3

When I try and run my project in xcode, I am getting the following error:

'auto_orientation/AutoOrientationPlugin.h' file not found.

If I remove this plugin, it will then go to the next plugin and fail on the .h file for that plugin and so on for every single plugin.

Previously this issue only used to happen when I attempted to make an archive, but it would always run without issues. Now it will not even run.

There are many threads about this and I have run through these but have so far been unable to find any suggestion that is working.

Pubspec.yaml file, as requested:

name: app_name
description: My application.

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# Read more about versioning at semver.org.
version: 6.0.0

environment:
  sdk: ">=2.3.0-dev.0.5 <3.0.0"


dependencies:
  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: 0.1.2
  firebase_admob: 0.5.5
  screen: 0.0.5
  image_picker: 0.6.1
  firebase_auth: 0.11.1+7
  shared_preferences: 0.4.3
  rflutter_alert: 1.0.2
  url_launcher: 5.0.3
  in_app_purchase: 0.2.0
  firebase_dynamic_links: 0.4.0+4
  app_review: 1.1.0+1
  auto_orientation: 1.0.4
  vibration: 1.2.1

dev_dependencies:
  flutter_test:
    sdk: flutter



# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec

# The following section is specific to Flutter.

flutter:
  assets:
  - lib/images/
  - lib/images/example1.png
  - lib/images/example2.png
  - lib/images/example3.png

uses-material-design: true

Screenshot for Cenk:

enter image description here

Bisclavret
  • 1,327
  • 9
  • 37
  • 65
  • Serves to give an indication of the length of time I have been attempting different solutions, reading different forums etc. Gives an idea that the answer might not be a simple one, and may take some 'outside the box' type solution (as the eventual answer in this thread will attest). So no, "halfer", that was not useful in any sense of the word, and was deliberately berating without reason. – Bisclavret Apr 04 '20 at 00:03
  • I understand your frustration, and I apologise if my tone seems too severe (I cannot myself tell). But I am sure that what you _meant_ by saying how long something has taken will be understood as begging by some readers. That interpretation process is out of your hands - it is a curse of human communication that words mean how they are heard, not how they are meant. – halfer Apr 04 '20 at 09:26
  • What is undoubtedly a useful observation is that we get a lot of begging here. All manner of urgency, ASAP, just-about-to-lose-my-job, kneeling prostrate on the floor, crying, tearing ones hair out, I'm desperate, I'm at my wit's end, and all manner of other obscene emotional coercion. I notice also that it is more common in some cultures than others. The reason I mention it - a lot - is that it ends up pressurising readers in a way that is inappropriate for volunteers. – halfer Apr 04 '20 at 09:29

5 Answers5

0

I guess you have some files missing for some reason.

I hope this steps maybe solve it:

  1. backup your flutter project folder
  2. delete "ios" folder from your your flutter project
  3. run flutter create -i swift , this command will recreate new 'ios' folder
  4. run your flutter project
halfer
  • 19,824
  • 17
  • 99
  • 186
abdalmonem
  • 1,367
  • 1
  • 10
  • 19
  • Hi abdalmonem, I have given this a shot, but I get the following error at step 3: "No option specified for the output directory." "Create a new Flutter project." "Usage: flutter create " – Bisclavret Mar 27 '20 at 13:28
  • @Bisclavret , you can create a new project in other path, then just copy 'ios' folder replace to the old project the name of the new project should be same as the old one – abdalmonem Mar 27 '20 at 13:36
  • Still not sure exactly what to do here. Not even sure what command you are suggesting I run, since the command you included in step 3 is wrong. Sorry mate. – Bisclavret Mar 28 '20 at 05:37
  • create new flutter project from your idea whith the same name of the current project , copy 'ios' folder from the new project to the old project , thats all , notice you maybe need to old 'Info.plist' file – abdalmonem Mar 28 '20 at 06:20
  • Sorry mate, no idea how to do any of this. Everything is simple and works perfectly on a PC with Android Studio. I am trying to port this over to ios now and it is just an absolute nightmare. This was all previously running fine, but just would not archive. Now it won't even run. I honestly don't know what "create new flutter project from your idea" means. I am guess .idea is some kind of a file. No idea where this is though or how to use it. – Bisclavret Mar 28 '20 at 06:51
  • i mean : create it with 'Android Studio' :) – abdalmonem Mar 28 '20 at 07:23
  • The program is already created with Android studio. It's fully functional. It's on the google play store. It's been generating me revenue for over a year now. This is just trying to port that same app over to ios now. IOS has Xcode only. I created a new project, I copied over the pubspec.yaml, ran flutter packages get. I copied over the ios folder. Now I get: Resolving dependencies... SLVR: fact: appname depends on in_app_puchase 0.2.0 ... and I get about 20 of these lines, one for every plugin. – Bisclavret Mar 28 '20 at 10:15
