Fixing `ld: file not found: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphoneos.a`
Today my Flutter app failed to build in iOS with this error:
ld: file not found: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphoneos.a
Googling will send you to StackOverflow posts with 1001 ways to supposedly fix it with obscure scripts and no explanation. But from what I gather, the error is due to the new version of XCode requiring that everything is built with deployment target iOS 11.0.
So I went to my Podfile and uncommented the first line:
# Uncomment this line to define a global platform for your project
platform :ios, '11.0'
Then built again. Since it still did not work, I tried to run flutter clean
, then tried again. Still didn't work. Btw, I also get these errors:
[project path]/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 10.0, but the range of supported deployment target versions is 11.0 to 16.4.99. (in target 'FirebaseInstallations' from project 'Pods')
[project path]/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 9.0, but the range of supported deployment target versions is 11.0 to 16.4.99. (in target 'nanopb' from project 'Pods')
[project path]/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 9.0, but the range of supported deployment target versions is 11.0 to 16.4.99. (in target 'Libuv-gRPC' from project 'Pods')
Why would it not apply the change I did to the Podfile? I went into the ios folder and tried pod install
:
% pod install
Analyzing dependencies
cloud_firestore: Using Firebase SDK version '10.3.0' defined in 'firebase_core'
firebase_analytics: Using Firebase SDK version '10.3.0' defined in 'firebase_core'
firebase_auth: Using Firebase SDK version '10.3.0' defined in 'firebase_core'
firebase_core: Using Firebase SDK version '10.3.0' defined in 'firebase_core'
firebase_dynamic_links: Using Firebase SDK version '10.3.0' defined in 'firebase_core'
Downloading dependencies
Generating Pods project
Integrating client project
Pod installation complete! There are 12 dependencies from the Podfile and 34 total pods installed.
[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target `Runner` to `Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig` or include the `Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig` in your build configuration (`Flutter/Release.xcconfig`).
What does that last message mean and is it an issue? This ticket explains how to fix it. They're saying you should match the config to the Name.
In my case Profile is not set to the correct configuration, according to the ticket. I have no idea how the Profile target got the Release configuration. I do not remember changing that.
I tried running pod install
again and indeed the warning message has disappeared. I am still not sure it was relevant.
% pod install
Analyzing dependencies
cloud_firestore: Using Firebase SDK version '10.3.0' defined in 'firebase_core'
firebase_analytics: Using Firebase SDK version '10.3.0' defined in 'firebase_core'
firebase_auth: Using Firebase SDK version '10.3.0' defined in 'firebase_core'
firebase_core: Using Firebase SDK version '10.3.0' defined in 'firebase_core'
firebase_dynamic_links: Using Firebase SDK version '10.3.0' defined in 'firebase_core'
Downloading dependencies
Generating Pods project
Integrating client project
Pod installation complete! There are 12 dependencies from the Podfile and 34 total pods installed.
Yep, it was not. The build failed again.
[project path]aoe4_coach/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 9.0, but the range of supported deployment target versions is 11.0 to 16.4.99. (in target 'PromisesObjC' from project 'Pods')
[project path]aoe4_coach/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 9.0, but the range of supported deployment target versions is 11.0 to 16.4.99. (in target 'GTMSessionFetcher' from project 'Pods')
[project path]aoe4_coach/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 9.0, but the range of supported deployment target versions is 11.0 to 16.4.99. (in target 'BoringSSL-GRPC' from project 'Pods')
But notice how the 3 affected projects are different from earlier. Earlier it was complaining about FirebaseInstallations, nanopb and Libuv-gRPC not being targeted to iOS 11.0. Now it's PromisesObjC, GTMSessionFetcher and BoringSSL-GRPC.
Btw, after looking at my Podfile again, I see why the Profile target was using the Release config. Look at this:
# Uncomment this line to define a global platform for your project
platform :ios, '11.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
So it really was intentionally written by the Flutter team.
Finally in the thread I refered to earlier, it appears that uncommenting the line to define a global platform is not enough. You need to manually change the Pods dependencies, or write a script that will do it for you in your Podfile.
So I guess I do have to resort to scripting. I hate that I have to copy paste some code and the fix or setting is not made easily available by default.
So I changed the bottom of my Podfile from:
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
To:
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
installer.generated_projects.each do |project|
project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
end
end
end
end
And this did fix it.