通用 IOS i386 静态库 x86_64 armv7 armv7s arm64

universal IOS static library with i386 x86_64 armv7 armv7s arm64

我需要创建一个 Cocoa Touch 静态库项目的通用库,

我正在使用

xcodebuild -target mysdsk ONLY_ACTIVE_ARCH=NO VALID_ARCHS="arm64 armv7 armv7s i386 x86_64" -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}"

即使我将 iphonesimulator 拆分为两个 xcodebuild,我仍然无法为 iphone4 模拟器

获取 i386

我遇到错误

Undefined symbols for architecture i386

基于How do I determine the target architecture of static library (.a) on Mac OS X?

我尝试运行文件命令,它显示

mysdsk.a: Mach-O universal binary with 5 architectures
mysdsk.a (for architecture i386): current ar archive random library
mysdsk.a (for architecture armv7): current ar archive random library
mysdsk.a (for architecture armv7s): current ar archive random library
mysdsk.a (for architecture x86_64): current ar archive random library
mysdsk.a (for architecture arm64): current ar archive random library

但我仍然遇到错误

Undefined symbols for architecture i386

不管你用什么方法,从架构列表上我觉得都可以。

XCode 有一个问题,即使您拖放 mysdsk.a 或更改链接器设置,XCode 仍然可以选择存储在

中的错误文件
/Users/<your username>/Library/Developer/Xcode/DerivedData/mysdsk_........ folder

您可以从 XCode 警告中识别出 3 个切片,但实际上是 5 个切片

ld: warning: ignoring file /Users//Library/Developer/Xcode/DerivedData/mysdsk_......./..../mysdsk.a, missing required architecture i386 in file /Users//Library/Developer/Xcode/DerivedData/mysdsk_......./..../mysdsk.a (3 slices)

因此删除文件夹/Users//Library/Developer/Xcode/DerivedData/mysdsk_.......

那应该没问题,其实我发现了这个问题,其他机器工作正常,但我的机器不工作。

引用ignoring file [path] missing required architecture i386 in file