主要使用两个命令
xcodebuild:将xcode工程打包成.app文件
xcrun:将app打包成.ipa文件
下面是写好的ant脚本:
1 <?xml version="1.0" encoding="UTF-8"?> 2 <project default="release" name="PackageForIOS" basedir="."> 3 <property name="xcodeProjectPath" value="/Users/xxx/Documents/IOS"/> 4 <property name="appPath" value="${xcodeProjectPath}/build/xxx.app"/> 5 <property name="ipaPath" value="${xcodeProjectPath}/build/xxx.ipa"/> 6 7 <!-- 证书 --> 8 <property name="sign" value="iPhone Developer: xxx"/> 9 <!-- 描述文件 --> 10 <property name="provision" value="xxx.mobileprovision"/> 11 <!-- provisionUUID根据provision生成 --> 12 <property name="provisionUUID" value="5cdcxxxx-4295-xxxx-bb44-cb4c89ee4245"/> 13 14 <target name="ipaBuild"> 15 <exec executable="/bin/bash" dir="${xcodeProjectPath}"> 16 <arg value="-c"/> 17 <arg value="xcodebuild clean"/> 18 </exec> 19 20 <echo message="Generate: ${appPath}" /> 21 <exec executable="/bin/bash" dir="${xcodeProjectPath}"> 22 <arg value="-c"/> 23 <arg value="xcodebuild CODE_SIGN_IDENTITY=‘${sign}‘ PROVISIONING_PROFILE=${provisionUUID}"/> 24 </exec> 25 26 <echo message="Generate: ${ipaPath}" /> 27 <exec executable="/bin/bash" dir="${xcodeProjectPath}"> 28 <arg value="-c"/> 29 <arg value="xcrun -sdk iphoneos PackageApplication -v ${appPath} -o ${ipaPath}"/> 30 </exec> 31 </target> 32 </project>
其中provisionUUID,需要根据描述文件*.mobileprovision来生成,生成代码如下:
1 #!/bin/bash 2 3 #描述文件存放的位置 4 provision=`pwd`/Dev_provision3.mobileprovision 5 #获取UUID 6 provisionUUID=`/usr/libexec/PlistBuddy -c ‘Print :UUID‘ /dev/stdin <<< $(security cms -D -i ${provision} )` 7 echo provisionUUID
时间: 2024-11-05 12:25:08