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.
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 your ios folder).
Paste your Runner backup in the ios folder (into the project).
Open Runner.xcworkspace (into ios 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 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:
cd ios
pod install
cd ..
flutter run
A way easier solution:
Remove ios/Flutter/Flutter.podspec: rm ios/Flutter/Flutter.podspec
flutter clean
Run your app again.
Taken from here
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
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
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.
Solution 1
Back up the Runner folder in your ios folder to a safe place.
Delete the ios folder:
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.
Copy and paste the Runner folder you have backed up before to the new ios folder:
A dialog will appear. Click on the Replace button to continue.
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.
Navigate to your ios folder and run:
pod install
You may fall into something like this:
# 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).
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.
Go to /ios folder and delete the following:
Flutter/Flutter.podspec file
Pods folder
Podfile.lock file
Still in the ios folder, execute the following command:
pod install --repo-update
Navigate to the root directory of your project and clean your project by running this command:
flutter clean
Run it:
flutter run
Hope this helps... Credit: A Goodman
In My case i have fix the issue
Runner -->Build phases--->Untick for install only
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.
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
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.
Use this commend in your terminal:
flutter pub cache repair
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:
Backup your project (just in case).
Delete the whole ios folder insider your Flutter project.
Call flutter create <projectname> at the parent folder of your flutter project (i.e. one folder above). This will recreate the ios folder.
Move the GoogleService-Info.plist file to your project in Xcode.
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.
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.
Call flutter clean and flutter run
With a little luck you've got it back running.
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.
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
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
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.
Deleted these files, and recrete as #Raffaelli L.C. answered.
flutter run command worked now
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
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.
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.
I got it solved by Adding arm64 for Excluded Architectures in pods & main target.
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.
here is how i solved the problem:
run on your terminal flutter packages upgrade
create a backup of your 'iOS' folder on the project.
delete your 'iOS' folder from your project.
run flutter clean
run flutter pub get
run flutter create . on your root project directory
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 be work now:)
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.
Go to your project folder, delete the ios folder in the project
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.
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.
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).
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.
Then flutter run, ran on my physical device and voila !
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.
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
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
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.
This happened me too. After follow below steps problem sorted for me !
Back up the Runner folder in your ios folder to a safe place.
Delete the ios folder:
Go to the root directory, run the following command:
flutter create .
After above step, will create ios folder. Copy and paste the Runner folder you have backed up before to the new ios folder:
Run the project in android studio or VS code
Navigate to your ios folder and run:
pod install
ios > Runner.xcworkspace right click and Flutter > Open iOS module in xCode
It will work :)
Copy info.plist, Assets.xcassets and other important files.
Create a New project with same name and bundle id.
Add an iOS project in your old project and add 1st step information in that.
Run project. It's working now.