Xcode Building For iOS Simulator, But Linking in an Object File Built For Ios, For Architecture 'Arm64'

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

Basically, you have to exclude arm64 for the 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.

    Sample Image

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 Architecture 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 necessary 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

building for iOS Simulator, but linking in object file built for iOS

This will do for now

  1. Find Xcode in your Applications folder.
  2. Select the app, and then press Command-I (or right-click/use the File menu and select Get Info.). This will open an Info window with details about the app.
  3. In the Info window, look for a checkbox labeled, “Open using Rosetta”. Check the box. here:
  4. Close the Info window.
  5. If you’re already running the app, quit and relaunch.

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

Basically, you have to exclude arm64 for the 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.

    Sample Image

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 Architecture 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 necessary 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

Xcode error 'building for iOS Simulator, but linking in dylib built for iOS .. for architecture arm64' from Apple Silicon M1 Mac

Answering my own question in a hope to help others who are having similar problems. (and until a good answer is added from another user)

I found out that GoogleWebRTC actually requires its source to be compiled with x64 based on its source depo.

For builds targeting iOS devices, this should be set to either "arm" or "arm64", depending on the architecture of the device. For builds to run in the simulator, this should be set to "x64".

https://webrtc.github.io/webrtc-org/native-code/ios/

This must be why I was getting the following error.

building for iOS Simulator, but linking in dylib built for iOS, file '/Users/andy/workspace/app/Pods/GoogleWebRTC/Frameworks/frameworks/WebRTC.framework/WebRTC' for architecture arm64

Please correct me if I am wrong, but by default, it seems that Xcode running in Apple M1 silicon seems to launch iOS simulator with arm arch type. Since my app did run fine on simulators in Intel Mac, I did the following as a workaround for now.

  1. Quit Xcode.
  2. Go to Finder and open Application Folder.
  3. Right click on Xcode application, select Get Info
  4. In the "Xcode Info Window" check on Open using Rosetta.
  5. Open Xcode and try running again.

That was all I needed to do to make my app, which relies on a library that is not yet fully supported on arm simulator, work again. (I believe launching Xcode in Rosetta mode runs simulator in x86 as well..?? which explains why things are working after making the above change)

A lot of online sources (often posted before M1 Mac launch on Nov/2020) talks about "add arm64 to Excluded Architectures", but that solution seems to be only applicable to Intel Mac, and not M1 Mac, as I did not need to make that change to make things work again.

Of course, running Xcode in Rosetta mode is not a permanent solution, and Xcode slows down lil bit, but it is an interim solution that gets things going in case one of libraries that you are using is not runnable in arm64 simulator.. yet.

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

What I did was

setting the BuildActiveArchitectureOnly to Yes in the build settings.

And

installer.pods_project.targets.each do |target|

target.build_configurations.each do |config|
config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
end
end

And

Updated my Realm to the latest version.



Related Topics



Leave a reply



Submit