一倒彰、fastlane自動(dòng)打包
fastlane自動(dòng)打包方式审洞,點(diǎn)擊跳轉(zhuǎn)。
二待讳、 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
'''
使用注意事項(xiàng):該腳本基于python2.7
1痴晦、將工程的編譯設(shè)備選成 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'
#將此處打開的鏈接改為蒲公英對應(yīng)app的鏈接
openUrl = 'https://www.pgyer.com/apptest'
#(此處需要替換)上傳蒲公英的key
USER_KEY = ""
API_KEY = ""
#上傳蒲公英
def uploadIPA(IPAPath):
? ? if(IPAPath==''):
? ? ? ? print "\n*************** 沒有找到對應(yīng)上傳的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))
? ? #切換到當(dāng)前目錄
? ? 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 + '目錄已經(jīng)存在'
? ? ? ? return False
if __name__ == '__main__':
? ? des = input("請輸入更新的日志描述:")
? ? bulidIPA()
? ? uploadIPA('%s/Payload.ipa'%packBagPath)
? ? openDownloadUrl()
自動(dòng)打包上傳步驟.
環(huán)境腳本配置ok -> xcode build app -> 打開終端 執(zhí)行python 自己的python腳本的位置(例如/Users/guanliyuancc/Desktop/自動(dòng)化打包工具代碼/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
'''
使用注意事項(xiàng):該腳本基于python2.7
1、將工程的編譯設(shè)備選成 Gemeric iOS Device
2汁针、command + B編譯
3术辐、執(zhí)行腳本文件
'''
#(此處需要替換)編譯的app的位置
appFileFullPath = '/Users/guanliyuancc/Desktop/XXX/build/ios/iphoneos/Runner.app'
#(此處需要替換)桌面放臨時(shí)生成的playload的位置
PayLoadPath = '/Users/guanliyuancc/Desktop/Payload'
packBagPath = '/Users/guanliyuancc/Desktop/ProgramBag'
#(此處需要替換)fir.im當(dāng)前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))
? ? #切換到當(dāng)前目錄
? ? 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 + '目錄已經(jīng)存在'
? ? ? ? return False
if __name__ == '__main__':
? ? bulidIPA()
? ? loginToFirIm()
自動(dòng)打包上傳步驟.
環(huán)境腳本配置ok -> xcode build app -> 打開終端 執(zhí)行python 自己的python腳本的位置(例如/Users/guanliyuancc/Desktop/自動(dòng)化打包工具代碼/DaoBaoToFirIm.py)