ld: building for iOS Simulator, but linking in dylib built for iOS

Hi,
I'm trying to compile the app with Xcode version 12.0 beta 6 on a simulator with iOS 14.0 and then I get this error:
"ld: building for iOS Simulator, but linking in dylib built for iOS, file ‘../Lib/Framework-dynamic/PDFNet.framework/PDFNet’ for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)"
I have attached you the error.
Can you please guide us on how to solve this issue.
Thanks in advance.

Best Regards, Walid
Post not yet marked as solved Up vote post of Walid.ad Down vote post of Walid.ad
58k views
  • I faced this same issue in the following configuration

    Xcode 13.1 + Monterey OS 12.0.1 + Intel chip 

    I had to go tot he Architectures section and replace $(ARCHS_STANDARD) by x86_64.

    I hope this helps.

  • @qamon can I get your help? I have the same setup and can't get it to work. I have been on this for 6 days now and its getting tiring :)

Add a Comment

Replies

Did you have any luck? I'm having the same issue with another 3rd party dependency. It's like the system is trying to link for arm64 even though it's building for the simulator.
Found this solution which seems to work:

https://developer.apple.com/forums/thread/657913


Did anyone find another solution for this? The solution described in https://developer.apple.com/forums/thread/657913 let me compile for simulator, but not for real devices.
For XCode 12, do what this says https://developer.apple.com/forums/thread/657913
I get why it tries to build for arm64 simulator. Because we will have soon Arm64 mac, that is good. But I don't have such mac yet. I do have intel based mac. so this I think is an error that guys on xcode team need to fix. -> clang++ -target arm64-apple-ios14.0-simulator. On intel based mac this can not be correct target.
This works:
Check if in your project for compiled target ->build settings -> user defined section (at the very bottom) you have defined VALID_ARCHS=arm64, if yes, delete it.

What I did is here:
  • I deleted VALIDARCHS from Project

  • I deleted VALID

  • ARCHS from Target
  • Build Active Architecture Only = YES (for Debug)

  • Architectures = Standard Architectures $(ARCHS_STANDARD)

Also, File -> Project/Workspace Settings == New Build System
  • This worked to resolve my issue: "Build Active Architecture Only = YES (for Debug)"

Add a Comment
I tried some approach that worked for me and I have described it here. Still finding its loopholes though.
My problem solved with delete arm64 from target>build settings>Excluded Architectures. Actually i deleted from there before,
but actually worked when i go to my VSCode and go to ios/App/App.xcodeproj/project.pbxproj file and searched EXCLUDED_ARCHS = arm64; and delete from there, and worked, i dont know why my update at xcode did not worked but VSCode worked

xcode 12.0.1, iOS 14 pack updated, and all capacitor stuff updated for 2.0.4 (latest one)
Deleting VALIDARCHS=arm64 is the only thing worked. Other solutions like
  1. Set

Build Active Architecture Only to "Yes" even for release mode.
  • Navigate to Build Settings of your project and add "Any iOS Simulator SDK" with value "arm64" inside

Excluded Architecture_.are useless and lead me to another error like this:

Code Block
The file “Myapp.app” couldn’t be opened because you don’t have permission to view it.


So don't waste your time. Because when you create a new app in Xcode 12 you will not find "VALID ARCHS" key in User defined section which is deprecated.

The Build Settings editor no longer includes the Valid Architectures build setting "VALID ARCHS", and its use is discouraged. Instead, there is a new Excluded Architectures build setting (EXCLUDED ARCHS). If a project includes VALIDARCHS, the setting is
displayed in the User-Defined section of the Build Settings editor._

For me it worked run in physical iPhone
An alternative is running on physical device. Guess that's no what most people can, I wonder if it something on behalf of the library, that it must be compiled with latest Xcode version, which... it shouldn't by now
I faced similar issue on M1 Mac where I was able to run project on real device but it was not working on simulator for certain libraries. Adding 'any iOS Simulator' as key and 'arm64' in target>BuildSettings>ExcludedArchitecture resolved the issue

I also faced this issue on a M1 Mac. It turns out that running Xcode with Rosetta fixed the issue. To open Xcode with Rosetta, quit Xcode then go to Applications folder > right-click on Xcode > Get Info > Check Open with Rosetta. Relaunch Xcode.

  • tompidom, exactly sloution! thank you

  • It was the only solution that worked for me after 2 hours of hustle.

Add a Comment

Firstly I had to go tot he Architectures section and replace $(ARCHS_STANDARD) by x86_64. Then reinstall pods .  I hope this helps