IOS 打包证书签名 shell脚本
生活随笔
收集整理的這篇文章主要介紹了
IOS 打包证书签名 shell脚本
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
shell 腳本:
#!/bin/bash # #-------------------------------------------- # 功能: # 作者: # 創(chuàng)建日期: #--------------------------------------------#上傳服務(wù)器配置 appId="0001" versionId="1.0.0" uploadUrl="http://*********/test/upload.json"#證書(shū)及描述文件 CODE_SIGN_IDENTITY="iPhone Distribution: *** Appliance Co., Ltd." DEVELOPMENT_TEAM="5E2PGY2377***" PROVISIONING_PROFILE_SPECIFIER="****Enterprise"#打包環(huán)境檢測(cè) if [ $1 != "sit" -a $1 != "pre" -a $1 != "Pre" -a $1 != "pre2" -a $1 != "Pre2" -a $1 != "pre3" -a $1 != "Pre3" -a $1 != "prd" ]; thenecho "請(qǐng)輸入正確的構(gòu)建環(huán)境:[sit | pre | Pre | pre2 | Pre2 | pre3 | Pre3 | prd]"exit 1 elsebuild_env=$(echo $1 | perl -pe 's/.*/\u$&/') fi#工程路徑讀取 workspace_path="$(cd "$(dirname $0)" && pwd)" cd ${workspace_path} workspace_name=$(ls | grep xcworkspace) project_dir="epa_project_ios" project_path=${workspace_path}/${project_dir} project_name=$(ls ${project_dir} | grep xcodeproj | awk -F.xcodeproj '{print $1}') target_name=${project_name} info_plist=${project_path}/Project/${project_name}-Info.plist result_path=${workspace_path}/build/${build_env}_$(date +%Y-%m-%d_%H_%M)#工程代碼更新 echo "======開(kāi)始更新代碼======" cd ${project_path} git stash git pull --rebase cd ${workspace_path} pod update --no-repo-update --verbose if [ $? != 0 ]; thenecho "======代碼更新失敗======"exit 1 elseecho "======完成代碼更新======" fi#修改版本號(hào) if [ -n "$2" ]; thenbundleShortVersion=$(echo $2 | perl -pe 's/.*/\u$&/')/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${bundleShortVersion}" ${info_plist} else#主版本號(hào)讀取bundleShortVersion=$(/usr/libexec/PlistBuddy -c "print CFBundleShortVersionString" ${info_plist}) fi#應(yīng)用標(biāo)識(shí)及名稱(chēng)修改 case "$1" insit|pre|pre2|pre3)bundle_identifier=com.suning.${build_env}bundle_name=${build_env}${bundleShortVersion};;Sit|Pre|Pre2|Pre3|Prd|prd)bundle_identifier=com.suning.SuningEfubaobundle_name="****test";; esac/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier ${bundle_identifier}" ${info_plist} /usr/libexec/PlistBuddy -c "Set :CFBundleDisplayName ${bundle_name}" ${info_plist}#Today Extension te_info_plist=${project_path}/NotificationBarForYiFuBao/Info.plist if [ -f ${nse_info_plist} ]; thente_bundle_identifier=${bundle_identifier}.NSExtension/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier ${te_bundle_identifier}" ${te_info_plist} fi#Notification Service Extension nse_info_plist=${project_path}/NotificationServiceExtension/Info.plist if [ -f ${nse_info_plist} ]; thennse_bundle_identifier=${bundle_identifier}.NotificationServiceExtension/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier ${nse_bundle_identifier}" ${nse_info_plist} fi#打包環(huán)境修改 config_file=${project_path}/Project/Src/Constants/BuildConfig.hif [ -f ${config_file} ]; thenupper_env=$(echo ${build_env} | tr '[a-z]' '[A-Z]')echo "======修改環(huán)境配置======"sed -i '' "/TARGET_ENV_/ s/1/0/" ${config_file}sed -i '' "/TARGET_ENV_${upper_env}/ s/0/1/" ${config_file}sed -i '' "/DEBUG_ENABLE/ s/1/0/" ${config_file}fi#構(gòu)建路徑設(shè)置 mkdir -p "${result_path}" setting_out=${result_path}/build_setting.txt xcodebuild -showBuildSettings -workspace "${workspace_name}" -scheme "${target_name}" -configuration Release > ${setting_out} build_path=`echo $(grep -w "CONFIGURATION_BUILD_DIR" ${setting_out} | awk -F= '{print $2}')` echo "======build_path: ${build_path}======" archive_path=${build_path}/${target_name}.xcarchive#清除舊包 rm -rf ${archive_path} #歸檔打包 echo "======開(kāi)始構(gòu)建======" xcodebuild clean archive -workspace "${workspace_name}" \ -scheme "${target_name}" \ -archivePath ${archive_path} \ -configuration Release \ CODE_SIGN_IDENTITY="${CODE_SIGN_IDENTITY}" \ DEVELOPMENT_TEAM="${DEVELOPMENT_TEAM}" \ PROVISIONING_PROFILE_SPECIFIER="${PROVISIONING_PROFILE_SPECIFIER}"echo "======檢查是否構(gòu)建成功======" if [ -d "${archive_path}" ]; thenecho "構(gòu)建成功......"elseecho -e "\033[31m 構(gòu)建失敗,請(qǐng)修正后重新運(yùn)行! \033[0m"rm -rf ${result_path}exit 1ficd ${project_path} git checkout -- ${config_file} git checkout -- ${info_plist} git checkout -- SNYifubao.xcodeproj/project.pbxprojipa_name=${target_name}_${bundleShortVersion}.ipa ipa_path=${result_path} ExportOptionsPlist=${project_path}/ExportOptions.plist#XCODE8 需要使用系統(tǒng)的ruby which rvm > /dev/null if [[ $? -eq 0 ]]; thenecho "RVM detected, forcing to use system ruby"[ -s "$HOME/.rvm/scripts/rvm" ] && . "$HOME/.rvm/scripts/rvm"rvm use system fi#導(dǎo)出ipa xcodebuild -exportArchive \ -archivePath ${archive_path} \ -exportOptionsPlist ${ExportOptionsPlist} \ -exportPath ${ipa_path}echo "======檢查是否成功導(dǎo)出ipa======" ipa_temp_path=${ipa_path}/${target_name}.ipa if [ -f "${ipa_temp_path}" ]; thenecho "導(dǎo)出ipa成功......"#ipa重命名mv "${ipa_temp_path}" "${ipa_path}/${ipa_name}" elseecho -e "\033[31m 導(dǎo)出ipa失敗...... \033[0m"exit 1 fi#備份dSYM dsym_path=${archive_path}/dSYMs/${target_name}.app.dSYM/Contents/Resources/DWARF/${target_name} cp -R "${dsym_path}" "${result_path}/${target_name}.dSYM"#info名稱(chēng) ipa_info=${target_name}_${bundleShortVersion}.info echo ${target_name} ${bundleShortVersion} $1"($(date "+%Y-%m-%d %H:%M"))" > ${result_path}/${ipa_info} ipaDesc="****test"$1echo "======result_path: ${result_path}======"###########################################文件上傳###########################################echo "======開(kāi)始上傳測(cè)試包======" case "$build_env" in Pre|Pre2|Pre3) build_env="Pre";; esac cd ${result_path} #curl -T "{${ipa_name},${ipa_info}}" -u epp:ios ftp://*********/${build_env}/ipa/curl -F "appId=${appId}" -F "versionId=${versionId}" -F "bundleId=${bundle_identifier}" -F "ipaDesc=${ipaDesc}" -F "ipaFile=@${ipa_path}/${ipa_name}" ${uploadUrl}echo "======共耗時(shí)${SECONDS}秒======"總結(jié)
以上是生活随笔為你收集整理的IOS 打包证书签名 shell脚本的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Swift 中的关键字详解
- 下一篇: openjdk(HOTSPOT)垃圾回收