前言
本來今天高高興興,周末跑來公司把新版本提交審核,Archive->Export ipa->打開Application Loader,本以為和平常一樣能夠輕輕松松的搞定,沒想到在用Application Loader提交的時候確報了一堆錯誤:
Snip20170709_2.png
ERROR ITMS-90087: "Unsupported Architectures. The executable for
JunYouLawer.app/Frameworks/FoxitRDK.framework contains unsupported architectures
'[x86_64, i386]'."
ERROR ITMS-90362: "Invalid Info.plist value. The value for the key 'MinimumOSVersion' in
bundle JunYouLawer.app/Frameworks/FoxitRDK.framework is invalid. The minimum value is
8.0"
ERROR ITMS-90209: "Invalid Segment Alignment. The app binary at
'JunYouLawer.app/Frameworks/FoxitRDK.framework/FoxitRDK' does not have proper segment
alignment. Try rebuilding the app with the latest Xcode version."
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."
WARNING ITMS-90080: "The executable
'Payload/JunYouLawer.app/Frameworks/FoxitRDK.framework' is not a Position Independent
Executable. Please ensure that your build settings are configured to create PIE executables.
For more information refer to Technical Q&A QA1788 - Building a Position Independent
Executable in the iOS Developer Library.
看到這一堆報錯,真是令人頭大,但是沒辦法,有了錯就得改啊,首先分析了一下這報錯的原因,仔細發現報錯的信息都指向了FoxitRDK.framework
,毫無疑問,罪魁禍首就是它了。于是又上網通過關鍵詞搜索錯誤碼看看有沒有什么解決的方法,在stackoverflow找到了一篇文章,大概意思是報錯的這個FoxitRDK.framework
里面包含了x86_64, i386 架構,解決方法就是通過在Xcode添加shell腳本去除x86_64, i386 這兩個架構。
如何在Xcode里面添加shell腳本
-
首先在Xcode菜單欄Editor->Add Build Phase -> Add Run Script Build Phase
Snip20170709_7.png 然后在Build Phases里發現多了一個Run Script
Snip20170709_8.png
在紅框里面添加以下代碼:
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
ok,到了這里好像是沒什么問題了,重新Archive打包上傳,最后發現架構的問題是解決了,可是還有一個錯誤沒有解除
Snip20170709_1.png
通過報錯信息可以知道又是這個
FoxitRDK.framework
出了問題,原因是FoxitRDK.framework
這個框架的info.plist
文件里的MinimumOSVersion
最小值是8.0,于是去找到這個info.plist文件,把MinimumOSVersion
改為8.0。
Snip20170709_9.png
OK,重新Archive打包上傳,Success,大功告成!!!