为临时分发导出存档时无法验证位码​​ - 尝试 Xcode 8.3.3 &Xcode 9 [英] Failed to verify bitcode while exporting archive for ad hoc distribution - tried Xcode 8.3.3 & Xcode 9

查看:22
本文介绍了为临时分发导出存档时无法验证位码​​ - 尝试 Xcode 8.3.3 &Xcode 9的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我已经阅读了 Apple 在这方面提供的文档

解决方案

错误描述让我在错误的方向上寻找解决方案.

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

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

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

APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"# 此脚本循环遍历嵌入在应用程序中的框架并# 删除未使用的架构.find "$APP_PATH" -name '*.framework' -type d |读时 -r 框架做FRAMEWORK_EXECUTABLE_NAME=$(默认为$FRAMEWORK/Info.plist"CFBundleExecutable)FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"echo "可执行文件是 $FRAMEWORK_EXECUTABLE_PATH"EXTRACTED_ARCHS=()用于 $ARCHS 中的 ARCH做echo "从 $FRAMEWORK_EXECUTABLE_NAME 中提取 $ARCH"lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")完毕echo "合并提取的架构:${ARCHS}"lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"rm "${EXTRACTED_ARCHS[@]}"echo "用精简版本替换原始可执行文件"rm "$FRAMEWORK_EXECUTABLE_PATH"mv "$FRAMEWORK_EXECUTABLE_PATH 合并" "$FRAMEWORK_EXECUTABLE_PATH"完毕

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

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

  • 在 Xcode 中打开您的项目.
  • 通过单击 Xcode 左窗格中最左侧的图标(当您指向它时显示显示项目导航器"的那个图标),确保您正在项目导航器"中查看您的项目.
  • 在导航器窗口顶部单击您的项目,以便将其选为目标
  • 此时,在 Xcode 窗口的中间部分,您会看到一些东西出现在顶部附近.常规、功能、资源标签、信息等.其中之一是构建阶段——点击它.
  • 单击 Xcode 窗口中间部分左上角附近的 +.如果您指向它足够长的时间,它会说添加新构建阶段.
  • 从点击 + 时弹出的菜单中选择New Run Script Phase"
  • 点击刚刚出现的运行脚本旁边的箭头.
  • 将上述脚本复制并粘贴到Shell"一词正下方的适当区域.您不应该更改任何其他内容.
  • 像往常一样构建/归档您的项目,只是现在您不会遇到那些烦人的无法验证位代码"错误.:-)

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)

I have gone through following similar questions posted on SO

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

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

New warnings in iOS 9

But the provided solutions do not seem to work.

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

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

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

It shows 2 segments

segname __LLVM

segname __LLVM

But while exporting the archive, Xcode still complains about absent 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.

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.

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

解决方案

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)

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/

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:

  • 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 8.3.3 &amp;Xcode 9的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