1. 打包失败 提示IPA processing failed
查看日志 IDEDistribution.standard.log 发现HyphenateLite这个SDK支持X86_64这个架构
2020-05-25 02:12:21 +0000 Assertion failed: Expected 4 archs in otool output:
/var/folders/_p/86p_txdd64n2483kkv4423rr0000gn/T/IDEDistributionOptionThinning.~~~IakcuY/Payload/BD.app/Frameworks/HyphenateLite.framework/HyphenateLite:
Mach header
magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
MH_MAGIC_64 X86_64 ALL 0x00 DYLIB 33 4584 NOUNDEFS DYLDLINK TWOLEVEL WEAK_DEFINES BINDS_TO_WEAK NO_REEXPORTED_DYLIBS
Load command 0
原因
X86_64是模拟器需要的 打包的时候不支持模拟器架构打包
模拟器/真机的处理器,架构和机型
处理器 | 架构 | 机型 | |||
---|---|---|---|---|---|
模拟器 | 32位 | i386 | iPhone5 ,iPhone5s以下的模拟器 | ||
模拟器 | 64位 | x86_64 | iPhone6以上的模拟器 | ||
真机 | 32位 | armv7 | iPhone4真机 | ||
真机 | 32位 | armv7s | iPhone5,iPhone5s真机 | ||
真机 | 64位 | arm64 | iPhone6,iPhone6p以上的真机 |
解决办法 添加脚本 在打包的时候剔除模拟器架构
# Type a script or drag a script file from your workspace to insert its path.
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
图示位置
TARGETS -> Build Phases -> 左上角加号 -> 选择 New Run Script Phase -> 把上述脚本复制进去 -> 再打包
2. Building for iOS Simulator, but the linked framework 'RPSDK.framework' was built for iOS.
在接入阿里云人脸识别后,直接跑模拟器会报错
Xcode 的Build System改成Legacy Build System再跑模拟器,就成功了
File
→ Workspace Settings...
→ Build System
→ Legacy Build System
图示位置
3. Xcode 11 版本build 自增脚本
旧的 build 自增脚本在新版Xcode 11里 ${plist} 取出来是环境变量名,无效了
需要将 ${plist} 修改成 INFO_PLIST_FULL_PATH= "${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}"
新脚本如下
Archive 打包则配置 CONFIGURATION == Release
如果是Debug 则是 CONFIGURATION == Debug
if [ $CONFIGURATION == Release ]; then
echo "当前为 Release Configuration,开始自增 Build"
plist=${INFOPLIST_FILE}
buildnum=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}")
if [[ "${buildnum}" == "" ]]; then
echo "Error:在Plist文件里没有 Build 值"
exit 2
fi
buildnum=$(expr $buildnum + 1)
/usr/libexec/PlistBuddy -c "Set CFBundleVersion $buildnum" "${plist}"
echo "自动设置: 为" buildnum
else
echo $CONFIGURATION "当前不为 Release Configuration"
f
添加方法