error: 'Flutter/Flutter.h' file not found when flutter run on iOS
Asked Answered
Y

37

158

I don't know why but I can't build or run the App in my new Macbook, I run the same folder on another Mac or my windows computer and runs perfectly. here when I run flutter clean, I have to run pub get to solve the issues, Is that normal?

If I create a new project, I can run flutter run normally, so I think that maybe there I think it may be related to plugins.

Do you know how can I solve this? Thanks

Flutter Doctor
[✓] Flutter (Channel master, 1.24.0-8.0.pre.343, on macOS 11.0.1 20B29 darwin-x64, locale es-419)
    • Flutter version 1.24.0-8.0.pre.343 at /Users/leo/tools/flutter
    • Framework revision cf6c33e58a (2 days ago), 2020-11-21 14:04:01 -0800
    • Engine revision 23a8e027db
    • Dart version 2.12.0 (build 2.12.0-62.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/leo/Library/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.2, Build version 12B45b
    • CocoaPods version 1.9.3

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] Connected device (2 available)
    • sdk gphone x86 arm (mobile) • emulator-5554                        • android-x86 • Android 11 (API
      30) (emulator)
    • iPhone 12 Pro Max (mobile)  • F768139D-7B87-4D9E-93B8-14C7D63786B0 • ios         •
      com.apple.CoreSimulator.SimRuntime.iOS-14-2 (simulator)

• No issues found!




Launching lib/main.dart on iPhone 12 Pro Max in debug mode...
Running Xcode build...                                                  
Xcode build done.                                           11.4s
Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **


Xcode's output:
↳
    <module-includes>:1:9: note: in file included from <module-includes>:1:
    #import "Headers/vibration-umbrella.h"
            ^
    /Users/leo/Apps/previate_esta/ios/Pods/Target Support Files/vibration/vibration-umbrella.h:13:9: note:
    in file included from /Users/leo/Apps/previate_esta/ios/Pods/Target Support
    Files/vibration/vibration-umbrella.h:13:
    #import "VibrationPlugin.h"
            ^
    /Users/leo/.pub-cache/hosted/pub.dartlang.org/vibration-1.4.0/ios/Classes/VibrationPlugin.h:1:9: error:
    'Flutter/Flutter.h' file not found
    #import <Flutter/Flutter.h>
            ^
    <unknown>:0: error: could not build Objective-C module 'vibration'
    In file included from
    /Users/leo/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.5.3/ios/Classes/FLTURLLauncherPlugin.m:7:
    /Users/leo/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.5.3/ios/Classes/FLTURLLauncherPlugin.h:5:9
    : fatal error: 'Flutter/Flutter.h' file not found
    #import <Flutter/Flutter.h>
            ^~~~~~~~~~~~~~~~~~~
    1 error generated.
    In file included from
    /Users/leo/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.10/ios/Classes/FLTSharedPreference
    sPlugin.m:5:
    /Users/leo/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.10/ios/Classes/FLTSharedPreference
    sPlugin.h:5:9: fatal error: 'Flutter/Flutter.h' file not found
    #import <Flutter/Flutter.h>
            ^~~~~~~~~~~~~~~~~~~
    1 error generated.
    In file included from
    /Users/leo/.pub-cache/hosted/pub.dartlang.org/share-0.6.5/ios/Classes/FLTSharePlugin.m:5:
    /Users/leo/.pub-cache/hosted/pub.dartlang.org/share-0.6.5/ios/Classes/FLTSharePlugin.h:5:9: fatal
    error: 'Flutter/Flutter.h' file not found
    #import <Flutter/Flutter.h>
            ^~~~~~~~~~~~~~~~~~~
    1 error generated.
    In file included from
    /Users/leo/.pub-cache/hosted/pub.dartlang.org/sensors-0.4.2+4/ios/Classes/FLTSensorsPlugin.m:5:
    /Users/leo/.pub-cache/hosted/pub.dartlang.org/sensors-0.4.2+4/ios/Classes/FLTSensorsPlugin.h:5:9: fatal
    error: 'Flutter/Flutter.h' file not found
    #import <Flutter/Flutter.h>
            ^~~~~~~~~~~~~~~~~~~
    1 error generated.
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Constructing build description

