Xcode 12, building for iOS Simulator, but linking in object file built for iOS, for architecture arm64

btxios picture btxios · Aug 27, 2020 · Viewed 66.3k times · Source

Trying to get a large (and working on Xcode 11!) project building in Xcode 12 (beta 5) to prep for iOS 14. Codebase was previously Obj-C, but now contains both Obj-C and Swift, and uses pods that are Obj-C and/or Swift as well.

I have pulled the new beta of cocoapods with Xcode 12 support (currently 1.10.0.beta 2).

Pod install is successful. When I do a build, I get the following error on a pod framework:

"building for iOS Simulator, but linking in object file built for iOS, for architecture arm64"

When I go run lipo -info on the framework, it has: armv7s armv7 i386 x86_64 arm64.

Previously, the project had Valid Architectures set to: armv7, armv7s and arm64.

In Xcode 12, that setting goes away, as per Apple's documentation. Architectures is set to $(ARCHS_STANDARD). I have nothing set in excluded architectures.

Anyone have an idea of what may be going on here? I have not been able to reproduce this with a simpler project yet.

Answer

Amit Samant picture Amit Samant · Sep 18, 2020

Basically you have to exclude arm64 for simulator architecture both from your project and the Pod project,

  • To do that, navigate to Build Settings of your project and add Any iOS Simulator SDK with value arm64 inside Excluded Architecture.

    enter image description here

OR

  • If you are using custom XCConfig files, you can simply add this line for excluding simulator architecture.
EXCLUDED_ARCHS[sdk=iphonesimulator*] = arm64

Then

You have to do the same for the Pod project until all the cocoa pod vendors are done adding following in their Podspec.

s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }
s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }

You can manually add the Excluded Architechure in your Pod project's Build Settings, but it will be overwritten when you use pod install.

In place of this, you can add this snippet in your Podfile. It will write the neccessary Build Settings every time you run pod install

post_install do |installer|
  installer.pods_project.build_configurations.each do |config|
    config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
  end
end