这两天在网上找了些自动打包的文章,精(Chao)心(Xi)整(Xiu)理(Gai)了两份打包文件。
测试的小伙伴 ,来要测试包吧,哥不烦了。
shell
#项目路径
project_path="XXX"
#xcworkspace 名称
xcworkspace="XXX.xcworkspace"
#scheme 名称
scheme="XXX"
#打包证书名称
profilename="XXX"
#获取当前系统时间
today=`date +%Y%m%d%H%M%S`
#打包前缀名称
ipaName="LDPX_HomeTest_V2.03_"
#archive 放置路径
archivePath="XXX"
xcarchiveName=".xcarchive"
archiveRPath=$archivePath$ipaName$today$xcarchiveName
#打包ipa放置路径
ipaPath="XXX"
ipa=".ipa"
ipaPathR=$ipaPath$ipaName$today$ipa
cd $project_path
echo $ipaPathR
echo $archiveRPath
echo "clean start..."
xcodebuild clean -workspace $xcworkspace -scheme CMCC_CY -configuration release
echo "clean end."
echo "compile start......"
#编译时增加archive字段,指定archive 路径
xcodebuild archive -workspace $xcworkspace -scheme $scheme -configuration release -sdk iphoneos9.2 IPHONEOS_DEPLOYMENT_TARGET=8.0 -archivePath $archiveRPath;
echo "compile end."
echo "xcodebuild archive start......"
#将xcrun改为 xcodebuild -exportArchive 导出ipa包
xcodebuild -exportArchive -archivePath $archiveRPath -exportPath $ipaPathR -exportFormat IPA -exportProvisioningProfile $profilename
echo "******xcodebuild archive end.******"
echo $ipaPathR
echo $archiveRPath
echo "******xcodebuild archive end.******"
python
# -*- coding: utf-8 -*-
import os
import sys
import time
# 项目根目录
project_path = "XXX"
#activePath
activePath = "XXX/XXX.xcarchive"
# 打包后ipa存储目录
targerIPA_parth = "XXX"
#证书名称
cerName = "XXX"
#测试包
#LDPX_Test_V2.01_B1.00_20161226.ipa
#家里测试包
#LDPX_TestHome_V2.01_B1.00_20161226.ipa
#上线版本
#LDPX_V2.01_B1.00_20161226.ipa
ipaName = "LDPX_HomeTest_V2.03_"
# 清理项目 创建build目录
def clean_project_mkdir_build():
os.system('cd %s;xcodebuild clean -workspace "CMCC_CY.xcworkspace" -scheme CMCC_CY -configuration release' % project_path) # clean 项目
def build_project():
print("build release start")
os.system ('xcodebuild -list')
os.system ('cd %s;xcodebuild archive -workspace "CMCC_CY.xcworkspace" -scheme CMCC_CY -configuration release -sdk iphoneos9.2 IPHONEOS_DEPLOYMENT_TARGET=8.0 -archivePath %s;' % (project_path,activePath))
# 打包ipa 并且保存在桌面
def build_ipa():
global ipa_filename
timeSr = time.strftime('%Y%m%d%H%M%S.ipa',time.localtime(time.time()))
ipa_filename = ipaName + timeSr
os.system ('xcodebuild -exportArchive -archivePath %s -exportPath %s/%s -exportFormat IPA -exportProvisioningProfile %s'%(activePath,targerIPA_parth,ipa_filename,cerName))
def main():
# 清理
clean_project_mkdir_build()
# 编译coocaPods项目文件并 执行编译目录
build_project()
# 打包ipa 并放置到指定路径
build_ipa()
# 执行
main()
后续可优化部分
- 跟新代码库
- 邮件通知相关测试人员
- 脚本写的跟灵活点(次要。。。毕竟项目目录、名称不可能频繁的改变)
网友评论