Could not build the application for the simulator.
Error launching application on iPhone 12 Pro Max.
Yearly answered 23/11, 2020 at 17:31 Comment(3)
For someone in 2021 facing this issue, here is the solution that worked for me https://stackoverflow.com/a/67110794/8647537Tatianna
I found a simple solution. #64973846 It saves your timeArkhangelsk
In my case all i have to is adding " pod 'Firebase/Core' " in my podfile. flutter_ios_podfile_setup target 'Runner' do use_frameworks! use_modular_headers! pod 'Firebase/Core' flutter_install_all_ios_pods File.dirname(File.realpath(FILE)) endHernandes
Y
116

I found a solution!

  1. Backup ios/Runner folder.

  2. Delete the ios folder.

  3. Run flutter create (your project name). in the previous folder where you have your project(cd users/user/"projects_folder") (this will recreate your ios folder).

  4. Paste your Runner backup in the ios folder (into the project).

  5. Open Runner.xcworkspace (into ios folder) and there, check the Version, the Bundle ID, all the info.

  6. (If do you Have Firebase, you have to copy and paste again the Google Service-Info.Plist into the Runner folder (Always through Xcode) (If do you do this manually, it doesn't work).

Finally, flutter run and should work!

If flutter run fails:

  1. cd ios
  2. pod install
  3. cd ..
  4. flutter run
Yearly answered 24/11, 2020 at 19:52 Comment(17)
I tried this, but deleting only ios/Flutter and not the entire ios folder, and it worked. Make a backup of it first!Prince
flutter.h error is now gone with this solution. It works. Any reason? I am an Android Developer so I don't have a clue what is happening under the hood in iOS.Viscountess
Since the edit queue is full. If you have created a splash screen don't forget to overwrite the Assets.xcassets folder and Main.storyboard and LaunchScreen.storyboard. (IMPORTANT: You MUST manually drag and drop to Xcode, not simply overwrite it in Finder.) Moreover, copy the content of info.plist.Acriflavine
@Raffaelli L.C., you are a legend. I tried EVERYTHING but this one the only one that worked. Thank you for sharing.Bara
I also had to upgrade platform :ios, '10.0' in ios/PodfileFishing
Hi @RaffaelliL.C. I have a question, where do you paste your backup iOS project? When I ran flutter create foo_bar it created a totally new flutter project for me called foo_bar inside my already existing project. This new project had an ios/ folder so it's a bit confusing as to where to paste my new folder. Thanks!Ada
I suggest don't do it like this. @PareshMangukiya answered the right way.Mammon
Flutter create is not working for me "testProject" is not a valid Dart package name. See dart.dev/tools/pub/pubspec#name for more information. I think what might have happened here, is previous version of Flutter would have allowed a camel cased project name, while the current one does not. How to come out of this mess?Conciliar
It worked for me but deleting the entire ios folder and creating a new fresh one, then you can apply your edits after it.Luckin
I didn't paste backup ios folder and work fine with new created ios folder.Assiduity
After following these steps, i have still this issue...any other clues?Stupidity
There has to be a better solution than this, I have made too many custom changes to my iOS project and deleting the entire thing is not an option for me.Misadvise
I am facing an issue after running flutter create . It says "PROJECT NAME" is not a valid Dart package name. See dart.dev/tools/pub/pubspec#name for more informationCollincolline
i was try this solution. but, it doesn't helped me. it still give me errorGrummet
in June 2023 it worked really good. Thanks man! I was searching for a solution for 2 Days now!Imponderabilia
Hi, may I ask whether the 'Flutter/Flutter.h' file exists? If it does, can I simply copy the 'Flutter/Flutter.h' file example from others and paste it into my project?Polivy
I tried your solution, and it didn't work for me. Is there anything I need to pay attention to? Did I miss some important details?Polivy
H
107

A way easier solution:

  1. Remove ios/Flutter/Flutter.podspec: rm ios/Flutter/Flutter.podspec
  2. flutter clean
  3. Run your app again.

Taken from here

Handcrafted answered 5/1, 2021 at 10:39 Comment(6)
Didn't work for me: fatal error: 'Flutter/Flutter.h' file not found. Running on channel master with build flavors.Neologize
I tried this with "rm podfile.lock" after 1st step. and clean the cache in android studio , restored it. so the error is gone in my case. thanks. it was a good shortcut.Snot
Thanks! Worked for me! It's happening caused by switching flutter version from to 2.2.1 to 1.22.2Breann
Doing this gave me a new error: "could not find included file 'Generated.xcconfig' in search paths" ... which is progress.Wensleydale
Hi, may I ask whether the 'Flutter/Flutter.h' file exists? If it does, can I simply copy the 'Flutter/Flutter.h' file example from others and paste it into my project?Polivy
I tried your solution, and it didn't work for me. Is there anything I need to pay attention to? Did I miss some important details?Polivy
I
41

This solution worked for me:

Changing PodFile from:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
    config.build_settings['ENABLE_BITCODE'] = 'NO'
    config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.0'
    end
  end
end

to

post_install do |installer|
  installer.pods_project.targets.each do |target| 
    flutter_additional_ios_build_settings(target)
  end
end
Irvingirwin answered 7/4, 2021 at 12:50 Comment(7)
I'm sorry, I don't really know anything about pod files. But it seems that there is a new method that handles this case smoothly. Correct me, if I'm wrong :)Irvingirwin
From what I understood flutter_additional_ios_build_settings(target) is automatically added from Flutter 2.0. I created my project in Flutter version 1.0 which didn't contain this line in the PodFile. That was my problem.Kelsey
I had only this config.build_settings['ENABLE_BITCODE'] = 'NO', so I removed it and the build worked out. thanksAdult
Maybe missing this line: flutter_additional_ios_build_settings(target)Mucoid
this worked for me thanksNitrogenous
Hi, may I ask whether the 'Flutter/Flutter.h' file exists? If it does, can I simply copy the 'Flutter/Flutter.h' file example from others and paste it into my project?Polivy
I tried your solution, and it didn't work for me. Is there anything I need to pay attention to? Did I miss some important details?Polivy
T
26

Edit: a new version of Crashlytics has just been release for Flutter 2. Just upgrade your pubspec.yml:

firebase_crashlytics: ^2.0.0

Below is my old answear.

For Flutter 2, you can follow the instructions in this GitHub comment. Text pasted below:

Workaround for Flutter 2.0.4 is to use firebase_crashlytics from git instead of pub.dev. This seems to work (ref to the currently latest commit):

  firebase_crashlytics:
    git:
      url: git://github.com/FirebaseExtended/flutterfire.git
      path: packages/firebase_crashlytics/firebase_crashlytics
      ref: 200b8ca8f1c452e4249fb791e53cc55e786ac768
Turnpike answered 5/4, 2021 at 18:41 Comment(1)
they already released firebase_crashlytics v2.0.0, bug fixedBibelot
B
18

Solution 1

  1. Back up the Runner folder in your ios folder to a safe place.

  2. Delete the ios folder:

enter image description here

  1. Still in the root directory, run the following command( including the space and period):

flutter create .

A new ios folder will be generated inside your project.

  1. Copy and paste the Runner folder you have backed up before to the new ios folder:

enter image description here

A dialog will appear. Click on the Replace button to continue.

  1. If your project is NOT using Firebase, you can ignore this step and move on to the next one. Otherwise, you need to re-add the GoogleService-Info.plist file by opening the ios folder with Xcode, right-click on Runner, choose Add Files to “Runner” from the drop-down menu, then select the GoogleService-Info.plist file that is associated with your project.

enter image description here

  1. Navigate to your ios folder and run:

pod install

You may fall into something like this:

enter image description here

# Uncomment this line to define a global platform for your project platform :ios, '11.0'

Now run pod install again, and it should work (a few warnings may appear, but we don’t care about them).

  1. Finally, go back to your root directory and run your project as normal (don’t forget to launch an iOS simulator first):

cd .. flutter run

If you still get errors, clear the Flutter’s build cache by executing this:

flutter clean

And update dependencies in .pub-cache:

flutter pub cache repair

Then run your project again.

Solution 2

Occasionally, the error is caused by a simple reason: you are currently on the Master channel instead of the Stable channel. According to the Flutter wiki:

Master channel: The current tip-of-tree, absolute latest cutting edge build. Usually functional, though sometimes things accidentally break. Stable channel: This channel is strongly recommend to use for all production app releases. What you need to do now is to switch to the stable channel:

flutter channel stable

Then:

flutter clean

Finally:

flutter run

Solution 3

You could try this if the two approaches above didn’t solve the problem.

  1. Go to /ios folder and delete the following:

Flutter/Flutter.podspec file Pods folder Podfile.lock file

  1. Still in the ios folder, execute the following command:

pod install --repo-update

  1. Navigate to the root directory of your project and clean your project by running this command:

flutter clean

  1. Run it:

flutter run

Hope this helps... Credit: A Goodman

Brawley answered 29/11, 2021 at 9:24 Comment(5)
Solution 1 helped me. Copying the Runner file before removing the ios folder and paste back again after is the only extra step I took compared to the solution of @Paresh Mangukiya below.Misbegotten
I am facing an issue after running flutter create . It says "PROJECT NAME" is not a valid Dart package name. See dart.dev/tools/pub/pubspec#name for more information"Collincolline
@ ZXERSTON Please ensure to run 'flutter create .' while in the root directory, (including the space and period. If you're not sure how to get to the root directory, run 'cd ..' in the terminal including the space and 2 periodsBrawley
Hi, may I ask whether the 'Flutter/Flutter.h' file exists? If it does, can I simply copy the 'Flutter/Flutter.h' file example from others and paste it into my project?Polivy
I tried your solution, and it didn't work for me. Is there anything I need to pay attention to? Did I miss some important details?Polivy
O
18

In My case i have fix the issue

Runner -->Build phases--->Untick for install only enter image description here

Outstand answered 22/4, 2022 at 4:31 Comment(1)
For me it's workedWernsman
T
12

It might happen that particular iOS POD depedency does not have Flutter dependency.

In my case it was firebase_crashlytics: ^1.0.0

Unfortunately it is up to maintainer to provide working solution. You might remove cached version located at:

/Users/user/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_crashlytics-1.0.0/ios/firebase_crashlytics.podspec

Please visit this issue for reference.

The .podspec for particular 3rd party lib should have:

s.dependency 'Flutter'

in

Pod::Spec.new do |s|
   ...

Then, invoke pod install in ios directory, to reflect the change.

Lastly, schedule your build.

Triphammer answered 4/4, 2021 at 17:11 Comment(2)
Same for me. The easiest temporary solution is to use the version of library from git. ` firebase_crashlytics: git: url: git://github.com/FirebaseExtended/flutterfire.git path: packages/firebase_crashlytics/firebase_crashlytics `Sihon
This solution worked for me with Flutter Channel stable, 2.2.1. The only additional thing I did is Pub get + Pub Upgrade after making shared changes. Thanks @Michał Dobi DobrzańskiRalli
C
10

If Flutter permission_handler Related

If you've just integrated permission_handler for flutter into your app, and followed instructions to modify the ios podfile to add needed permissions, you may encounter this error using the provided instructions.

I started receiving the fatal error: 'Flutter/Flutter.h' file not found error after modifying the podfile.

Solution

The solution is to change the way the podfile modification is made so that flutter_additional_ios_build_settings(target) is properly and included, with proper nesting for the target.build_configurations.each... array.

Example Podfile Modification

post_install do |installer|
  installer.pods_project.targets.each do |target|
        flutter_additional_ios_build_settings(target)
        target.build_configurations.each do |config|
            # You can enable the permissions needed here. For example to enable camera
            # permission, just remove the `#` character in front so it looks like this:
            #
            # ## dart: PermissionGroup.camera
            # 'PERMISSION_CAMERA=1'
            #
            # When enabled here, corresponding metadata should be added to info.plist
            config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
                '$(inherited)',

                ## dart: PermissionGroup.calendar
                # 'PERMISSION_EVENTS=1',

                ## dart: PermissionGroup.reminders
                # 'PERMISSION_REMINDERS=1',

                ## dart: PermissionGroup.contacts
                # 'PERMISSION_CONTACTS=1',

                ## dart: PermissionGroup.camera
                # 'PERMISSION_CAMERA=1',

                ## dart: PermissionGroup.microphone
                # 'PERMISSION_MICROPHONE=1',

                ## dart: PermissionGroup.speech
                # 'PERMISSION_SPEECH_RECOGNIZER=1',

                ## dart: PermissionGroup.photos
                # 'PERMISSION_PHOTOS=1',

                ## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
                # 'PERMISSION_LOCATION=1',

                ## dart: PermissionGroup.notification
                # 'PERMISSION_NOTIFICATIONS=1',

                ## dart: PermissionGroup.mediaLibrary
                # 'PERMISSION_MEDIA_LIBRARY=1',

                ## dart: PermissionGroup.sensors
                # 'PERMISSION_SENSORS=1',

                ## dart: PermissionGroup.bluetooth
                # 'PERMISSION_BLUETOOTH=1',

                ## dart: PermissionGroup.appTrackingTransparency
                # 'PERMISSION_APP_TRACKING_TRANSPARENCY=1',

                ## dart: PermissionGroup.criticalAlerts
                # 'PERMISSION_CRITICAL_ALERTS=1'
            ]
        end
    end
end
Carlacarlee answered 8/11, 2021 at 17:8 Comment(0)
A
10

If you ever changed build phases scripts in xcode, verify that Run script(/bin/sh "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" build) is before Compile Sources enter image description here

Anuria answered 11/1, 2023 at 11:30 Comment(0)
T
8

I tried all the above solutions and but I ended up re-creating the ios directory.

rm -rf ios
flutter create -i swift .

Note: by performing the above steps will lose all native ios setup. In my case I was getting this error in the demo project I did this.

Tollman answered 7/6, 2021 at 15:31 Comment(1)
I tried all solutions, and I spent more than a day working on it, but nothing worked, thanks for your response.Barringer
C
6

Something that worked for me:

Some of the dependencies in my pubspec were outdated (specifically I was using crashalytics 1.0.0 with Flutter 2.0.5, which are incompatible and thus throwing this error).

Upgrading crashalytics to 2.0.0 fixed it for me.

I would look into whatever package is throwing this error, and see if any upgrades are available. If that does not work, try downgrading your flutter version.

Cupulate answered 21/4, 2021 at 18:9 Comment(2)
In my case, I had a large number of old dependencies so I cant manually change it, but your other solution worked like a charm I have downgraded the flutter version to 2.0.3 and it worked thanks 👍Pocketknife
I have added today firebase_crachlytics version 0.4.0 and faced the same problem. Updating the version solved the issue. Thanks!Wit
S
6

Use this commend in your terminal:

flutter pub cache repair
Sentimentalize answered 17/5, 2021 at 8:57 Comment(3)
@MostafaAEl-Hakak Please specify what you mean, your answere is hard to understand for me.Alisaalisan
Didn't fix the issue for me on m1 chip.Barnstorm
This worked for me. My situation: trying to build the app on a Mac after doing a large majority of the development on a Windows PC. The app doesn't use Crashalytics.Winfredwinfrey
L
6

The reason might be Podfile conflict. (ex. in case : after merge source code .v.v.)

It is easy way, re-install Pod file.

To completely clean (Removing all points to links) and create upgraded to the new (uninstall and installing again too),

Write following command :

flutter clean

rm -Rf ios/Pods
rm -Rf ios/.symlinks
rm -Rf ios/Flutter/Flutter.framework
rm -Rf ios/Flutter/Flutter.podspec

Then for reproduce Podfile follow this command

rm ios/Podfile

Finally your project is ready to good to go

flutter run
Layne answered 13/10, 2021 at 10:3 Comment(0)
D
5

Yet another approach...

If you stumble across this issue in a Flutter project that uses Firebase, and non of the above steps worked, try the following:

  1. Backup your project (just in case).
  2. Delete the whole ios folder insider your Flutter project.
  3. Call flutter create <projectname> at the parent folder of your flutter project (i.e. one folder above). This will recreate the ios folder.
  4. Move the GoogleService-Info.plist file to your project in Xcode.
  5. Now to the important part: When you follow the instructions at Firebase console under "Add firebase to your iOS app", skip step 3 (Add Firebase SDK) and skip step 4 (Add initialization code). In other words: Don't call pod init and don't call pod install. Also keep the AppDelegate unchanged! Instead simply call flutter run, which handles setting up the pods.
  6. In ios/Podfile: Uncomment the line platform :ios, '8' and set the iOS version (12.1 seems to be a good fit at the time of writing). Set the same version in Xcode at PROJECT -> Runner -> Deployment Target -> iOS Deployment Target and (also in Xcode) under TARGETS -> Runner -> Deployment Info.
  7. Call flutter clean and flutter run

With a little luck you've got it back running.

Dangerous answered 30/6, 2021 at 8:36 Comment(0)
L
5

here is how i solved the problem:

  1. run on your terminal flutter packages upgrade
  2. create a backup of your 'iOS' folder on the project.
  3. delete your 'iOS' folder from your project.
  4. run flutter clean
  5. run flutter pub get
  6. run flutter create . on your root project directory
  7. This will create an 'ios' folder in the repo. Copy the Info.plist, Podfile and any other config files like GoogleServices.plist from the backup 'ios' folder to the newly created 'ios' folder.

try to run your project again. it should work now:)

Livingston answered 20/3, 2022 at 18:13 Comment(1)
This should be new accepted answer in 2023, i've been at it for 4 days...this solution worked !!!!, thanks @aligurStickseed
W
5

For me it helped to update my podfile to the following :

post_install do |installer|
  installer.generated_projects.each do |project|
    project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
         end
    end
end
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end

credit to https://mcmap.net/q/87908/-missing-file-libarclite_iphoneos-a-in-xcode-14-3-after-update-flutter-and-xcode

Wobbly answered 13/8, 2023 at 17:35 Comment(0)
C
4

I hit my head for 3 days with this error. In my case, This error was happening due to a plugin : webview_flutter.

This is how approached to this problem:

1.) remove that plugin from pubspec.yaml

