美文网首页
ERROR ITMS-90087、ITMS-90209、ITMS

ERROR ITMS-90087、ITMS-90209、ITMS

作者: ThinkerH | 来源:发表于2017-11-22 23:24 被阅读215次

提交 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.

相关文章

网友评论

      本文标题:ERROR ITMS-90087、ITMS-90209、ITMS

      本文链接:https://www.haomeiwen.com/subject/jmlavxtx.html