为临时分发导出存档时无法验证位码​​ - 尝试了 Xcode 8.3.3 和 Xcode 9

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46404236/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 10:18:06  来源:igfitidea点击:

Failed to verify bitcode while exporting archive for ad hoc distribution - tried Xcode 8.3.3 & Xcode 9

iosxcodeapp-store-connectbitcode

提问by Vipin

Apps containing our framework complains about missing bitcode while exporting archive for Ad-hoc distribution.

包含我们框架的应用程序在为临时分发导出存档时会抱怨缺少位码。

I have gone through the documentation provided by Apple in this regard Technical Note TN2432. The documentations' listed possible root causes do not resemble our scenario. (We are not using assembly instructions or have malformed info.plist file)

我已经阅读了 Apple 在这方面提供的文档 Technical Note TN2432。文档中列出的可能的根本原因与我们的场景不同。(我们没有使用汇编指令或有格式错误的 info.plist 文件)

I have gone through following similar questions posted on SO

我已经完成了在 SO 上发布的类似问题

Error while exporting with Bitcode enabled (symbol not found for architecture armv7)

在启用 Bitcode 的情况下导出时出错(未找到架构 armv7 的符号)

Is it possible to create a universal iOS framework using bitcode?

是否可以使用 bitcode 创建一个通用的 iOS 框架?

New warnings in iOS 9

iOS 9 中的新警告

But the provided solutions do not seem to work.

但是提供的解决方案似乎不起作用。

I have tried adding BITCODE_GENERATION_MODEflag in User-Defined build settings. I also tried adding -fembed-bitcode-marker & -fembed-bitcodein Other C flags in framework target.

我尝试BITCODE_GENERATION_MODE在用户定义的构建设置中添加标志。我还尝试在框架目标的其他 C 标志中添加-fembed-bitcode-marker & -fembed-bitcode

I check if bitcode segments are present in my generated framework using the suggestedcommand

我使用建议的命令检查我生成的框架中是否存在位码段

otool -l -arch arm64 <framework_name> | grep __LLVM

It shows 2 segments

它显示了 2 个部分

segname __LLVM

segname __LLVM

段名 __LLVM

段名 __LLVM

But while exporting the archive, Xcode still complains about absent bitcode.

但是在导出存档时,Xcode 仍然抱怨缺少 bitcode。

I tried to upload app on App store to verify if this issue is due to Xcode versions (I tried 8.3.3. and 9.0), but I get following email about build import error from iTunes Store.

我尝试在 App Store 上上传应用程序以验证此问题是否由 Xcode 版本引起(我尝试了 8.3.3. 和 9.0),但我收到了以下有关 iTunes Store 构建导入错误的电子邮件。

While processing your iOS app, APP_NAME 1.0(4), errors occurred in the app thinning process, and your app couldn't be thinned. If your app contains bitcode, bitcode processing may have failed. Because of these errors, this build of your app will not be able to be submitted for review or placed on the App Store. For information that may help resolve this issue, see Tech Note 2432.

在处理您的iOS应用APP_NAME 1.0(4)时,应用瘦身过程发生错误,您的应用无法瘦身。如果您的应用程序包含位码,则位码处理可能失败。由于这些错误,您的应用程序版本将无法提交审核或放置在 App Store 上。有关可能有助于解决此问题的信息,请参阅技术说明 2432。

PS: Disabling bitcode is not an option for us as host app need to support bitcode.

PS:禁用位码对我们来说不是一个选项,因为主机应用程序需要支持位码。

Error while exporting the Archieve

导出档案时出错

回答by Vipin

The error description took me in the wrong direction to find the solution.

错误描述使我在错误的方向上找到了解决方案。

This error is not related to bitcode.It appeared when the framework contained simulator slices (i386 x86_64)

此错误与位码无关。当框架包含模拟器切片时出现 ( i386 x86_64)

Removing them before archiving resolved the issue.

在归档之前删除它们解决了问题。

Adding a run script phase to build phases of the target with following code helped in getting rid of the error.

添加运行脚本阶段以使用以下代码构建目标的阶段有助于摆脱错误。

APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"

# This script loops through the frameworks embedded in the application and
# removes unused architectures.
find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"

EXTRACTED_ARCHS=()

for ARCH in $ARCHS
do
echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
done

echo "Merging extracted architectures: ${ARCHS}"
lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"
rm "${EXTRACTED_ARCHS[@]}"

echo "Replacing original executable with thinned version"
rm "$FRAMEWORK_EXECUTABLE_PATH"
mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"

done

Credits: http://ikennd.ac/blog/2015/02/stripping-unwanted-architectures-from-dynamic-libraries-in-xcode/

学分:http: //ikennd.ac/blog/2015/02/stripping-unwanted-architectures-from-dynamic-libraries-in-xcode/

If you don't know how to add a run script phase to your Xcode project, because maybe you're building a project with Cordova or Ionic and you never were taught much about Xcode, here's how you do that:

如果您不知道如何将运行脚本阶段添加到您的 Xcode 项目中,因为您可能正在使用 Cordova 或 Ionic 构建一个项目,而您从未学过太多有关 Xcode 的知识,那么您可以这样做:

  • Open your project in Xcode.
  • Make sure you're looking at your project in the "Project Navigator" by clicking on the left-most icon in the left pane of Xcode (the one that says "show Project Navigator" when you point at it.
  • Click on your project at the top of the navigator window, so that it is selected as your target
  • At that point, in the middle portion of the Xcode window, you'll see several things appear near the top. General, Capabilities, Resource Tags, Info, among others. One of them is Build Phases -- click on it.
  • Click the + that's near the top-left of the middle portion of the Xcode Window. It will say Add New Build Phase if you point at it long enough.
  • Select "New Run Script Phase" from the menu that popped up when you clicked on the +
  • Click on the arrow next to the Run Script that just appeared.
  • Copy and paste the above script into the appropriate area just below the word "Shell". You shouldn't have to change anything else.
  • Build/Archive your project like normal, only now you won't get those annoying "failed to verify bitcode" errors. :-)
  • 在 Xcode 中打开您的项目。
  • 通过单击 Xcode 左窗格中最左侧的图标(当您指向它时显示“显示项目导航器”的那个图标),确保您正在“项目导航器”中查看您的项目。
  • 单击导航器窗口顶部的项目,将其选为目标
  • 此时,在 Xcode 窗口的中间部分,您会看到顶部附近出现了几项内容。常规、功能、资源标签、信息等。其中之一是构建阶段——点击它。
  • 单击 Xcode 窗口中间部分左上角附近的 +。如果您指向它足够长的时间,它会说添加新构建阶段。
  • 从单击 + 时弹出的菜单中选择“New Run Script Phase”
  • 单击刚刚出现的运行脚本旁边的箭头。
  • 将上述脚本复制并粘贴到“Shell”一词下方的适当区域。你不应该改变任何其他东西。
  • 像往常一样构建/归档您的项目,只是现在您不会遇到那些烦人的“无法验证位码​​”错误。:-)

回答by MobileMon

I had to set Enable Bitcode to 'NO' in Build Settings

我必须在 Build Settings 中将 Enable Bitcode 设置为“NO”

回答by Roy K

Try the following:

请尝试以下操作:

  • Make sure this framework is added under Copy Frameworks Scriptin Build Phases.
  • Use BITCODE_GENERATION_MODE instead of BITCODE_GENERATION_CODE
  • 确保在构建阶段的复制框架脚本下添加此框架。
  • 使用 BITCODE_GENERATION_MODE 而不是 BITCODE_GENERATION_CODE