2.) cd ios

3.) pod deintegrate

4.) again add that plugin in pubspec.yaml

5.) flutter clean

6.) flutter pub get

7.) cd iOS

8.) pod install

This should work! It worked in my project.

Clarsach answered 7/8, 2021 at 9:26 Comment(1)
I got this error beacuse of webview_flutter but these steps didnt work for me. i think reason of this error releted the podfile configuration. it can be related about "use_frameworks!" or platform ios declaration or else. Im not sure.Cottbus
T
3

Change inside Podfile

#platform :ios, '9.0'

Uncomment this line to define a global platform for your project in the Podfile

platform :ios, '13.0'

Tested in VSCode ✅ It will save your 3 hours.

Theressathereto answered 13/10, 2021 at 20:20 Comment(0)
C
3

I think the case and solution would be varied but try and fail each case on this post is sometimes still helpful. My case:

Repair pub cache

flutter pub cache repair

Run your project, this should show if any dependency those the pod obsolete with

flutter run

Get rid of your flutter build

flutter clean

rm ios/Podfile

Update the pod

pod repo update

Run your project again and hope it works out

flutter run
Converted answered 14/10, 2021 at 1:16 Comment(0)
C
2

Deleted these files, and recrete as @Raffaelli L.C. answered. flutter run command worked now enter image description here

