一中简单说了使用xcodebuild命令archive和导出ipa
本篇主要就是写简单 python脚本来执行 xcodebuild命令 内容很简单 后期加直接上传firm
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import sys
import time
#Release Debug
configuration = 'Debug'
#是否是发布环境
isDistribution = False
# 项目根目录
project_path = "/Users/renqianbei/work/saasMz"
#当前autoIpa.py 以及 plist 所在文件夹位置
autoPythonRoot = '/Users/renqianbei/work/saasMz/autoIPA'
#自动打包根目录
autoBuildDirRoot = '/Users/renqianbei/Desktop/saasM_Autobuild'
# 编译成功后.xcarchive所在目录
archive_dir = autoBuildDirRoot+'/archive'
# 编译后目录
build_path = autoBuildDirRoot+'/build'
# 打包后ipa存储目录
targerIPA_dir = autoBuildDirRoot+'/ipaDir'
project_Name = 'Saas_M'
scheme = 'Saas_M'
#CA certificate
#发布证书
DistributionCodeSignIndentify = "iPhone Distribution: renqianbei(1231)"
DistributionProfile = "1231231-131-231"
DistributionExportFileName = "Distribution_ExportOptions.plist"
#测试证书
DeveloperCodeSignIndentify = "iPhone Developer:renqianbei (W7318)"
DeveloperProfile = "fwefwwfwfew-12321-123123-123"
DeveloperExportFileName = "Develop_ExportOptions.plist"
#时间字符串
time_Tag = '%s'%(time.strftime('%Y-%m-%d-%H-%M-%S',time.localtime(time.time())))
# 清理项目 创建build目录
def clean_project_mkdir_build():
os.system('rm -rf %s;mkdir %s'%(build_path,build_path))
#archive 打包
def archive_project():
print("====archive_project start")
print(archiveName())
os.system('cd %s; xcodebuild archive -workspace %s.xcworkspace -scheme %s -configuration %s -archivePath %s CONFIGURATION_BUILD_DIR=%s CODE_SIGN_IDENTITY="%s" PROVISIONING_PROFILE="%s"'
%(project_path,project_Name,scheme,configuration,archivePath(),build_path,CodeSignIdentify(),ProvisioningProfile())
)
# 打包ipa 并且保存在桌面
def export_ipa():
print("export_ipa start")
print(ipafilename())
print(export_OptionsPlist())
os.system('xcodebuild -exportArchive -archivePath %s/ -exportOptionsPlist %s -exportPath %s'%(archivePath(),export_OptionsPlist(),exportpath()))
def main():
# 清理并创建build目录
clean_project_mkdir_build()
# 编译coocaPods项目文件并 执行编译目录
archive_project()
# 导出ipa
export_ipa()
main()