ERROR ITMS-90087、ITMS-90209、ITMS-90125、ITMS-90125

提交 APP store 报错 Unsupported Architecture x86

晚上打包归档提交APP store,报了3个错误一个警告,如下:

1.ERROR ITMS-90087: "Unsupported Architecture. Your executable contains unsupported architecture '[x86_64, i386]'."
2.ERROR ITMS-90209: "Invalid segment Alignment. The App Binary at SJAPP.app/Frameworks/PLPlayerKit.framework/Buy does not have proper segment alignment. Try rebuilding the app with the latest xcode version."
3.ERROR ITMS-90125: "The Binary is invalid. The encryption info in the LC_ENCRYPTION_INFO load command is either missing or invalid, or the binary is already encrypted. This binary does not seem to have been built with Apple's Linker."
4.WARNING ITMS-90080: "The Executable Payload/..../PLPlayerKit.framework is not a Position Independent Executable. Please ensure that ur build settings are configured to create PIE executables."

原因很明显,是集成的第三方库PLPlayerKit.framework的问题。
坑爹玩意,模拟器、真机编译都正常,就是归档提交APP store 报错。

开始漫长的查找原因和解决方法的路程。。。

原因:

在build setting的link library导入PLPlayerKit.framework后,无法读取framework中的图片资源,编译运行会报如下错误:

dyld: Library not loaded: @rpath/PLPlayerKit.framework/PLPlayerKit

Referenced from: /private/var/mobile/Containers/Bundle/Application/107B34E6-F250-4511-9FA9-31526F8E7B84/Test.app/Test

Reason: image not found

这是因为以前iOS上用的framework,实际上都是static library打包成framework结构,图片资源打包为bundle。直接在工程中导入framework和bundle资源即可。然而动态包直接将图片资源编译打包进framework,需要在导入的工程中做下面两个配置。

  • 将包含图片的framework加载到bundle resource。
  • 在build setting界面:target-〉Build Phases -〉左上角+号 -〉New Copy Files Phase 然后在Copy Files下 Destination选择Frameworks -〉添加动态库或在已有的embed frameworks添加该动态库。

到这里Library not loaded的错误解决了,模拟器和真机的运行也都一切OK。
BUT ...

在今天归档提交 APP store 时,验证资源的过程中一下报了开头那4个错。。。
错误的原因很明显,动态库不支持 architecture '[x86_64, i386]' 。

解决:

在Build Phases里点击左上角+号添加Run Script,然后粘贴如下脚本文件:

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

然后编译,如果工程中引用的第三方库比较多的话,可能会报一堆错:
例如:

fatal error: lipo: input file (/...Frameworks/*.framework/Bolts) must be a fat file when the -extract option is specified
...

显然上面的脚本导致的其他的库文件报错。

解决办法:
现在只有 PLPlayerKit.framework 这个动态库提交时有问题,所以这里把

find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK

换成

find "$APP_PATH" -name 'PLPlayerKit.framework' -type d | while read -r FRAMEWORK

就可以了。

或者,使用下面的脚本文件,跳过不适用的库文件:

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"

if [ ! -f "${FRAMEWORK_EXECUTABLE_PATH}" ]; then
continue
fi

if xcrun lipo -info "${FRAMEWORK_EXECUTABLE_PATH}" | grep --silent "Non-fat"; then
echo "Framework non-fat, skipping: $FRAMEWORK_EXECUTABLE_NAME"
continue
fi

echo "Thinning framework $FRAMEWORK_EXECUTABLE_NAME"

EXTRACTED_ARCHS=()

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

echo "Merging extracted architectures: ${ARCHS}"
xcrun 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

Done.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 静态库与动态库的区别 首先来看什么是库,库(Library)说白了就是一段编译好的二进制代码,加上头文件就可以供别...
    吃瓜群众呀阅读 12,089评论 3 42
  • 仅以方便自己查阅记录前言1.静态库和动态库有什么异同?静态库:链接时完整地拷贝至可执行文件中,被多次使用就有多份冗...
    190CM阅读 4,295评论 0 4
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,637评论 25 708
  • 晚上和几个同事一起吃饭,讨论到要找一个什么样的对象。 男同事说,找公司的男生挺好的,加班多,实在,没心思出去花。 ...
    苏语嫣阅读 334评论 0 0
  • 如果,天是海的蓝 会不会引来飞鱼 或是漂亮的扇贝还有虾蟹 可以在白云上打滚 在月宫里做客 在繁星上奔跑 再嗅一嗅桂...
    北城未眠阅读 451评论 28 16