shell脚本-iOS打包

1.打包导出配置文件ExportOptions.plist文件

    provisioningProfiles 包签名,hoc证书名字

    signingCertificatehoc证书 SHA-1 签名

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>uploadBitcode</key>
	<false/>
	<key>compileBitcode</key>
	<false/>
	<key>destination</key>
	<string>export</string>
	<key>method</key>
	<string>ad-hoc</string>
	<key>provisioningProfiles</key>
	<dict>
		<key>com.soft.youai</key>
		<string>lcx_ya_pp_hoc</string>
	</dict>
	<key>signingCertificate</key>
	<string>DE315EA1811A7F5953FC947AE4E185705D86C2FE</string>
	<key>signingStyle</key>
	<string>manual</string>
	<key>stripSwiftSymbols</key>
	<true/>
	<key>teamID</key>
	<string>47WKTWKMY6</string>
	<key>thinning</key>
	<string>&lt;none&gt;</string>
</dict>
</plist>

2.脚本文件

#注意:1.shell.sh和xxx.xcworkspace同一目录
#     2.ExportOptions.plist和xxx.xcworkspace同一目录

#---------------------------------配置工程信息---------------------------------
#archive类型 打包hoc 商店store
archive_type="store"
#工程名字(Target名字)
target_name="xxx"
#配置环境,Release或者Debug
configuration_type="Release"
#Bundle ID
target_bundleID="com.xxx.xxx"

#---------------------------------配置证书信息---------------------------------
#发布证书名称
dis_sign_identity="iPhone Distribution: xxx xxx xxx (xxxxxxxxxx)"
#hoc证书名称
hoc_pp_name="xxx"
#store证书名称
store_pp_name="xxx"
#蒲公英apiKey
pgyer_api_key="xxxxxxxxxxxxxxxxxxx"

#---------------------------------打包plist文件位置---------------------------------
#打包plist文件位置
exportoptions_plist_path=./ExportOptions.plist

echo "---------------------------------开始打包---------------------------------"
#1.清理就目录
rm -rf build

#2.清理构建目录
xcodebuild clean -xcodeproj ./$target_name/$target_name.xcodeproj -configuration $configuration_type -alltargets

if [ "${archive_type}" = "hoc" ]
then
    #3.归档
    xcodebuild -workspace $target_name.xcworkspace -scheme $target_name -configuration $configuration_type -archivePath build/$target_name-adhoc.xcarchive clean archive build CODE_SIGN_IDENTITY="${dis_sign_identity}" PROVISIONING_PROFILE="${hoc_pp_name}" PRODUCT_BUNDLE_IDENTIFIER="${target_bundleID}"
    #4.导出IPA
    xcodebuild -exportArchive -archivePath build/$target_name-adhoc.xcarchive -exportOptionsPlist $exportoptions_plist_path -exportPath build/$target_name-adhoc
    #5.上传到蒲公英
    curl -F "file=@build/${target_name}-adhoc/${target_name}.ipa" -F "_api_key=${pgyer_api_key}" https://www.pgyer.com/apiv2/app/upload
elif [ "${archive_type}" = "store" ]
then
    #3.归档
    xcodebuild -workspace $target_name.xcworkspace -scheme $target_name -configuration $configuration_type -archivePath build/$target_name-store.xcarchive clean archive build CODE_SIGN_IDENTITY="${dis_sign_identity}" PROVISIONING_PROFILE="${store_pp_name}" PRODUCT_BUNDLE_IDENTIFIER="${target_bundleID}"
    #4.导出IPA
    xcodebuild -exportArchive -archivePath build/$target_name-store.xcarchive -exportOptionsPlist $exportoptions_plist_path -exportPath build/$target_name-store
fi

echo "---------------------------------结束打包---------------------------------"

3.执行 终端 ./shell.sh

猜你喜欢

转载自blog.csdn.net/liqun3yue25/article/details/87623074