M1 Mac Xcode Build Done then Failed Flutter Project (apple silicon)
2,904
Add below code in the project pod file and run command pod install
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
flutter_additional_ios_build_settings(target)
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
config.build_settings["ONLY_ACTIVE_ARCH"] = "YES"
end
end
end
Author by
Muhtar
Updated on December 30, 2022Comments
-
Muhtar over 1 year
I have been stuck on a problem that always occurs whenever I run any project from my M1 Mac. I have tried all the solutions from stack overflow and github. I am about to lose my. 4th project because of the hassle. First I thought it is because of flutter macOS desktop support. Disabled it, nothing changed. When I add some dependencies to my app and use it as a widget or function the project fails. It ruins my 4th day. I am sharing all the details and kindly waiting for your help.
Reproduced:
- Disabled macOS flutter desktop support
- delete podfile.lock and restart
- In Xcode Runner/Runner disabled for builds only
- Install cocoapods and ffi as it is (first answer) cocoapods_ffi
- Changed deployment target to 9 and 10
flutter doctor -v;
alperenbaskaya@Alperen-MacBook-Air ios % flutter doctor -v [✓] Flutter (Channel stable, 2.0.1, on macOS 11.2.1 20D74 darwin-arm, locale tr-TR) • Flutter version 2.0.1 at /Users/alperenbaskaya/Desktop/flutter • Framework revision c5a4b4029c (3 months ago), 2021-03-04 09:47:48 -0800 • Engine revision 40441def69 • Dart version 2.12.0 [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at /Users/alperenbaskaya/Library/Android/sdk • Platform android-30, build-tools 30.0.3 • 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 at /Applications/Xcode.app/Contents/Developer • Xcode 12.5, Build version 12E262 • CocoaPods version 1.10.1 [✓] 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 (1 available) • iPhone 11 Pro (mobile) • 8E932E0F-46C9-42FC-AA28-06DBA7A513D6 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator) • No issues found!
Error Log;
Failed to build iOS app Error output from Xcode build: ↳ objc[89556]: Class AMSupportURLConnectionDelegate is implemented in both ?? (0x1eb708188) and ?? (0x115c482b8). One of the two will be used. Which one is undefined. objc[89556]: Class AMSupportURLSession is implemented in both ?? (0x1eb7081d8) and ?? (0x115c48308). One of the two will be used. Which one is undefined. ** BUILD FAILED ** Xcode's output: ↳ abseil-dfbvnbqkknxxbhdudyeskahnmgpi building file list ... rsync: link_stat "/Users/alperenbaskaya/AndroidStudioProjects/app_app/build/ios/Debug-iphonesimulator/App.framework" failed: No such file or directory (2) done sent 29 bytes received 20 bytes 98.00 bytes/sec total size is 0 speedup is 0.00 rsync error: some files could not be transferred (code 23) at /AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-55/rsync/main.c(996) [sender=2.6.9] Command PhaseScriptExecution failed with a nonzero exit code abseil-dfbvnbqkknxxbhdudyeskahnmgpi note: Using new build system note: Building targets in parallel note: Planning build note: Analyzing workspace note: Constructing build description note: Build preparation complete note: Removed stale file '/Users/alperenbaskaya/Library/Developer/Xcode/DerivedData/Runner-diukrbptujoetdfkyqoxkpqvirsd/Build/Products/Debug-iphonesimulator/sqflite/sqflite.framework'
pod;
# Uncomment this line to define a global platform for your project platform :ios, '10.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'false' 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) end end
Edit:
note: Using new build system note: Building targets in parallel note: Planning build note: Analyzing workspace note: Constructing build description note: Build preparation complete
-
Tommy almost 3 yearsIt looks like the version of Flutter you're linking to is built for 'iOS Simulator-x86_64' and, of course, you're attempting to link that into an arm64 build. I have to admit to being ignorant as to whether Xcode can build iOS projects for the x86 simulator and launch them under Rosetta but it certainly can for macOS projects. Search your project settings for 'architectures' maybe?
-
Muhtar almost 3 yearsI updated. Build arch doesnt contains x86_64 at all. I could not find what to do ? Do you have any idea because I am really stuck for decades
-
Tommy almost 3 yearsIf you can set the simulator build architecture to x86_64 then that might resolve the problem; apologies – I'm typing this from my work computer so can't check Xcode myself.
-
Muhtar almost 3 yearsWhere can I set it ?
-
Tommy almost 3 yearsI'll see whether I can figure that out when I'm back at my personal machine. In the meantime, maybe try opening Xcode under Rosetta so that the whole suite is running as if on x86? beebom.com/force-apps-to-run-with-rosetta-m1-mac describes how.
-
Muhtar almost 3 yearsDidnt help unfortunately
-
L.Keysoft almost 3 yearsFacing the same issue, did you find a solution?
-
Muhtar almost 3 yearsNo solution for it unfortunatelly
-
SULPHURIC ACID almost 2 yearsi have tried with add this above code I'm still facing same issuse.