shell自动打包IPA

自动打包ipa,测试发现时间和用xcode打包差不多,但可以减少鼠标点击操作。

#!/bin/bash
#----------使用说明---
#将EnterpriseExportOptionsPlist放在.xcodeproj同级目录
#运行脚本,直接拖放项目目录(.xcodeproj上级文件夹)
#mac 下终端访问文件出现“Permission Denied”解决方案:chmod a+x ./文件名
#----------使用说明 END---
#配置信息--Start---------
version_string="3.5.0"      #版本号-空值不设置
build_number="3.5.1286"     #版本号-空值不设置
##企业(enterprise)证书名&描述文件
ENTERPRISECODE_SIGN_IDENTITY="iPhone Distribution: xxx Service Co., Ltd."
EnterpriseBundleID="com.xxx.inhouse"
ENTERPRISEROVISIONING_PROFILE_NAME="73c2dfe3-ebc4-4801-bbd6-e4ba25f14fe9"
echo "请拖入项目文件目录(.xcodeproj文件的上层目录)"
# 读取用户输入并存到变量里
read user_input
Project_Path=$user_input

#EnterpriseExportOptionsPlist文件路径
EnterpriseExportOptionsPlist=$Project_Path/EnterpriseExportOptionsPlist.plist
echo "$EnterpriseExportOptionsPlist" 
echo "$Project_Path" 
cd $Project_Path
#查找项目名称
Project_Name=`find . -name *.xcodeproj | awk -F "[/.]" '{print $(NF-1)}'` 
###############获取版本号,bundleID
info_plist=$Project_Path/$Project_Name/Info.plist
echo "~~~0~$Project_Name~~~~~"
ipa_outPath=~/Desktop/$Project_Name    #保存ipa文件到桌面
echo "~~~~~开始编译~~~~~"
#修改plist 版本号,修改build号函数--放在调用前
PlistBuddy_setting(){
    echo "~~~~~修改plist版本号~~~~~"
    bundleVersion=`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" $info_plist`
    bundleIdentifier=`/usr/libexec/PlistBuddy -c "Print CFBundleIdentifier" $info_plist`
    bundleBuildVersion=`/usr/libexec/PlistBuddy -c "Print CFBundleVersion" $info_plist`
    echo "~~~工程名~~~~~$Project_Name~~Bundle ID~~~$bundleIdentifier~~版本号~~~~~$bundleBuildVersion"

    if [ ! -n $version_string ]; then
         echo "IS NULL"
        else
        # 修改版本号
        /usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $version_string" "${info_plist}"
    fi

    if [ ! -n $version_string ]; then
         echo "IS NULL"
        else
        # 修改build号
        /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $build_number" ${info_plist}
    fi
}

xcodebuild_Archive(){
xcodebuild -project $Project_Name.xcodeproj -scheme $Project_Name -configuration Release -archivePath $Project_Name-enterprise.xcarchive clean archive build CODE_SIGN_IDENTITY="${ENTERPRISECODE_SIGN_IDENTITY}" PROVISIONING_PROFILE="${ENTERPRISEROVISIONING_PROFILE_NAME}" PRODUCT_BUNDLE_IDENTIFIER="${EnterpriseBundleID}"
}

xcodebuild_ExportArchive(){
xcodebuild -exportArchive -archivePath $Project_Name-enterprise.xcarchive -exportOptionsPlist $EnterpriseExportOptionsPlist -exportPath $ipa_outPath
}

#清理工程
xcodebuild -project ${Project_Path}/${Project_Name}.xcodeproj clean
#利用PlistBuddy修改plist信息
PlistBuddy_setting;
#企业打包脚本
xcodebuild_Archive;         #第一步--archive-.xcarchive
xcodebuild_ExportArchive;   #第二步--exportArchive-ipa
if [ -d "$ipa_outPath" ]; then
    echo "导出成功✅!! $ipa_outPath" 
    open $ipa_outPath
fi
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值