简体   繁体   中英

Error when trying to link fat binary with 64-bit simulator target

I have a static library lipo'd for iOS and OS X with 5 architectures (x86_64, i386, armv7, armv7s, arm64).

  • The x86_64 architecture was built using the macosx SDK
  • The i386 architecture was built using the iphonesimulator SDK
  • The ARM architectures were built using the iphoneos SDK

When I try to link the resulting library in an example App it works when building for a device or for a 32-bit iOS simulator target. But when I try to build it for a 64-bit iOS simulator target I get a linker error:

ld: framework not found CoreServices for architecture x86_64

If I remove the x86_64 slice from the fat library it works for all devices and simulators.

I assume it's because the linker prefers the x86_64 architecture if it's there for the 64-bit simulator. But since it was compiled and linked for the macosx SDK it has the OS X dependencies somehow encoded.

I tried adding a second x68_64 slice for the iphonesimulator SDK but lipo won't let me. Also I tried to find a way to make the simulator use the i386 architecture even for 64-bit builds, but so far no luck.

If absolutely necessary I can create 2 binaries which would solve this but I would really prefer having them in one file. Is there a way to achieve this?

I solved it by only building it for the iOS device and simulator. The 64bit slice of the iOS Simulator SDK equally works for iOS and OS X targets, provided you don't need any other frameworks than what's shared between OS X and iOS (Foundation only in my case).

Project and Pods:

Build Settings ---> Link Frameworks Automatically change YES to NO, and rebuild static library ,it is work!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM