Xcode 7和ENABLE_BITCODE=YES设置无效

96

我一直在关注关于Xcode中新的ENABLE_BITCODE设置的几个线程,也尽我所能地尝试了一些方法(承认我不是xcode专家),但仍然无法使项目编译以在我的测试手机上使用。

我的应用在模拟器上运行良好,但我不能将其部署到我的iPhone进行测试。我只安装了iOS 9 beta的后者。

现在,这里是我收到的错误信息。看起来该设置不会影响我的项目中的PARSE.com库?我该如何使我的项目能够部署到我的手机上?感谢任何建议。

    Ld /Users/xxxxxx/Library/Developer/Xcode/DerivedData/graffiti-  bnmizxueojwiqcbbnsvilljhosrw/Build/Products/Debug-iphoneos/Pods/Parse.framework/Parse normal armv7
cd /Users/xxxxxx/Documents/DigitalTempusDev/graffiti/Pods
export IPHONEOS_DEPLOYMENT_TARGET=8.0
export PATH="/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode-beta.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch armv7 -dynamiclib -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk -L/Users/xxxxxx/Library/Developer/Xcode/DerivedData/graffiti-bnmizxueojwiqcbbnsvilljhosrw/Build/Products/Debug-iphoneos/Pods -L/Users/xxxxxx/Documents/DigitalTempusDev/graffiti/Pods/Parse -F/Users/xxxxxx/Library/Developer/Xcode/DerivedData/graffiti-bnmizxueojwiqcbbnsvilljhosrw/Build/Products/Debug-iphoneos/Pods -filelist /Users/xxxxxx/Library/Developer/Xcode/DerivedData/graffiti-bnmizxueojwiqcbbnsvilljhosrw/Build/Intermediates/Pods.build/Debug-iphoneos/Pods-Parse.build/Objects-normal/armv7/Parse.LinkFileList -install_name @rpath/Parse.framework/Parse -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -miphoneos-version-min=8.0 -dead_strip -fembed-bitcode-marker -ObjC -lParseLib -lz -framework AudioToolbox -framework CFNetwork -framework CoreGraphics -framework CoreLocation -framework QuartzCore -framework Security -framework StoreKit -framework SystemConfiguration -weak_framework Accounts -weak_framework Social -ObjC -fobjc-arc -fobjc-link-runtime -framework AudioToolbox -framework Bolts -framework CFNetwork -framework CoreGraphics -framework CoreLocation -framework Foundation -framework QuartzCore -framework Security -framework StoreKit -framework SystemConfiguration -single_module -compatibility_version 1 -current_version 1 -Xlinker -dependency_info -Xlinker /Users/xxxxxx/Library/Developer/Xcode/DerivedData/graffiti-bnmizxueojwiqcbbnsvilljhosrw/Build/Intermediates/Pods.build/Debug-iphoneos/Pods-Parse.build/Objects-normal/armv7/Parse_dependency_info.dat -o /Users/xxxxxx/Library/Developer/Xcode/DerivedData/graffiti-bnmizxueojwiqcbbnsvilljhosrw/Build/Products/Debug-iphoneos/Pods/Parse.framework/Parse

---
ld: warning: -weak_framework is treated as -framework when used with -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES). Weak linking may still happen based on availability mark-up in headers
ld: warning: -weak_framework is treated as -framework when used with -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES). Weak linking may still happen based on availability mark-up in headers
ld: '/Users/xxxxxx/Documents/DigitalTempusDev/graffiti/Pods/Parse/libParseLib.a(PFSQLiteDatabase.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

1
你确定在使用的构建配置(例如DEBUG)中已将“启用位码”设置为“NO”吗?您可以在项目->目标->构建设置中检查它->搜索“启用位码”->在DEBUG中设置为“NO”(记得尝试在测试发布之前更新库,也许它已经包含了位码)。然后,编辑方案->运行->检查您当前是否有DEBUG配置。 - Nat
1
好的!是和不是。我没有在POD目标上设置它,那是我的疏忽。你的提示让我找到了答案。谢谢。 - DirkLX
很高兴听到这个消息 :) 我将把它发布为答案,因为它可能对其他人有用。 - Nat
为什么我们需要更改位码?以前我们不需要更新它的值。有任何逻辑原因吗?谢谢。 - msmq
所有的操作都已经完成,但是应用在设备上仍然以相同的错误崩溃。我正在使用iOS 9.1,请帮忙! - Md Rais
10个回答

135
您确定针对您正在使用的构建配置(例如DEBUG),已将Enable Bitcode设置为NO吗? 您可以在项目->目标->构建设置->搜索enable bitcode->在DEBUG中设置NO中进行检查(记得尝试在测试发布之前更新库,也许它已经包含了bitcode)。 然后编辑方案->运行->检查您当前是否具有DEBUG配置。

输入图像描述


1
@Zorayr,由于您在我的帖子中添加了图像:您应该首先检查您的应用程序构建设置,并更改应用程序构建设置中的此标志。只有在这样做无效时,才对Pods执行相同操作。 - Nat
3
如果将“启用位码”设置为“否”,应用程序能否在App Store中被接受? - Ne AS
@NeAS 是的。目前没有启用位码的要求。 - Nat

55
注意对于使用CocoaPods的项目,您应该在项目和Pods容器项目目标上都设置ENABLE_BITCODE = NO

这个错误

Ld /Users/maximveksler/Library/Developer/Xcode/DerivedData/ParseUI-gwtgmlgbpobjfjfjgkiwdahqveos/Build/Products/Debug-iphoneos/ParseTwitterUtils.framework/ParseTwitterUtils normal arm64
    cd /Users/maximveksler/Developer/ParseUI-iOS/Pods
    export IPHONEOS_DEPLOYMENT_TARGET=9.0
    export PATH="/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode-beta.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch arm64 -dynamiclib -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk -L/Users/maximveksler/Library/Developer/Xcode/DerivedData/ParseUI-gwtgmlgbpobjfjfjgkiwdahqveos/Build/Products/Debug-iphoneos -L/Users/maximveksler/Developer/ParseUI-iOS/Pods/ParseTwitterUtils -F/Users/maximveksler/Library/Developer/Xcode/DerivedData/ParseUI-gwtgmlgbpobjfjfjgkiwdahqveos/Build/Products/Debug-iphoneos -filelist /Users/maximveksler/Library/Developer/Xcode/DerivedData/ParseUI-gwtgmlgbpobjfjfjgkiwdahqveos/Build/Intermediates/Pods.build/Debug-iphoneos/ParseTwitterUtils.build/Objects-normal/arm64/ParseTwitterUtils.LinkFileList -install_name @rpath/ParseTwitterUtils.framework/ParseTwitterUtils -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -miphoneos-version-min=9.0 -dead_strip -fembed-bitcode-marker -ObjC -lParseTwitterUtilsLib -lsqlite3 -lz -framework AudioToolbox -framework CFNetwork -framework CoreGraphics -framework CoreLocation -framework QuartzCore -framework Security -framework StoreKit -framework SystemConfiguration -weak_framework Accounts -weak_framework Social -fobjc-arc -fobjc-link-runtime -framework AudioToolbox -framework Bolts -framework CFNetwork -framework CoreGraphics -framework CoreLocation -framework Foundation -framework Parse -framework QuartzCore -framework Security -framework StoreKit -framework SystemConfiguration -single_module -compatibility_version 1 -current_version 1.8.1 -Xlinker -dependency_info -Xlinker /Users/maximveksler/Library/Developer/Xcode/DerivedData/ParseUI-gwtgmlgbpobjfjfjgkiwdahqveos/Build/Intermediates/Pods.build/Debug-iphoneos/ParseTwitterUtils.build/Objects-normal/arm64/ParseTwitterUtils_dependency_info.dat -o /Users/maximveksler/Library/Developer/Xcode/DerivedData/ParseUI-gwtgmlgbpobjfjfjgkiwdahqveos/Build/Products/Debug-iphoneos/ParseTwitterUtils.framework/ParseTwitterUtils

