基于Python脚本 iOS 工程的自动打包
导入的库
import os
import requests
import webbrowser
import subprocess
import shutil
appFileFullPath = 'XXX.app'# .app的绝对路径(iOS工程的绝对路径)
PayLoadPath = '***' payload的路径
packBagPath = '/Users/zrq/Desktop/IPAPath'//ipa包的绝对路径
#编译打包流程
def bulidIPA():
#删除之前打包的ProgramBag文件夹
subprocess.call(["rm","-rf",packBagPath])
#创建PayLoad文件夹
mkdir(PayLoadPath)
#将app拷贝到PayLoadPath路径下
subprocess.call(["cp","-r",appFileFullPath,PayLoadPath])
#在桌面上创建packBagPath的文件夹
subprocess.call(["mkdir","-p",packBagPath])
#将PayLoadPath文件夹拷贝到packBagPath文件夹下
subprocess.call(["cp","-r",PayLoadPath,packBagPath])
#删除桌面的PayLoadPath文件夹
subprocess.call(["rm","-rf",PayLoadPath])
#切换到当前目录
os.chdir(packBagPath)
#压缩packBagPath文件夹下的PayLoadPath文件夹夹
subprocess.call(["zip","-r","./Payload.zip","."])
print ("\n*************** 打包成功 *********************\n")
#将zip文件改名为ipa
subprocess.call(["mv","payload.zip","Payload.ipa"])
#删除payLoad文件夹
subprocess.call(["rm","-rf","./Payload"])
#创建PayLoad文件夹
def mkdir(PayLoadPath):
isExists = os.path.exists(PayLoadPath)
if not isExists:
os.makedirs(PayLoadPath)
print(PayLoadPath + '创建成功')
return True
else:
print (PayLoadPath + '目录已经存在')
return False
if __name__ == '__main__':
bulidIPA()
uploadIPA('%s/Payload.ipa'%packBagPath)
//主动调用打包
原博客地址:http://www.cocoachina.com/ios/20180507/23295.html