error: 'Flutter/Flutter.h' file not found when flutter run on iOS
Solution 1
I found a solution!
-
Backup
ios/Runner
folder. -
Delete the
ios
folder. -
Run
flutter create (your project name)
. in the previous folder where you have your project(cd users/user/"projects_folder"
) (this will recreate yourios
folder). -
Paste your Runner backup in the
ios
folder (into the project). -
Open
Runner.xcworkspace
(intoios
folder) and there, check the Version, the Bundle ID, all the info. -
(If do you Have Firebase, you have to copy and paste again the Google
Service-Info.Plist
into theRunner
folder (Always through Xcode) (If do you do this manually, it doesn't work).
Finally, flutter run
and should work!
If flutter run
fails:
cd ios
pod install
cd ..
flutter run
Solution 2
A way easier solution:
- Remove ios/Flutter/Flutter.podspec:
rm ios/Flutter/Flutter.podspec
flutter clean
- Run your app again.
Taken from here
Solution 3
It's happening caused by switching from master/dev back to beta/stable.
Here are two solutions are summarized
This is a bug of flutter and pod install. When flutter does pod install installation dependencies, the synchronization of the framework file in Flutter leads to the loss of the framework file. Once the card owner is lost once, it is only necessary to execute the pod install command. Can install user-specified dependencies, but cannot synchronize framework files in Flutter
Because of ios/Flutter/Flutter.podspec
the CocoaPods linking logic was moved into the flutter tool. However, when you switch back to beta/stable, that bogus podspec is still present, but the flutter tool linking logic has been reverted.
1 Solution
The following commands fixed this behavior:
-
cd ios
for going to iOS directory of the flutter app pod deintegrate
rm Flutter/Flutter.podspec
rm podfile.lock
flutter clean
flutter run
2 Solution
If the above solution does not work then try to switch the channel from Master to stable.
to switch your channel, run this in your terminal:
-
flutter channel stable
-
flutter clean
-
flutter run
Solution 4
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
Solution 5
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
Raffaelli L.C.
Updated on February 16, 2022Comments
-
Raffaelli L.C. about 2 years
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.
-
Raffaelli L.C. over 3 yearsI edit the answer, I hope it helps you. If you have any questions, ask me!
-
Cliff Helsel over 3 yearsDidn't work for me: fatal error: 'Flutter/Flutter.h' file not found. Running on channel master with build flavors.
-
Michele Volpato over 3 yearsI tried this, but deleting only
ios/Flutter
and not the entireios
folder, and it worked. Make a backup of it first! -
Viren V Varasadiya about 3 yearsThis is only solution work for me, Thank you!
-
Jason Waku about 3 yearsI 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.
-
zackygaurav about 3 yearsflutter.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.
-
Vit Veres about 3 yearsSame 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 `
-
Mol0ko about 3 yearsthey already released
firebase_crashlytics
v2.0.0, bug fixed -
p0wl about 3 yearsI'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 :)
-
Jayson O. about 3 yearsWorks like a charm. Thanks!
-
kyu about 3 yearsFrom 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. -
Zenko about 3 yearsSince the edit queue is full. If you have created a splash screen don't forget to overwrite the
Assets.xcassets
folder andMain.storyboard
andLaunchScreen.storyboard
. (IMPORTANT: You MUST manually drag and drop to Xcode, not simply overwrite it in Finder.) Moreover, copy the content ofinfo.plist
. -
edn about 3 years@Raffaelli L.C., you are a legend. I tried EVERYTHING but this one the only one that worked. Thank you for sharing.
-
Gorges about 3 yearsI also had to upgrade platform :ios, '10.0' in ios/Podfile
-
Adnan Kazi almost 3 yearsIn 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 👍
-
Andy A. almost 3 years@MostafaAEl-Hakak Please specify what you mean, your answere is hard to understand for me.
-
Karthik Kannan almost 3 yearsHi @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!
-
Amit Khetan almost 3 yearsI suggest don't do it like this. @PareshMangukiya answered the right way.
-
Ameer almost 3 yearsThis 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ński
-
genericUser almost 3 yearsI have added today firebase_crachlytics version 0.4.0 and faced the same problem. Updating the version solved the issue. Thanks!
-
Marvioso almost 3 yearsYou are an absolute life saver!
-
Harsh Phoujdar almost 3 yearsFlutter 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?
-
Fellow7000 almost 3 yearsI had only this config.build_settings['ENABLE_BITCODE'] = 'NO', so I removed it and the build worked out. thanks
-
Abbas over 2 yearsOr 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.
-
Cosmo Dai over 2 yearsMaybe missing this line:
flutter_additional_ios_build_settings(target)
-
Aziz over 2 yearsIt worked for me but deleting the entire ios folder and creating a new fresh one, then you can apply your edits after it.
-
Eray Hamurlu over 2 yearsI didn't paste backup ios folder and work fine with new created ios folder.
-
rbatty19 over 2 yearsreally good advice ( solved on M1 mac ), thank you
-
Kamil OZTURK over 2 yearsI 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.
-
Beyond Chao over 2 yearsThanks! Worked for me! It's happening caused by switching flutter version from to 2.2.1 to 1.22.2
-
Astik Anand over 2 yearsThanks a lot for this answer @RaffaelliL.C.
-
LearningPath about 2 yearsAfter following these steps, i have still this issue...any other clues?
-
Leena Marie about 2 yearsSaved my life!!
-
Almett about 2 yearsSolution 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.
-
Ian Wambai about 2 yearsThere 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.
-
ZeroCode about 2 yearsDidn't fix the issue for me on m1 chip.
-
ZXERSTON almost 2 yearsI 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"
-
ZXERSTON almost 2 yearsI 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
-
Mr. Ripper almost 2 years@ 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 periods
-
Tsimbalyuk Konstantin almost 2 yearsYou save my day!!! 🙏 you!!!
-
Ujjawal Maurya almost 2 yearsIt's not a SDK related problem