Python 調(diào)用 fastlane 自動(dòng)化創(chuàng)建 App

環(huán)境配置

安裝 fastlane (以下操作二選一)

1.1 使用 homebrew 管理(未安裝 homebrew 可以點(diǎn)擊查看如何安裝)

brew install fastlane

1.2 使用 gem 安裝

gem install fastlane

若提示權(quán)限不足

sudo gem install fastlane

物料配置

Apple ID + 密碼 + 此賬號(hào)雙重認(rèn)證驗(yàn)證碼

1 在桌面創(chuàng)建一個(gè)文件夾

我創(chuàng)建了一個(gè)名為 fastlaneTest 的文件夾在桌面

fastlaneTest

2 在終端 CD 到該文件夾目錄下
cd /Users/aken/Desktop/fastlaneTest 
3 初始化 fastlane
fastlane init

image.png

輸入 y

image.png

看見 Continue by pressing Enter 就敲擊回車,不出意外敲擊三次回車就行了。

image.png

Python 示例腳本

有了以上準(zhǔn)備,將腳本中備注需要替換的物料替換成你自己的物料,就可以運(yùn)行腳本了,首次使用腳本會(huì)在終端提示輸入 蘋果開發(fā)者登入密碼 以及雙重驗(yàn)證碼,驗(yàn)證過后,會(huì)在本地存貯一個(gè)月的有效期。

import subprocess
import os

# 賬號(hào),要填的bunld id,app名字
def generate_fastfile(appleid, app_identifier, app_name):
    fastfile_content = f'''
default_platform(:iOS)

platform :iOS do
  lane :create_tb do
    produce(
      username: "{appleid}",
      app_identifier: "{app_identifier}",
      app_name: "{app_name}",
      language: "en-US",
    )
  end
end
'''
    # 替換為你自己桌面文件的絕對(duì)路勁
    with open('/Users/aken/Desktop/fastlaneTest/fastlane/Fastfile', 'w') as file:
        file.write(fastfile_content)
# 執(zhí)行 fastlane
def call_fastlane():
    try:
        # 替換為你自己桌面文件的絕對(duì)路勁
        os.chdir("/Users/aken/Desktop/fastlaneTest")  # 切換到指定路徑
        subprocess.run(['fastlane', 'create_tb'], check=True)
    except subprocess.CalledProcessError as e:
        print(f"Error occurred: {e}")



if __name__ == "__main__":
    # 替換成你的蘋果開發(fā)者賬號(hào)
    appleid = "xxx"
    # 填入你想創(chuàng)建的 bundle id
    app_identifier = "xxx.xxx.xxxx"
    # 你的 app名字
    app_name = "xxxxx"
    # 執(zhí)行文檔腳本
    generate_fastfile(appleid,app_identifier, app_name)
    # 執(zhí)行創(chuàng)建腳本
    call_fastlane()
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容