Flutter: fatal error: 'Flutter/Flutter.h' file not found - flutter

Xcode's output: ↳
In file included from /Users/dani/development/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-6.0.3/ios/Classes/FLTURLLauncherPlugin.m:7:
/Users/dani/development/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-6.0.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/dani/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-2.0.5/ios/Classes/FLTSharedPreferencesPlugin.m:5:
/Users/dani/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-2.0.5/ios/Classes/FLTSharedPreferencesPlugin.h:5:9:
fatal error: 'Flutter/Flutter.h' file not found
#import <Flutter/Flutter.h>
^~~~~~~~~~~~~~~~~~~
1 error generated.
Command CompileSwift failed with a nonzero exit code
Command CompileSwift failed with a nonzero exit code
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
flutter doctor:
[✓] Flutter (Channel stable, 2.0.5, on macOS 11.2.3 20D91
darwin-x64, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android
SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] Connected device (3 available)
• No issues found!
I tried all solutions proposed here without luck:
https://github.com/flutter/flutter/issues/16036
All dependencies updated

This is a matter of finding a library on our app that doesn't support null safety. We can do several things after identify it:
Ask on its repo to get support for null safety
Use a different library that supports this
Try to fix it ourselves
stackoverflow.com/a/33509278/4858133

I believe you should try both of this steps:
1- Try to remove pod files and install them again by executing:
$ cd ios/
$ pod deintegrate
$ pod install
2- Clean workplace by executing command on the root of the project:
$ flutter clean
Then try to run the app again.

Related

Flutter Braintree not working in Apple M1

I am having issues while compiling Flutter Braintree in Apple M1.
I even tried creating a new project only with flutter_braintree 2.2.0, still doesn't compile.
Attached is the flutter doctor and logs of the project.
Flutter Doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.8.1, on macOS 12.0.1 21A559 darwin-arm, locale en-AU)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0-rc5)
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.61.2)
[✓] Connected device (2 available)
• No issues found!
Logs
Launching lib/main.dart on iPhone 13 in debug mode...
Running pod install...
Running Xcode build...
Xcode build done. 6.8s
Failed to build iOS app
Error output from Xcode build:
↳
objc[95440]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libamsupport.dylib (0x1da8cf130) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x107bc02c8). One of the two will be used. Which one is undefined.
objc[95440]: Class AMSupportURLSession is implemented in both /usr/lib/libamsupport.dylib (0x1da8cf180) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x107bc0318). One of the two will be used. Which one is undefined.
** BUILD FAILED **
Xcode's output:
↳
/Users/project/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_braintree-2.2.0/ios/Classes/FlutterBraintreeDropInPlugin.swift:163:121: warning: expression implicitly coerced from 'String?' to 'Any'
flutterResult(["paymentMethodNonce": buildPaymentNonceDict(nonce: result?.paymentMethod), "deviceData": deviceData])
^~~~~~~~~~
/Users/project/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_braintree-2.2.0/ios/Classes/FlutterBraintreeDropInPlugin.swift:163:121: note: provide a default value to avoid this warning
flutterResult(["paymentMethodNonce": buildPaymentNonceDict(nonce: result?.paymentMethod), "deviceData": deviceData])
^~~~~~~~~~
?? <#default value#>
/Users/project/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_braintree-2.2.0/ios/Classes/FlutterBraintreeDropInPlugin.swift:163:121: note: force-unwrap the value to avoid this warning
flutterResult(["paymentMethodNonce": buildPaymentNonceDict(nonce: result?.paymentMethod), "deviceData": deviceData])
^~~~~~~~~~
!
/Users/project/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_braintree-2.2.0/ios/Classes/FlutterBraintreeDropInPlugin.swift:163:121: note: explicitly cast to 'Any' with 'as Any' to silence this warning
flutterResult(["paymentMethodNonce": buildPaymentNonceDict(nonce: result?.paymentMethod), "deviceData": deviceData])
^~~~~~~~~~
as Any
Command CompileSwiftSources failed with a nonzero exit code
/Users/project/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_braintree-2.2.0/ios/Classes/BaseFlutterBraintreePlugin.swift:3:8: error: could not find module 'Braintree' for target 'arm64-apple-ios-simulator'; found: x86_64-apple-ios-simulator, x86_64, at: /Users/project/Developer/testing_braintree/build/ios/Debug-iphonesimulator/Braintree/Braintree.framework/Modules/Braintree.swiftmodule
import Braintree
^
/Users/project/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_braintree-2.2.0/ios/Classes/BaseFlutterBraintreePlugin.swift:3:8: error: could not find module 'Braintree' for target 'arm64-apple-ios-simulator'; found: x86_64-apple-ios-simulator, x86_64, at: /Users/project/Developer/testing_braintree/build/ios/Debug-iphonesimulator/Braintree/Braintree.framework/Modules/Braintree.swiftmodule
import Braintree
^
/Users/project/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_braintree-2.2.0/ios/Classes/BaseFlutterBraintreePlugin.swift:3:8: error: could not find module 'Braintree' for target 'arm64-apple-ios-simulator'; found: x86_64-apple-ios-simulator, x86_64, at: /Users/project/Developer/testing_braintree/build/ios/Debug-iphonesimulator/Braintree/Braintree.framework/Modules/Braintree.swiftmodule
import Braintree
^
note: Using new build system
note: Planning
note: Build preparation complete
note: Building targets in dependency order
Could not build the application for the simulator.
Error launching application on iPhone 13.
Add this code on the Podfile,
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
end
And from Xcode pass to build iOS 9.0 to 12.0

