升级macOS Monterey系统,默认安装的Xcode14最低支持 iOS 11.0并且移除了armv7架构的SDK,所以要兼容更早的iOS版本就需要下载旧版本Xcode来打包了。
warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 9.0, but the range of supported deployment target versions is 11.0 to 16.0.99.
旧版本Xcode打包
下载地址:https://developer.apple.com/download/all
# 解压缩包
xattr -d com.apple.quarantine Xcode 12.5.1.xip
# Xcode13以下无法在 macOS Monterey上双击运行,只能命令行打包。
# 切换默认Xcode版本,方便执行 xcodebuild。
sudo xcode-select -s /Applications/Xcode12.app
# 如果切换默认Xcode版本就需要补全 xcodebuild路径
# Xcode命令行工具目录 Xcode12.app/Contents/Developer/usr/bin
# build debug framework
/Applications/Xcode12.app/Contents/Developer/usr/bin/xcodebuild -project ${proj.xcodeproj} -target ${target} ONLY_ACTIVE_ARCH=NO -configuration Debug -sdk iphoneos
# build release framework
/Applications/Xcode12.app/Contents/Developer/usr/bin/xcodebuild -project ${proj.xcodeproj} -target ${target} ONLY_ACTIVE_ARCH=NO -configuration Release -sdk iphoneos
# archive
/Applications/Xcode12.app/Contents/Developer/usr/bin/xcodebuild archive -workspace ${proj.xcworkspace} -scheme ${scheme} -configuration Release -archivePath ${out/app.xcarchive}
# export develop ipa
/Applications/Xcode12.app/Contents/Developer/usr/bin/xcodebuild -exportArchive -archivePath ${out/app.xcarchive} -exportPath ${out/dev} -exportOptionsPlist ${out/ExportOptionsDev.plist}
# export distribution ipa
/Applications/Xcode12.app/Contents/Developer/usr/bin/xcodebuild -exportArchive -archivePath ${out/app.xcarchive} -exportPath ${out/dis} -exportOptionsPlist ${out/ExportOptionsDis.plist}
证书参数
# 证书Identity获取方法
# 钥匙串 -> 选中证书 -> 右键 -> 显示简介(把标题复制出来)
# iPhone Distribution: XXX (WHZQ83KBDZ)
# 解密 Provisioning Profiles
cd /Users/${user}/Library/MobileDevice/Provisioning Profiles
/usr/bin/security cms -D -i 0bd90c81-1cd7-4203-bd19-5e115ebf50ec.mobileprovision