Crapulent answered 17/4, 2021 at 2:56 Comment(0)
C
2

the solution is to
1 - change your flutter sdk location and make sure that your flutter sdk new location doesnot have any space char
2 - delete your pods
3 - flutter clean
4 - flutter pub get
5 - cd ios
6 - pod install
7 - flutter run

Credulity answered 4/5, 2021 at 11:58 Comment(1)
really good advice ( solved on M1 mac ), thank youCantrell
M
2
In file included from /Users/user/.pub-cache/hosted/pub.dartlang.org/firebase_crashlytics-0.4.0+1/ios/Classes/FLTFirebaseCrashlyticsPlugin.m:5:
/Users/user/.pub-cache/hosted/pub.dartlang.org/firebase_crashlytics-0.4.0+1/ios/Classes/FLTFirebaseCrashlyticsPlugin.h:8:9: fatal error: 'Flutter/Flutter.h' file not found
#import <Flutter/Flutter.h>
        ^~~~~~~~~~~~~~~~~~~
While building module 'firebase_core' imported from /Users/user/.pub-cache/hosted/pub.dartlang.org/firebase_crashlytics-0.4.0+1/ios/Classes/FLTFirebaseCrashlyticsPlugin.h:12:
In file included from <module-includes>:1:
In file included from /Users/user/Documents/Projects/Vorso-Maui/flutter/vorso_maui/ios/Pods/Target Support Files/firebase_core/firebase_core-umbrella.h:13:
/Users/user/.pub-cache/hosted/pub.dartlang.org/firebase_core-0.7.0/ios/Classes/FLTFirebaseCorePlugin.h:8:9: fatal error: 'Flutter/Flutter.h' file not found
#import <Flutter/Flutter.h>
        ^~~~~~~~~~~~~~~~~~~
