xcode 针对架构 i386 的 MacOSX 文件“/usr/lib/libSystem.B.dylib”构建的 dylib 链接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19105131/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
linking against dylib built for MacOSX file '/usr/lib/libSystem.B.dylib' for architecture i386
提问by Farhan Ahmad
I recently switched my development MacBook from a classic MacBook (32 bit) to a MacBook Air (64 bit). I am trying to open a project that was made on my old MacBook (32 bit) running XCode 4.
我最近将我的开发 MacBook 从经典 MacBook(32 位)切换到 MacBook Air(64 位)。我正在尝试打开一个在运行 XCode 4 的旧 MacBook(32 位)上制作的项目。
The project is a PhoneGap application made in PhoneGap 1.7.0.
该项目是在PhoneGap 1.7.0 中制作的PhoneGap 应用程序。
My new MacBook Air (64 bit) is running XCode 5.
我的新 MacBook Air(64 位)运行的是 XCode 5。
I imported my developer profiles from my old MacBook to my new MacBook Air. But when I try to run it, I get the following error message.
我将我的开发人员配置文件从我的旧 MacBook 导入到我的新 MacBook Air。但是当我尝试运行它时,我收到以下错误消息。
I have tried changing the my architecture in the build settings to armv7 but still no luck :(
我尝试将构建设置中的架构更改为 armv7,但仍然没有运气:(
Does anyone know why I'm getting this error and how to fix it?
有谁知道我为什么会收到这个错误以及如何解决它?
Thanks
谢谢
回答by Farhan Ahmad
OK so as it turns out, XCode 5 changes the default architecture to armv7 when my application does not support armv7. I am running Cordova 1.7.0 and that version does not have support for armv7 architecture.
好吧,事实证明,当我的应用程序不支持 armv7 时,XCode 5 将默认架构更改为 armv7。我正在运行 Cordova 1.7.0,该版本不支持 armv7 架构。
Fix architecture issue:
修复架构问题:
- Removed ALLarchitectures from
Build Settings
-->Valid Architecture
- Added
armv6
toBuild Settings
-->Valid Architecture
- 从--> 中
删除了所有架构
Build Settings
Valid Architecture
- 添加
armv6
到Build Settings
-->Valid Architecture
Fix libSystem.B.dylib
issue:
修复libSystem.B.dylib
问题:
Removed
/usr/lib/libSystem.B.dylib
fromBuild Settings
-->Linking
-->Other Linker Flags
Also removed
-weak_library
fromBuild Settings
-->Linking
-->Other Linker Flags
/usr/lib/libSystem.B.dylib
从Build Settings
-->中移除Linking
-->Other Linker Flags
也
-weak_library
从Build Settings
-->Linking
--> 中删除Other Linker Flags
回答by such
Xcode 5 asks you to build your libraries for the simulator (1) and for iOS (2). You can then merge (3) these into a fat binary which you then link to your main project. I use the same flags as Xcode is using to build your main project (as seen in your screendump).
Xcode 5 要求您为模拟器 (1) 和 iOS (2) 构建库。然后,您可以将 (3) 这些合并到一个胖二进制文件中,然后将其链接到您的主项目。我使用与 Xcode 相同的标志来构建您的主项目(如您的屏幕转储所示)。
Expressed in common gnu toolchain variables I do:
用通用的 gnu 工具链变量表示,我这样做:
1. Building a library for the simulator
1. 为模拟器构建一个库
CC=clang
IPHONEOS_DEPLOYMENT_TARGET=7.0
PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:$PATH"
CFLAGS="-arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk -mios-simulator-version-min=7.0"
2. Building a library for iOS
2.为iOS构建一个库
CC=clang
IPHONEOS_DEPLOYMENT_TARGET=7.0
PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:$PATH"
CFLAGS="-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -miphoneos-version-min=7.0"
3. Merging to a fat binary
3. 合并为胖二进制
Choose either of .a
or .dylib
depending on what you use:
选择.a
或.dylib
取决于您使用的内容:
lipo -create "your armv7 lib".a "your simulator lib".a -output "your lib".a
lipo -create "your armv7 lib".dylib "your simulator lib".dylib -output "your lib".dylib