Xcode8.3之前,我一直用的xcrun命令进行ipa的导出
//xcrun -sdk iphoneos PackageApplication -v appnamepath−o ipa_name_path
但是最近我升级到Xcode8.3.2后,打包提示我:
xcrun: error: unable to find utility “PackageApplication”, not a developer tool or in PATH
解决办法:找到这个路径
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin
然后拷贝一份原来的PackageApplication文件到里面即可。
缺点:每次升级都要进行此操作一遍,而且用修改过的Xcode提交App Store可能会有问题
下面我来说一下我的做法:
//workspace的名字
Workspace_Name=”XXX”
//工程名字(Target名字)
Project_Name=”XXX”
//develop版本的Bundle ID
BundleID=”XXX”
//develop 证书名#描述文件
DevelopCODE_SIGN_IDENTITY=”iPhone Developer: XXX”
PROVISIONING_PROFILE_UUID=”XXX-XXX-XXX-XXX-XXX”
//加载plist文件
DevelopExportOptionsPlist=./exportOptions.plist
DevelopExportOptionsPlist=${DevelopExportOptionsPlist}
plist文件里写如下的类型即可,如果你需要打appstore,enterprise,或者adhoc类型的,只需要在里面自己添加相应的配置即可
compileBitcode默认是YES,如果你的项目没有开启bitcode,可以在当前plist文件里把compileBitcode设置为NO即可
//.ipa生成后的路径
//用当前时间命名
DATE=date +%Y-%m-%d_%H-%M-%S
ipa_name_path=/Users/XXX/Desktop/ projectname− {DATE}.ipa
第一步:生产archive包
xcodebuild archive -workspace WorkspaceName.xcworkspace−scheme Project_Name -configuration Configuration−archivePathbuild/ Project_Name.xcarchive CODE_SIGN_IDENTITY=” DevelopCODESIGNIDENTITY"PROVISIONINGPROFILE=" {PROVISIONING_PROFILE_UUID}”
注意:如果你没有用cocoapods管理三方,上面的命令换为如下:
xcodebuild archive -project ProjectName.xcodeproj−scheme Project_Name -configuration Configuration−archivePathbuild/ Project_Name.xcarchive CODE_SIGN_IDENTITY=” DevelopCODESIGNIDENTITY"PROVISIONINGPROFILE=" {PROVISIONING_PROFILE_UUID}”
第二步:生产ipa包
//生成ipa包时,使用DevelopExportOptionsPlist
xcodebuild -exportArchive -archivePath build/ ProjectName.xcarchive−exportPath ipa_name_path -exportOptionsPlist ${DevelopExportOptionsPlist}
此时ipa包导出成功
下面是完整的脚本用例:
//工程名字(Target名字)
Project_Name=”UZG”
//workspace的名字
Workspace_Name=”UZG”
//配置环境,Release或者Debug,默认Release
Configuration=”Release”
//develop版本的Bundle ID
BundleID=”XXX”
//develop 证书名#描述文件
DevelopCODE_SIGN_IDENTITY=”iPhone Developer: XXX”
PROVISIONING_PROFILE_UUID=”XXX-XXX-XXX-XXX-XXXXX”
DevelopExportOptionsPlist=./exportOptions.plist
DevelopExportOptionsPlist=${DevelopExportOptionsPlist}
//.ipa生成后的路径
//用当前时间命名
DATE=date +%Y-%m-%d_%H-%M-%S
ipa_name_path=/Users/xxx/Desktop/ projectname− {DATE}.ipa
//制作archive包
echo “~~~~~~~~第一步 生成archive包~~~~~~~~~~~”
//生成archive包时,使用证书,以及描述文件UUID
xcodebuild archive -workspace WorkspaceName.xcworkspace−scheme Project_Name -configuration Configuration−archivePathbuild/ Project_Name.xcarchive CODE_SIGN_IDENTITY=” DevelopCODESIGNIDENTITY"PROVISIONINGPROFILE=" {PROVISIONING_PROFILE_UUID}”
echo “~~~~~~~~第二步 生成ipa包~~~~~~~~~~~”
//生成ipa包时,使用DevelopExportOptionsPlist
xcodebuild -exportArchive -archivePath build/ ProjectName.xcarchive−exportPath ipa_name_path -exportOptionsPlist ${DevelopExportOptionsPlist}
echo “~~~~~~~~第三步 制作ipa包完 end~~~~~~~~~~~~”