Xcode9.3 xcodebuild 自动化打包发布到蒲公英并发送邮件通知

前言

从事iOS最经常遇到的莫过于 测试同学过来 通知你 赶紧发个包 ~ ~ 。。然后一顿操作。作为一个有着多年iOS开发经验的程序猿,肯定不能再走寻常路,遂决定亲自写个脚本 ps: 其实是python忘的差不多了(本来也不咋的) 赶紧练练手 复习复习

相关配置

前提:mac配置python3
IDE工具:Pycharm
网络请求工具:Requests
脚本工具: Xcode

代码实现

编译并打包生成ipa文件

清理工程(command+shift+k)

  def cleanProject(self):
        global isWorkSpace
        if isWorkSpace:
            os.system(
                'cd %s;xcodebuild -workspace %s.xcworkspace -scheme %s clean' % (mainPath,  targetName, targetName))
        else:
            os.system('cd %s;xcodebuild -target %s clean' % (mainPath, targetName))
        return

编译工程

  def buildProject(self):

        if isWorkSpace:
            os.system(
                "cd %s;xcodebuild -workspace %s.xcworkspace -scheme %s -configuration Release  -archivePath %s/%s.xcarchive clean archive" % (
                    mainPath, targetName, targetName, archivePath, targetName))
        else:
            os.system(
                "cd %s;xcodebuild -project %s.xcodeproj -scheme %s -configuration Release  -archivePath %s/%s.xcarchive clean archive" % (
                    mainPath, targetName, targetName, archivePath, targetName))
        return

导出并生成IPA文件

        def cerateIPA(self):
        if isDev:
          os.system("cd %s; xcodebuild -exportArchive -archivePath %s/%s.xcarchive -exportPath %s/%s -exportOptionsPlist %s/DevExportOptions.plist -allowProvisioningUpdates -quiet" % (
                mainPath, archivePath, targetName, archivePath, targetName, archivePath))
        else:
            os.system(
                "cd %s; xcodebuild -exportArchive -archivePath %s/%s.xcarchive -exportPath %s/%s -exportOptionsPlist %s/DisExportOptions.plist -allowProvisioningUpdates -quiet" % (
                    mainPath, archivePath, targetName, archivePath, targetName, archivePath))
        return
上传到蒲公英

调用蒲公英API,将ipa文件上传至自己账户

   def uploadToPGY(self):
        print("上传到蒲公英")
        path = "%s/%s.ipa/%s.ipa" % (archivePath, targetName, targetName)
        f_op = open(path, 'rb')
        print(path)
        print(f_op.readlines())

        if os.path.exists(path):
            print("找到ipa文件")
            # 请求参数字典
            params = {
                'uKey': PGY_UKey,
                '_api_key': PGY_APIKey,
                'installType': PGY_INSTALL_type,
                'password': PGY_PW,
                'updateDescription': PGY_DES
            }

            response = requests.post(PGY_URL, files={
  "file": open(path, 'rb')}, data=params)


        else:
            print("没有找到ipa文件")
上传给Itunes Connect
  """
          altoolPath="/Applications/Xcode.app/Contents/Applications/Application\ Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Versions/A/Support/altool"
          ${altoolPath} --validate-app -f ${ipaPath} -u xxxxxx -p xxxxxx -t ios --output-format xml >>
          ${altoolPath} --upload-app -f ${ipaPath} -u xxxxxx -p xxxxxx -t ios --output-format xml

         
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值