XZ_Python之使用Python编写Xcode界面化打包脚本

    我们的项目每次更新之后,需要打100多个企业包,这个企业包的数量是一直都在增加的,之前都是手动打,这么多的包,大概得打一天的时间。。。。

    现在打100多个包只需要16分钟左右,我们的企业包的不同就在于每个企业包用户名和用户手机号不同,其他配置都是一样的,所以,思路是:在工程中创建一个plist,把所有的企业包的用户名和手机号都写在里面,在需要的时候,直接去里面取就行。打包的时候只生成一个.xcarchive包,然后修改项目的plist文件,重新签名然后打包输出。

   打包的思想跟使用命令行打包的思想是一样的,可查看文章 XZ_iOS之使用终端命令行打包

  打包功能的实现

   下面是实现打包功能的主要代码:

# 编译命令
archivePath = outputPath + "/" + scheme + ".xcarchive"
# 编译后app中的info.plist文件路径
infoPath = archivePath + "/Products/Applications/" + scheme + ".app/info.plist"
# 执行编译命令
buildCommand = "xcodebuild archive -project " + projectpath + " -scheme " + scheme + " -archivePath " + archivePath
output = os.system(buildCommand)
# 修改plist文件
for n in idList:
    pl = readPlist(infoPath)
    # 修改对应的业务数据
    pl["LocalUserID"] = n
    writePlist(pl, infoPath)
codeSignPlistPath = outputPath + "/DistributionSummary.plist"
    appPath = archivePath + "/Products/Applications/" + scheme + ".app"
    codesignCommand = "codesign -f -s " + teamName + " --entitlements " + codeSignPlistPath + " " + appPath
    print("执行签名命令: " + codesignCommand)
output = os.system(codesignCommand)
if output == 0:
    print("====================项目    <<" + n +
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值