0

I have had such issues before. The error was because I deleted a package dependency from my pubspec.yaml. As we know deleting a package as such will remove all the flutter files it downloaded form pub.dev but forgot to delete the permission and method I added into Info.plist and AppDelegate.swift manually as dependencies for that package.

When Xcode see this methods in the AppDelegate.switf, it searches for the required files but it can't find them because the package was deleted from pubspec.yaml.

So cross-check if the content of those 2 files matches the packages that require them.

Hope it helps.

Edit

Based on your pubspec.yaml, they are some keys that need to be added to your AndroidManifest and info.plist files respectively. I assume you haven't done that from your comment.

Locations

AndroidManifist is found in android/app/src/main/AndroidManifiest.xml info.plist is found in iso/Runner/Info.plist

  1. For the firebase_admob package you need to add the following to your AndroidManifest

<meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="[ADMOB_APP_ID]"/>

Where [ADMOD_APP_ID] is your App ID. Check firebase_admod to see how to initialize an app ID and how to initialize the plugin

Then you need to add the following to your info.plist

<key>GADApplicationIdentifier</key> 

<string>[ADMOB_APP_ID]</string>
  1. For screen 0.0.5 you need to add the following permission to your 'AndroidManifest`

<uses-permission android:name="android.permission.WAKE_LOCK" />

  1. For image_picker: 0.6.1, you also need some permission added to the info.plist.

Add the following keys to your Info.plist file, located in /ios/Runner/Info.plist:

  • NSPhotoLibraryUsageDescription - describe why your app needs permission for the photo library. This is called Privacy - Photo Library Usage Description in the visual editor.
  • NSCameraUsageDescription - describe why your app needs access to the camera. This is called Privacy - Camera Usage Description in the visual editor.
  • NSMicrophoneUsageDescription - describe why your app needs access to the microphone if you intend to record videos. This is called Privacy Microphone Usage Description in the visual editor.

Android No configuration required - the plugin should work out of the box

  1. Not to be redundant, you need to browse you the package in you pubspec.yaml pub.dev page and follow the instruction to add all the dependencies for the packages to work.

I hope you project compiles now!

Loïc Fonkam
  • 2,284
  • 11
  • 25
  • I have not removed anything at all from pubspec, all my plugins are still there, and still required in the app. I have no idea where info.plist is, and have never heard of appdelegate.swift. So definitely haven't been editing these files either. – Bisclavret Mar 28 '20 at 06:49
  • Can we take a look at your pubspec.yaml? – Loïc Fonkam Mar 28 '20 at 12:59
  • 1
    Of course mate, I have added it to the original question. Thank you. – Bisclavret Mar 28 '20 at 15:07
  • Hi mate, sorry but I have done all this a long time ago. As I said originally, this was all running fine for months, meaning I have all those settings in place. Then it just stopped working. – Bisclavret Mar 29 '20 at 01:45
  • To humour you, I checked anyway. This is from my AndroidManifest.xml file: – Bisclavret Mar 29 '20 at 05:00
  • But you do not say where I am supposed to find the info.plist file and neither does any single person on the internet, for some reason. I have searched my mac for this file name and found 200 or so macthes. Where is this file and I will check it for you. – Bisclavret Mar 29 '20 at 05:01
  • I think I found that if I select the project name in xcode and click on "info" I have that GADApplicationIdentifier with the correct string listed. I highly appreciate you trying to help me, but every single individual plugin gives the missing.h file error, so it is not going to be an issue with each individual plugin, but rather something fundamentally broken with this entire platform. The first error I get is 'auto_orientation/AutoOrientationPlugin.h' file not found. This is the one listed in the question and you havent addressed that one. Might be the best place to start. – Bisclavret Mar 29 '20 at 05:06
  • I did tell you where to find info.plist . In my answer under location. `info.plist is found in iso/Runner/Info.plist` – Loïc Fonkam Mar 29 '20 at 11:56
  • Oh, so you did. Completely missed that, my apologies. – Bisclavret Mar 29 '20 at 12:43