can't build IOS

I encounter this error when i try to build for ios, i tried every solution i could find online
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
In file included from
/Users/ahmedaly/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_ios-6.0.13/ios/Classes/FLTURLLauncherPlugin.m:7:
/Users/ahmedaly/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_ios-6.0.13/ios/Classes/FLTURLLauncherPlugin.h:5:9: fatal
error: 'Flutter/Flutter.h' file not found
#import <Flutter/Flutter.h>
^~~~~~~~~~~~~~~~~~~
1 error generated.
note: Using new build system
note: Planning
note: Build preparation complete
note: Building targets in parallel
Encountered error while building for device.
example of the things i tried:
pod deintegrate
rm podfile.lock
rm pubspec.lock
flutter clean
flutter run
and just about anything similar you could immagine
i also tried removing the file from the path indicated and removing the dependency from pubspec.yaml but it didn’t work
flutter doctor output :
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.8.0, on macOS 11.6 20G165 darwin-x64, locale
en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] IntelliJ IDEA Community Edition (version 2021.2.3)
[✓] VS Code (version 1.63.0)
[✓] Connected device (2 available)
• No issues found!
I found a solution in another question on Stack!
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

fatal error: 'Flutter/Flutter.h' file not found running on MabookBook M1

I already tried all of this link and nothing
Xcode build done. 4,3s
Failed to build iOS app
Error output from Xcode build:
↳
objc[22045]: Class AMSupportURLConnectionDelegate is implemented in both ?? (0x1ffbaf8f0) and ?? (0x11b1602b8). One of the two will be used. Which one is undefined.
objc[22045]: Class AMSupportURLSession is implemented in both ?? (0x1ffbaf940) and ?? (0x11b160308). One of the two will be used. Which one is undefined.
** BUILD FAILED **
Xcode's output:
↳
In file included from /Users/netolobo/development/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.28/ios/Classes/FLTPathProviderPlugin.m:5:
/Users/netolobo/development/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.28/ios/Classes/FLTPathProviderPlugin.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.
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 2.1.0-13.0.pre.499, on macOS 11.1 20C69 darwin-arm, locale pt-BR)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0-rc2)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] Connected device (2 available)
• No issues found!
I finally found the final solution!
Backup ios/Runner folder.
Delete the ios folder.
Run flutter create . 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!

Flutter build failed with fatal error: 'Flutter/Flutter.h' file not found

I am developing the app with flutter,
I am getting fatal error: 'Flutter/Flutter.h' file not found , this error when I build my app.
I tried reinstall cocoapod and delete podfile.lock and reinstalled it,
but I am still getting this error..
what can I do for this error ?
daegilpyo#DAEGILs-MacBook-Pro eminail % flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.22.4, on macOS 11.0.1 20B50 darwin-x64, locale en-CA)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 12.2)
[✓] Android Studio (version 3.6)
[✓] Connected device (1 available)
• No issues found!
daegilpyo#DAEGILs-MacBook-Pro eminail %
vent sent after app closed: {id: 0, progressId: null, finished: true}
Launching lib/main.dart on DAEGIL의 iPhone in debug mode...
lib/main.dart:1
Automatically signing iOS for device deployment using specified development team in Xcode project: T6ULPGT4J7
Xcode build done. 18.9s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
Command CompileSwift failed with a nonzero exit code
In file included from /Users/daegilpyo/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.7.10/ios/Classes/FLTURLLauncherPlugin.m:7:
/Users/daegilpyo/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.7.10/ios/Classes/FLTURLLauncherPlugin.h:5:9: fatal error: 'Flutter/Flutter.h' file not found
#import <Flutter/Flutter.h>
^~~~~~~~~~~~~~~~~~~
1 error generated.
Command CompileSwift failed with a nonzero exit code
Command CompileSwift failed with a nonzero exit code
Command CompileSwift failed with a nonzero exit code
Command CompileSwift failed with a nonzero exit code
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
go to terminal, backup your ios/Runner folder and delete your ios folder. Then go to terminal and execute
cd path/to/your/project/projectName
flutter create .
flutter run
if flutter run fails
cd ios
pod install
cd ..
flutter run

Flutter Android build failed for task ':auto_orientation:verifyReleaseResources'

When I run the command flutter build apk --release then i face the following issue with auto_orientation.
In my pubspec.yaml file I have the latest version included auto_orientation: ^1.0.5.
Btw. when I run the project with flutter run everything works fine.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':auto_orientation:verifyReleaseResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
/Users/johannes/flutter_projects/udare/app/build/auto_orientation/intermediates/res/merged/release/values/values.xml:236: error: resource android:attr/fontVariationSettings not found.
/Users/johannes/flutter_projects/udare/app/build/auto_orientation/intermediates/res/merged/release/values/values.xml:237: error: resource android:attr/ttcIndex not found.
error: failed linking references.
Flutter doctor:
[✓] Flutter (Channel master, v1.12.15-pre.29, on Mac OS X 10.14.6 18G95, locale
en-DE)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 11.2.1)
[✓] Android Studio (version 3.4)
[✓] VS Code (version 1.40.2)
[✓] Connected device (1 available)
• No issues found!
#GreenTigerEye, this could be due to AndroidX incompatibility. You could try directly using the source code of auto_orientation package or try few options mentioned here for a similar issue.