1 error generated.
2 errors generated.

As mentioned by other responses here, Firebase Crashlytics caused this error for me, due to [firebase_crashlytics] 'Flutter/Flutter.h' file not found #5440

The version of the last legacy release of Firebase Crashlytics was 0.4.0+1, which did not include the fix. The fix was included in a later null-safe version (v2.0.0).

However, when I tried to use versions v2+ in which the bug had been fixed, I got trapped in dependency hell - unresolvable conflicts between dependencies / sub-dependencies.

So, I created a fork (firebase_crashlytics_legacy) to provide the fix in a legacy compatible version.

This forked version is 0.4.0+x for consistency.

Hopefully it helps make it easy for others to use the legacy version with this bug fixed.

Myeshamyhre answered 17/9, 2021 at 16:19 Comment(1)
You save my day!!! 🙏 you!!!Orlina
N
1

I'd a similar problem, in my case I wasn't able to build my project even using command line or using xCode, but when I ran pod install --verbose I realize that there was an specific error during pod install

undefined method `each_child' for #Dir:0x00007ff10befa7f0 Did you mean? each_slice

Looking for this specific error I found this answer and I realize that I was using ruby 2.5 and one file generated by Flutter for iOS devices was trying to use a method that was introduced on version 2.6.

After follow the steps on that answer I could run my Flutter app on iOS simulator.

The method dir.each_child was introduced in Ruby 2.6, but you are using Ruby 2.3.0.

You should update Ruby to 2.6.0 or later 2.x version.

After Ruby updating you may also need to restart your IDE and re-install cocoapods.

Natale answered 24/5, 2021 at 23:8 Comment(0)
A
1

I got it solved by Adding arm64 for Excluded Architectures in pods & main target.

And answered 18/8, 2021 at 15:25 Comment(0)
M
1

If you only encounter this problem when running "flutter build ipa", in XCode make sure your Deployment Info under Runner and Pods matches the 'platform' in ios/Podfile.

Podfile

Runner

Mathewmathews answered 7/2, 2022 at 15:25 Comment(0)
P
1

You have to make changes in your ios folder Podfile as per below code :

# Uncomment this line to define a global platform for your project
platform :ios, '13.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}

def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
  raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end

File.foreach(generated_xcode_build_settings_path) do |line|
  matches = line.match(/FLUTTER_ROOT\=(.*)/)
  return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target) // This error occurred if this line is missing in Podfile
  end
end

After above change, run below commands in terminal :

flutter clean
flutter pub get
flutter run
Pitapat answered 12/1, 2024 at 10:46 Comment(0)
C
0

I was stuck at this error message for months ! After a lot of trial and errors I finally, finally got it working and these were the steps I followed.

  1. Go to your project folder, delete the ios folder in the project
  2. Create a new project by running flutter create . This step actually did not work for me because my project name was CamelCase, and maybe a recent update for Flutter did not allow this as the project name. I had to change the project name throughout the project before I ran this command.
  3. Step 2 actually created a new project inside my existing one, but don't worry about that, all you require is the ios folder from that.
  4. Copy-paste this ios folder into your project folder and delete the newly created project folder, you don't need this anymore (I am sure there is a better way to do this).
  5. Flutter run gave me a Could not locate configuration file: 'GoogleService-Info.plist' error, this was easily solved by getting the latest GooglService file from Firebase and adding in through X-code.
  6. Then flutter run, ran on my physical device and voila !
Conciliar answered 11/7, 2021 at 18:36 Comment(1)
Or you can simply delete the ios directory and do "flutter create ." ios inside your project directory, to create a fresh new ios directory. Make sure to backup any code that you did manually inside the ios file.Nahshon
S
0

This error is due to not using the appropriate flutter version. Your packages are written in old flutter version. You can update packages to latest versions or you can revert to the flutter version appropriate for the packages you use in your project.

Sepulcher answered 27/7, 2021 at 13:4 Comment(0)
A
0

1-Run flutter create (your project name). in the previous folder where you have your project(cd users/user/"projects_folder") (this will recreate your ios folder).

2-uncomment #platform :ios, '9.0' in the Podfile - i set that '10.0'

3-pod repo update

4-pod install

Assiduity answered 16/9, 2021 at 14:5 Comment(0)
U
0

Flutter version on my mac was higher than the flutter version where I coded the application on… So I just downgraded my flutter to the version I coded on And tada Error resolved Make sure you are on the same version of flutter as the laptop you coded on In my case I coded it on old version of flutter on my windows laptop and tired to run on latest version of flutter so the error popped up. If this is your case then go through the below link - Flutter simulator error: Command PhaseScriptExecution failed with a nonzero exit code

Upmost answered 16/11, 2021 at 4:56 Comment(0)
M
0

A really simple solution that worked for me was simply: close the xcode project. Then, on Android Studio, build the iOS archive by going to Build -> Flutter -> Build iOS. Then reopen the xcode project and it built and ran fine.

Maffei answered 15/2, 2022 at 10:51 Comment(0)
G
0

This happened me too. After follow below steps problem sorted for me !

  1. Back up the Runner folder in your ios folder to a safe place.
  2. Delete the ios folder:
  3. Go to the root directory, run the following command:

flutter create .

  1. After above step, will create ios folder. Copy and paste the Runner folder you have backed up before to the new ios folder:
  2. Run the project in android studio or VS code
  3. Navigate to your ios folder and run:

pod install

  1. ios > Runner.xcworkspace right click and Flutter > Open iOS module in xCode enter image description here

It will work :)

Gastroenterostomy answered 21/2, 2022 at 8:25 Comment(0)
W
0
  1. Copy info.plist, Assets.xcassets and other important files.
  2. Create a New project with same name and bundle id.
  3. Add an iOS project in your old project and add 1st step information in that.
  4. Run project. It's working now.
Whiffen answered 1/3, 2022 at 3:59 Comment(0)
A
0

I found a simple solution. just in case save backup :)

  1. rm -rf ios
  2. flutter create -i swift .

That's it.

Arkhangelsk answered 6/8, 2022 at 1:35 Comment(0)
A
0

Give full access to your Xcode from mac System Settings -> Privacy & Security -> Full Disk Access and from the app list turn on Xcode toggle button. enter image description here

Antitank answered 17/11, 2022 at 7:46 Comment(2)
This is actually how I fixed this problem. I was building on a new MacBook Pro and hadn't given Xcode the permissions it needed. The other error I was seeing was the Build Script failing. After giving access I could Build in Xcode. I don't understand why this had been downvoted.Flofloat
Did not work for meOctangle
V
0

delete the following in your ios folder:

# Flutter/Flutter.podspec file

# Pods folder

# Podfile.lock file

go to your ios folder (cd ios), execute the following command:

pod install --repo-update

back to you project folder and run

flutter clean

flutter run
Verada answered 26/6, 2023 at 12:31 Comment(0)
N
-3

Downgrade flutter to 1.22.6 (any version below 2.0.0)

Option 1

flutter downgrade v1.22.6

After this, run any Flutter command (such as flutter doctor), and Flutter will take care of downloading/compiling everything required to run this version.

Option 2

You can also download other versions of Flutter SDK from here

Nonpros answered 22/6, 2021 at 7:33 Comment(1)
It's not a SDK related problemCletacleti

© 2022 - 2025 — McMap. All rights reserved.