我从 XCode 6 迁移到 XCode 7,并且没有对源代码、项目或我的存档构建开始失败的任何内容进行任何更改。

在研究了 lipo 产生的错误后:

lipo:.../Release-iphoneos/libSDWebImage.a and .../Release-iphonesimulator/libSDWebImage.a have the same architectures (i386) and can't be in the same fat output file

我发现以下内容:

在 XCode 6 中,lipo -info 返回正确的 Architectures in the fat file: .../Release-iphoneos/libSDWebImage.a are: armv7 arm64Architectures in the fat file: .../Release-iphonesimulator/libSDWebImage.a are: i386 x86_64。我有用于 iphone 设备的 arm 和用于 iphone 模拟器的 i386。

在 XCode 7 中,这两个文件是相同的,并且具有 i386 架构!所以使用 lipo 将这两个 .a 文件合二为一的框架脚本失败了。

为什么 XCode 7 突然停止为 arm 构建我的 SDWebImage 框架?项目设置不变,库不变,方案的Archive设置为Release。请帮忙。
iMac:~ lukasz$ lipo -info /Users/lukasz/Library/Developer/Xcode/DerivedData/…-etcsjmgakpylpmgchumhnsqpyrev/Build/Intermediates/ArchiveIntermediates/adhoc-stage/BuildProductsPath/Release-iphoneos/libSDWebImage.a
input file /Users/lukasz/Library/Developer/Xcode/DerivedData/…-etcsjmgakpylpmgchumhnsqpyrev/Build/Intermediates/ArchiveIntermediates/adhoc-stage/BuildProductsPath/Release-iphoneos/libSDWebImage.a is not a fat file
Non-fat file: /Users/lukasz/Library/Developer/Xcode/DerivedData/…-etcsjmgakpylpmgchumhnsqpyrev/Build/Intermediates/ArchiveIntermediates/adhoc-stage/BuildProductsPath/Release-iphoneos/libSDWebImage.a is architecture: i386

iMac:~ lukasz$ lipo -info /Users/lukasz/Library/Developer/Xcode/DerivedData/…-etcsjmgakpylpmgchumhnsqpyrev/Build/Intermediates/ArchiveIntermediates/adhoc-stage/BuildProductsPath/Release-iphonesimulator/libSDWebImage.a
input file /Users/lukasz/Library/Developer/Xcode/DerivedData/…-etcsjmgakpylpmgchumhnsqpyrev/Build/Intermediates/ArchiveIntermediates/adhoc-stage/BuildProductsPath/Release-iphonesimulator/libSDWebImage.a is not a fat file
Non-fat file: /Users/lukasz/Library/Developer/Xcode/DerivedData/…-etcsjmgakpylpmgchumhnsqpyrev/Build/Intermediates/ArchiveIntermediates/adhoc-stage/BuildProductsPath/Release-iphonesimulator/libSDWebImage.a is architecture: i386

最佳答案

我在尝试在 Xcode 7 上构建多架构框架时遇到了同样的问题。看起来你正在构建一个静态库,它是不同的,但可能是相关的。我假设您正在使用 xcodebuild 命令(在聚合目标运行脚本中?)为不同的 SDK 构建您的库,然后在最后执行 lipo 以加入所有这些。

我的问题是正在构建的框架/库位于 build/UninstalledProducts 文件夹中,而 BUILD_DIR 中的内容是指向该文件夹的符号链接(symbolic link)。因此,您的 Release-iphoneosRelease-iphonesimulator 中的库很可能是同一库的别名,因此您会看到它们具有相同的架构(在您的情况下为 i386)。

为避免这种情况,请导航到 Xcode 中静态库目标的“build设置”,并确保“部署”下的以下内容:

  • Deployment Location 是用于发布的 NO
  • Deployment Postprocessing 是用于发布的 NO

  • 您应该看到构建不再输出 UninstalledProducts 文件夹,并且在 BUILD_DIR 中构建的所有库/框架都是唯一文件,它们现在应该具有正确的架构。然后你可以使用 lipo 对它们做任何你喜欢的事情。在尝试上述操作之前,您可能必须删除 DerivedData

    关于ios - Xcode 7 为 Release-iphoneos 构建 i386 而不是 arm 二进制文件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32841578/

    10-11 22:38
    查看更多