简体   繁体   English

尝试将胖二进制文件与64位模拟器目标链接时出错

[英]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). 我有一个用于5种体系结构(x86_64,i386,armv7,armv7s,arm64)的iOS和OS X静态库lipo'd。

  • The x86_64 architecture was built using the macosx SDK x86_64体系结构是使用macosx SDK构建的
  • The i386 architecture was built using the iphonesimulator SDK i386体系结构是使用iphonesimulator SDK构建的
  • The ARM architectures were built using the iphoneos SDK ARM体系结构是使用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. 当我尝试在示例应用程序中链接生成的库时,在为设备或32位iOS模拟器目标进行构建时,它将起作用。 But when I try to build it for a 64-bit iOS simulator target I get a linker error: 但是,当我尝试为64位iOS模拟器目标构建它时,出现链接器错误:

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. 如果从胖库中删除x86_64切片,则它适用于所有设备和模拟器。

I assume it's because the linker prefers the x86_64 architecture if it's there for the 64-bit simulator. 我认为这是因为链接器更喜欢x86_64体系结构(如果它用于64位模拟器)。 But since it was compiled and linked for the macosx SDK it has the OS X dependencies somehow encoded. 但是,由于它是为macosx SDK编译和链接的,因此它以某种方式对OS X依赖项进行了编码。

I tried adding a second x68_64 slice for the iphonesimulator SDK but lipo won't let me. 我尝试为iphonesimulator SDK添加第二个x68_64切片,但是lipo不允许我这样做。 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. 我也试图找到一种方法,使模拟器即使在64位版本中也可以使用i386架构,但到目前为止还算不上什么。

If absolutely necessary I can create 2 binaries which would solve this but I would really prefer having them in one file. 如果绝对必要,我可以创建2个二进制文件来解决此问题,但我真的希望将它们放在一个文件中。 Is there a way to achieve this? 有没有办法做到这一点?

I solved it by only building it for the iOS device and simulator. 我仅通过为iOS设备和模拟器构建它来解决了它。 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). iOS Simulator SDK的64位片段同样适用于iOS和OS X目标,前提是您不需要OS X和iOS之间共享的框架(仅在我的情况下为基础)。

Project and Pods: 专案和广告连播:

Build Settings ---> Link Frameworks Automatically change YES to NO, and rebuild static library ,it is work! 构建设置--->链接框架自动将YES更改为NO,并重建静态库,就可以了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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