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

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

问题描述

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



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

解决方案

错误描述使我朝错误的方向寻找解决方案。



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



在存档解决之前将其删除问题。



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

  APP_PATH = $ {TARGET_BUILD_DIR} / $ {WRAPPER_NAME} 

#此脚本循环浏览应用程序中嵌入的框架,并删除
#未使用的架构。
找到 $ APP_PATH-名称 * .framework-类型d |在读取-r FRAMEWORK
时执行
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-创建 $ {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中打开项目。

  • 通过单击Xco​​de左窗格中最左边的图标(当您指向它时显示 show Project Navigator的图标)来确保您正在 Project Navigator中查看项目。

  • 在导航器窗口的顶部单击您的项目,以便将其选择为目标。

  • 此时,在项目的中间在Xcode窗口中,您会看到顶部附近出现了一些东西。常规,功能,资源标签,信息等。其中之一是构建阶段-单击它。

  • 单击Xco​​de窗口中间部分左上角附近的+。如果您将其指向足够长的时间,它将显示添加新构建阶段。

  • 从单击+
  • $时弹出的菜单中选择新建运行脚本阶段。 b $ b
  • 单击刚出现的运行脚本旁边的箭头。

  • 将上面的脚本复制并粘贴到单词 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天全站免登陆