iOS-自動化打包上傳到Fir.im或者蒲公英

一、fastlane自動打包

fastlane自動打包方式,點擊跳轉。

二、 python環(huán)境安裝 , 自己Google吧. 文章很多 .

1、安裝python包管理器

pip?? curl https://bootstrap.pypa.io/get-pip.py -o get-pip.pysudo python get-pip.py

2、安裝requets庫

sudo pip install requests

二、上傳到蒲公英

具體python代碼如下 .

#!/usr/bin/env python

#coding=utf-8

import os

import commands

import requests

import webbrowser

'''

使用注意事項:該腳本基于python2.7

1、將工程的編譯設備選成 Gemeric iOS Device

2、command + B編譯

3、執(zhí)行腳本文件

'''

#(此處需要替換)編譯的app的位置

appFileFullPath = '/Users/guanliyuancc/Desktop/SeresNew/build/ios/iphoneos/Runner.app'

#Release-iphoneos

#(此處需要替換)

PayLoadPath = '/Users/guanliyuancc/Desktop/Payload'

packBagPath = '/Users/guanliyuancc/Desktop/ProgramBag'

#將此處打開的鏈接改為蒲公英對應app的鏈接

openUrl = 'https://www.pgyer.com/apptest'

#(此處需要替換)上傳蒲公英的key

USER_KEY = ""

API_KEY = ""

#上傳蒲公英

def uploadIPA(IPAPath):

? ? if(IPAPath==''):

? ? ? ? print "\n*************** 沒有找到對應上傳的IPA包 *********************\n"

? ? ? ? return

? ? else:

? ? ? ? print "\n***************開始上傳到蒲公英*********************\n"

? ? ? ? url='http://www.pgyer.com/apiv1/app/upload'

? ? ? ? data={

? ? ? ? ? ? 'uKey':USER_KEY,

? ? ? ? ? ? '_api_key':API_KEY,

? ? ? ? ? ? 'installType':'2',

? ? ? ? ? ? 'password':'123456',

? ? ? ? ? ? 'updateDescription':des

? ? ? ? }

? ? ? ? files={'file':open(IPAPath,'rb')}

? ? ? ? r=requests.post(url,data=data,files=files)

def openDownloadUrl():

? ? webbrowser.open(openUrl,new=1,autoraise=True)

? ? print "\n*************** 更新成功 *********************\n"

#編譯打包流程

def bulidIPA():

? ? #打包之前先刪除packBagPath下的文件夾

? ? commands.getoutput('rm -rf %s'%packBagPath)

? ? #創(chuàng)建PayLoad文件夾

? ? mkdir(PayLoadPath)

? ? #將app拷貝到PayLoadPath路徑下

? ? commands.getoutput('cp -r %s %s'%(appFileFullPath,PayLoadPath))

? ? #在桌面上創(chuàng)建packBagPath的文件夾

? ? commands.getoutput('mkdir -p %s'%packBagPath)

? ? #將PayLoadPath文件夾拷貝到packBagPath文件夾下

? ? commands.getoutput('cp -r %s %s'%(PayLoadPath,packBagPath))

? ? #刪除桌面的PayLoadPath文件夾

? ? commands.getoutput('rm -rf %s'%(PayLoadPath))

? ? #切換到當前目錄

? ? os.chdir(packBagPath)

? ? #壓縮packBagPath文件夾下的PayLoadPath文件夾夾

? ? commands.getoutput('zip -r ./Payload.zip .')

? ? print "\n*************** 打包成功 *********************\n"

? ? #將zip文件改名為ipa

? ? commands.getoutput('mv Payload.zip Payload.ipa')

? ? #刪除payLoad文件夾

? ? commands.getoutput('rm -rf ./Payload')

#創(chuàng)建PayLoad文件夾

def mkdir(PayLoadPath):

? ? isExists = os.path.exists(PayLoadPath)

? ? if not isExists:

? ? ? ? os.makedirs(PayLoadPath)

? ? ? ? print PayLoadPath + '創(chuàng)建成功'

? ? ? ? return True

? ? else:

? ? ? ? print PayLoadPath + '目錄已經存在'

? ? ? ? return False

if __name__ == '__main__':

? ? des = input("請輸入更新的日志描述:")

? ? bulidIPA()

? ? uploadIPA('%s/Payload.ipa'%packBagPath)

? ? openDownloadUrl()


自動打包上傳步驟.

