iOS自动签名打包(xcodebuild)

#工程名字(Target名字)Project_Name="Target名字,系统默认和工程名字一样"#配置环境,Release或者DebugConfiguration="Release"#AdHoc版本的Bundle IDAdHocBundleID="com.xxx"#AppStore版本的Bundle IDAppStoreBundleID="com.xxx"#enterprise的Bundle IDEnterpriseBundleID="com.xxx"# ADHOC#证书名#描述文件ADHOCCODE_SIGN_IDENTITY="iPhone Distribution: xxxx"ADHOCPROVISIONING_PROFILE_NAME="xxxx-xxxx-xxxx-xxxx"#AppStore证书名#描述文件APPSTORECODE_SIGN_IDENTITY="iPhone Distribution: xxxx"APPSTOREROVISIONING_PROFILE_NAME="xxxx-xxxx-xxxx-xxxx"#企业(enterprise)证书名#描述文件ENTERPRISECODE_SIGN_IDENTITY="iPhone Distribution: xxxxx"ENTERPRISEROVISIONING_PROFILE_NAME="xxxx-xxxx-xxxx-xxxx"#加载各个版本的plist文件ADHOCExportOptionsPlist=./ADHOCExportOptionsPlist.plistAppStoreExportOptionsPlist=./AppStoreExportOptionsPlist.plistEnterpriseExportOptionsPlist=./EnterpriseExportOptionsPlist.plistADHOCExportOptionsPlist=${ADHOCExportOptionsPlist}AppStoreExportOptionsPlist=${AppStoreExportOptionsPlist}EnterpriseExportOptionsPlist=${EnterpriseExportOptionsPlist}echo "~~~~~~~~~~~~选择打包方式(输入序号)~~~~~~~~~~~~~~~"echo "  1 appstore"echo "  2 adhoc"echo "  3 enterprise"# 读取用户输入并存到变量里read parametersleep 0.5method="$parameter"# 判读用户是否有输入if [ -n "$method" ]then#clean下xcodebuild clean -xcodeproj ./$Project_Name/$Project_Name.xcodeproj -configuration $Configuration -alltargets    if [ "$method" = "1" ]    then#appstore脚本xcodebuild -project $Project_Name.xcodeproj -scheme $Project_Name -configuration $Configuration -archivePath build/$Project_Name-appstore.xcarchive clean archive build  CODE_SIGN_IDENTITY="${APPSTORECODE_SIGN_IDENTITY}" PROVISIONING_PROFILE="${APPSTOREROVISIONING_PROFILE_NAME}" PRODUCT_BUNDLE_IDENTIFIER="${AppStoreBundleID}"xcodebuild -exportArchive -archivePath build/$Project_Name-appstore.xcarchive -exportOptionsPlist $AppStoreExportOptionsPlist -exportPath ~/Desktop/$Project_Name-appstore.ipa    elif [ "$method" = "2" ]    then#adhoc脚本xcodebuild -project $Project_Name.xcodeproj -scheme $Project_Name -configuration $Configuration -archivePath build/$Project_Name-adhoc.xcarchive clean archive build CODE_SIGN_IDENTITY="${ADHOCCODE_SIGN_IDENTITY}" PROVISIONING_PROFILE="${ADHOCPROVISIONING_PROFILE_NAME}" PRODUCT_BUNDLE_IDENTIFIER="${AdHocBundleID}"xcodebuild -exportArchive -archivePath build/$Project_Name-adhoc.xcarchive -exportOptionsPlist $ADHOCExportOptionsPlist -exportPath ~/Desktop/$Project_Name-adhoc.ipa    elif [ "$method" = "3" ]    then#企业打包脚本xcodebuild -project $Project_Name.xcodeproj -scheme $Project_Name -configuration $Configuration -archivePath build/$Project_Name-enterprise.xcarchive clean archive build CODE_SIGN_IDENTITY="${ENTERPRISECODE_SIGN_IDENTITY}" PROVISIONING_PROFILE="${ENTERPRISEROVISIONING_PROFILE_NAME}" PRODUCT_BUNDLE_IDENTIFIER="${EnterpriseBundleID}"xcodebuild -exportArchive -archivePath build/$Project_Name-enterprise.xcarchive -exportOptionsPlist $EnterpriseExportOptionsPlist -exportPath ~/Desktop/$Project_Name-enterprise.ipaelse    echo "参数无效...."    exit 1    fifi注意:1.由于脚本配置的路径问题,所以xcodebuild.sh和xxx.xcodeproj放到同一个目录下,否则会出现路径问题...如下图:执行脚本打开终端,cd到当前脚本所在路径,在终端输入:./xcodebuild.sh,点击回车即可...脚本下载路径:github下载地址#author by 得力#注意:脚本目录和WorkSpace目录在同一个目录#工程名字(Target名字)Project_Name="Target名字,系统默认等于工程名字"#workspace的名字Workspace_Name="WorkSpace名字"#配置环境,Release或者Debug,默认releaseConfiguration="Release"#AdHoc版本的Bundle IDAdHocBundleID="com.xxxx"#AppStore版本的Bundle IDAppStoreBundleID="com.xxxx"#enterprise的Bundle IDEnterpriseBundleID="com.xxxx"# ADHOC证书名#描述文件ADHOCCODE_SIGN_IDENTITY="iPhone Distribution: xxxx"ADHOCPROVISIONING_PROFILE_NAME="xxxxx-xxxx-xxxx-xxxx-xxxxxx"#AppStore证书名#描述文件APPSTORECODE_SIGN_IDENTITY="iPhone Distribution: xxxxx"APPSTOREROVISIONING_PROFILE_NAME="xxxxx-xxxx-xxxx-xxxx-xxxxxx"#企业(enterprise)证书名#描述文件ENTERPRISECODE_SIGN_IDENTITY="iPhone Distribution: xxxx"ENTERPRISEROVISIONING_PROFILE_NAME="xxxxx-xxxx-xxx-xxxx"#加载各个版本的plist文件ADHOCExportOptionsPlist=./ADHOCExportOptionsPlist.plistAppStoreExportOptionsPlist=./AppStoreExportOptionsPlist.plistEnterpriseExportOptionsPlist=./EnterpriseExportOptionsPlist.plistADHOCExportOptionsPlist=${ADHOCExportOptionsPlist}AppStoreExportOptionsPlist=${AppStoreExportOptionsPlist}EnterpriseExportOptionsPlist=${EnterpriseExportOptionsPlist}echo "~~~~~~~~~~~~选择打包方式(输入序号)~~~~~~~~~~~~~~~"echo "  1 adHoc"echo "  2 AppStore"echo "  3 Enterprise"# 读取用户输入并存到变量里read parametersleep 0.5method="$parameter"# 判读用户是否有输入if [ -n "$method" ]then    if [ "$method" = "1" ]    then#adhoc脚本xcodebuild -workspace $Workspace_Name.xcworkspace -scheme $Project_Name -configuration $Configuration -archivePath build/$Project_Name-adhoc.xcarchive clean archive build CODE_SIGN_IDENTITY="${ADHOCCODE_SIGN_IDENTITY}" PROVISIONING_PROFILE="${ADHOCPROVISIONING_PROFILE_NAME}" PRODUCT_BUNDLE_IDENTIFIER="${AdHocBundleID}"xcodebuild  -exportArchive -archivePath build/$Project_Name-adhoc.xcarchive -exportOptionsPlist ${ADHOCExportOptionsPlist} -exportPath ~/Desktop/$Project_Name-adhoc.ipa    elif [ "$method" = "2" ]    then#appstore脚本xcodebuild -workspace $Workspace_Name.xcworkspace -scheme $Project_Name -configuration $Configuration -archivePath build/$Project_Name-appstore.xcarchive archive build CODE_SIGN_IDENTITY="${APPSTORECODE_SIGN_IDENTITY}" PROVISIONING_PROFILE="${APPSTOREROVISIONING_PROFILE_NAME}" PRODUCT_BUNDLE_IDENTIFIER="${AppStoreBundleID}"xcodebuild  -exportArchive -archivePath build/$Project_Name-appstore.xcarchive -exportOptionsPlist ${AppStoreExportOptionsPlist} -exportPath ~/Desktop/$Project_Name-appstore.ipa    elif [ "$method" = "3" ]    then#企业打包脚本xcodebuild -workspace $Workspace_Name.xcworkspace -scheme $Project_Name -configuration $Configuration -archivePath build/$Project_Name-enterprise.xcarchive archive build CODE_SIGN_IDENTITY="${ENTERPRISECODE_SIGN_IDENTITY}" PROVISIONING_PROFILE="${ENTERPRISEROVISIONING_PROFILE_NAME}" PRODUCT_BUNDLE_IDENTIFIER="${EnterpriseBundleID}"xcodebuild  -exportArchive -archivePath build/$Project_Name-enterprise.xcarchive -exportOptionsPlist ${EnterpriseExportOptionsPlist} -exportPath ~/Desktop/$Project_Name-enterprise.ipa    else    echo "参数无效...."    exit 1    fifi可能出现的问题1.如果配置的证书名字、BundleID、配置文件UUID不一致,脚本就会报错,这个可以看脚本提示错误,由于错误非常明显,所以就不在截图了。

扫描二维码分享话题