0

Sometimes I also get ios compilation error in my project working properly, I create a clean project with the same name, copy my codes there and it gets better.

I suggest you try if you can't find a solution.

enter image description here

Cenk YAGMUR
  • 3,154
  • 2
  • 26
  • 42
  • Problem is I don't really know how to do this in xcode. On my real computer I can just open all the files and copy and paste them over in android studio. With the mac and xcode, it cant actually understand any of its own file extensions, and I have to open everything in text editor, it's an absolute nightmare of a system. Really need to be able to fix this properly. – Bisclavret Mar 28 '20 at 06:46
  • Did you try change File->Workspace Settings and set build system to Legacy Build System or New Build System ? – Cenk YAGMUR Mar 28 '20 at 10:32
  • Hi Cenk. I have been working through your suggestion, building a basic app from scratch. I build the original application, run it. Works fine. I add in the plugins only to my pubspec file and everything just falls over into a big pile. I have been working through many errors for hours today. Every time I solve an error, a new one appears. This is from a blank application. How unstable is this platform? – Bisclavret Mar 28 '20 at 15:09
  • I also do not have "workspace settings" under file. Have added screenshot to original question. – Bisclavret Mar 28 '20 at 15:12
  • I have the latest xcode, and your update does not show me at all HOW to get to this settings screen. As I showed you in my update, I don't have those options. See screenshot in my original question above. Thank you. – Bisclavret Mar 29 '20 at 01:42
  • I managed to find this setting under file > project settings in the newest versions, if this helps anyone. I set it to legacy build system as shown in the suggestion and tried to run the app again. Same error: 'auto_orientation/AutoOrientationPlugin.h' file not found. Thank you though, appreciate any and all suggestions at this stage. – Bisclavret Mar 29 '20 at 05:31
  • maybe can help you https://stackoverflow.com/questions/5198905/h-file-not-found – Cenk YAGMUR Mar 29 '20 at 10:08
0

you definitely do not need to wipe out your whole ios/ folder.

1) flutter cleancause why not

2) rm ios/Podfile.lock

3) rm -rf ios/Pods

4) rm -rf ~/.pub-cache/hosted/pub.dartlang.org/ (or wherever you set this up to live)

5) flutter packages get

then run/build your app however you normally do it.

blaneyneil
  • 3,122
  • 13
  • 14
  • Thank you @blaneyneil. I don't have any file anywhere on my mac that looks anything like this: 4) rm -rf ~/.pub-cache/hosted/pub.dartlang.org/ but I ran the command anyway. Now I get the exact same autoorientation.h error as before (when running from xcode), but also now on top of this when running flutter run -v I get a new error that states "could not find the built application bundle at build/ios/iphoneos/runner.app – Bisclavret Mar 28 '20 at 06:17
-1

In the end I found a fix for this in another forum:

Seems like by opening up the project by double clicking Runner.xcworkspace instead of Runner.xcodeproj xcode can finally figure out where everything is.

I tried this and it literally works. Now my app will run with a new error (because of course):

malloc: can't allocate region securely

But I will make a new question for that one.

halfer
  • 19,824
  • 17
  • 99
  • 186
Bisclavret
  • 1,327
  • 9
  • 37
  • 65
  • I wonder how you have a flutter project of this magnitude your building on mac and you don't know the location of `info.plist`. If you don't know it's location, then clearly you are missing some package dependencies. – Loïc Fonkam Mar 29 '20 at 12:03
  • Anyways, I am happy you found a solution. Bye – Loïc Fonkam Mar 29 '20 at 12:09
  • Yeah sorry mate, assumed it was a file, as it looks like a file in the vain of the android equivalent. Hate all things related to macs, macos and ios. Just, riddled with unecessary complications and problems. A necessary evil as they will not let me push my app to ios without running it from a mac. Yet another reason to hate everything they stand for. Had none of these issues on PC with Android Studio. Thank you for all of your suggestions. – Bisclavret Mar 29 '20 at 12:41