Plugin.h file not found: flutter and xcode

Viewed 2152

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

5 Answers

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

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!

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

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.

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.

Related