問(wèn)題
APP改版測(cè)試后準(zhǔn)備Archive發(fā)布時(shí)痰驱,結(jié)果居然出現(xiàn)題目中的錯(cuò)誤提示证芭。查了一下,如果archive的時(shí)候沒(méi)有選iOS Devices而是模擬器担映,會(huì)出現(xiàn)這個(gè)錯(cuò)誤提示废士。
另一種情況就是我項(xiàng)目中的:用到了一些其它的結(jié)構(gòu)包含x86_64, i386的framework。
解決方法
可以在終端使用
$ lipo -info workspacePath/XXX.framework/XXX 命令來(lái)檢查一下framework蝇完。
解決方法是生成binary的時(shí)候使用一段script來(lái)去掉那些不支持的結(jié)構(gòu)官硝。
在Xcode中選擇項(xiàng)目->TARGETS->Build Phases, 找到Embed Framework。
然后在Xcode的菜單欄Editor->Add Build Phase->Add Run Scrip Build Phase短蜕。
如下圖:
于是在Embed Framework下面會(huì)出現(xiàn)Run Script氢架。
Shell填入:/bin/sh
下面輸入這段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
操作如下圖:
然后重新Archive即可。