環(huán)境腳本配置ok -> xcode build app -> 打開終端 執(zhí)行python 自己的python腳本的位置(例如/Users/guanliyuancc/Desktop/自動化打包工具代碼/DaoBaoToPuGY.py)

三、上傳到Fir.im

上傳到fir需要配置fir命令環(huán)境

sudo gem install fir-cli

如下是上傳到fir.im的python代碼

#!/usr/bin/env python

#coding=utf-8

import os

import commands

import requests

import webbrowser

import subprocess

'''

使用注意事項:該腳本基于python2.7

1、將工程的編譯設備選成 Gemeric iOS Device

2、command + B編譯

3、執(zhí)行腳本文件

'''

#(此處需要替換)編譯的app的位置

appFileFullPath = '/Users/guanliyuancc/Desktop/XXX/build/ios/iphoneos/Runner.app'

#(此處需要替換)桌面放臨時生成的playload的位置

PayLoadPath = '/Users/guanliyuancc/Desktop/Payload'

packBagPath = '/Users/guanliyuancc/Desktop/ProgramBag'

#(此處需要替換)fir.im當前app的展示頁

openUrl = 'https://fir.im/apppackage'

#(此處需要替換)上傳到fir.im的token

Fir_token = "XXXXXXd8da4fd56699e72ba7ac26b46"

def openDownloadUrl():

? ? webbrowser.open(openUrl,new=1,autoraise=True)

? ? print "\n*************** 更新成功 *********************\n"

def loginToFirIm():

? ? loginCmd = 'fir login -T %s' %(Fir_token)

? ? process = subprocess.Popen(loginCmd, shell=True)

? ? process.wait()

? ? loginReturnCode = process.returncode

? ? if loginReturnCode != 0:

? ? ? ? print ("login faild")

? ? else:

? ? ? ? print ("login success")

? ? ? ? publishToFirIm('%s/Payload.ipa'%packBagPath)


# publish

def publishToFirIm(IPAPath):

? ? des = input("version desprition:")

? ? publishCmd = 'fir publish %s -c %s'%(IPAPath,des)

? ? process = subprocess.Popen(publishCmd, shell=True)

? ? process.wait()

? ? publishReturnCode = process.returncode

? ? if publishReturnCode != 0:

? ? ? ? print ("publish faild")

? ? else:

? ? ? ? print ("publish success")

? ? ? ? openDownloadUrl()

#編譯打包流程

def bulidIPA():

? ? #打包之前先刪除packBagPath下的文件夾

? ? commands.getoutput('rm -rf %s'%packBagPath)

? ? #創(chuàng)建PayLoad文件夾

? ? mkdir(PayLoadPath)

? ? #將app拷貝到PayLoadPath路徑下

? ? commands.getoutput('cp -r %s %s'%(appFileFullPath,PayLoadPath))

? ? #在桌面上創(chuàng)建packBagPath的文件夾

? ? commands.getoutput('mkdir -p %s'%packBagPath)

? ? #將PayLoadPath文件夾拷貝到packBagPath文件夾下

? ? commands.getoutput('cp -r %s %s'%(PayLoadPath,packBagPath))

? ? #刪除桌面的PayLoadPath文件夾

? ? commands.getoutput('rm -rf %s'%(PayLoadPath))

? ? #切換到當前目錄

? ? os.chdir(packBagPath)

? ? #壓縮packBagPath文件夾下的PayLoadPath文件夾夾

? ? commands.getoutput('zip -r ./Payload.zip .')

? ? print "\n*************** 打包成功 *********************\n"

? ? #將zip文件改名為ipa

? ? commands.getoutput('mv Payload.zip Payload.ipa')

? ? #刪除payLoad文件夾

? ? commands.getoutput('rm -rf ./Payload')

#創(chuàng)建PayLoad文件夾

def mkdir(PayLoadPath):

? ? isExists = os.path.exists(PayLoadPath)

? ? if not isExists:

? ? ? ? os.makedirs(PayLoadPath)

? ? ? ? print PayLoadPath + '創(chuàng)建成功'

? ? ? ? return True

? ? else:

? ? ? ? print PayLoadPath + '目錄已經存在'

? ? ? ? return False

if __name__ == '__main__':

? ? bulidIPA()

? ? loginToFirIm()

自動打包上傳步驟.
環(huán)境腳本配置ok -> xcode build app -> 打開終端 執(zhí)行python 自己的python腳本的位置(例如/Users/guanliyuancc/Desktop/自動化打包工具代碼/DaoBaoToFirIm.py)

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容