ld: '/Users/maximveksler/Developer/ParseUI-iOS/Pods/ParseTwitterUtils/libParseTwitterUtilsLib.a(PFTwitterAuthenticationProvider.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

问题已被解决:

这里输入图片描述

这里输入图片描述


如果我们提交的选项中启用了Bitcode = NO,苹果会拒绝应用程序吗? - Ganesh G
@G.Ganesh请单独发布问题。在tvOS和watchOS中,答案是肯定的,但在iOS中目前是否定的,未来会变成肯定的。 - Maxim Veksler
@GaneshGuturi 目前是这样,但可能在未来苹果会削减它。更多解释请参见此处:https://dev59.com/C10Z5IYBdhLWcg3wwyre#31207170。 - Nat

17

我之前也在Xcode7中遇到了同样的问题。解决方法如下:

  • 进入项目
  • 选择构建设置
  • 选择全部选项卡
  • 在搜索框中输入启用位码
  • 更新标记No(该选项在您的项目下方(第二列))

16

我曾遇到与GoogleAnalytics cocoa pod库类似的问题,该库在iOS 8上的iPhone 6上无法编译。

我的解决方案是在应用程序项目的目标中关闭"Enable Bitcode"标志,而不是在Pods项目中关闭。


这就是我在我的答案评论中所说的。如果在项目设置中尝试无效,那么才切换到Pod项目。 - Nat
将目标和项目切换到构建设置的位代码 NO 对于归档不起作用。对于 Sim builds 可以正常工作。XCODE 7.0.1 - ort11

11
如果您的Bitcode未显示,请选择All。当Xcode选择Basic时,您的Bitcode选项未显示。

enter image description here

当您选择“全部”时,您可以看到Bitcode。然后将广告配置设置为“否” enter image description here

10

我刚刚为我的项目进行了设置。

我的项目目标 -> 构建设置 -> 启用位码 = 否


1
应用程序会被App Store拒绝吗? - Ne AS

5
正如大家所说,答案是在构建设置中将Enable Bitcode设置为No,但我认为你们中的一些人可能会对如何从命令行执行此操作感兴趣。
我的Xcode项目是由Unity生成的,我不想在Xcode项目设置上进行任何手动干预。也许有更好的方法或工具可以编辑构建设置,就像PlistBuddy可以让您更新plist文件中的值一样。我不知道有哪个工具可以用于构建设置,因此我使用sed

sed:基于正则表达式运行替换。

如何从命令行将Enable Bitcode设置为No

这里,我的项目名称是Unity-iPhone,所以我从我的Xcode项目根目录运行以下命令:
sed -i -e 's/ENABLE_BITCODE = YES;/ENABLE_BITCODE = NO;/g' \ 
Unity-iPhone.xcodeproj/project.pbxproj

-e -- 指定要运行的sed命令
-i -- 在原始文件上进行编辑,对每个文件单独运行脚本

如果您只想预览它的功能,请删除-i ;)

请注意,此命令将使用此命令更改所有构建配置,我的project.pbxproj文件中出现了6次ENABLE_BITCODE = YES;

现在,我的构建步骤可以完全自动化处理,fastlane负责其余部分!


4
如果您找不到“enable_bitcode”标志,请点击搜索栏旁边上方工具栏的“全部”选项卡。 enter image description here

请添加一些代码以更好地解释您的答案。 - Usman Maqbool

1

如果您无法在项目中更改BITCODE设置,请在终端中尝试此命令:

xcodebuild -target "目标" -configuration "配置" ENABLE_BITCODE=NO


1
如果您正在使用Cocoapods,这将解决问题:
post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end
end

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接