美文网首页
Python 调用 fastlane 自动化创建 App

Python 调用 fastlane 自动化创建 App

作者: 试图与自己和解 | 来源:发表于2024-04-24 18:18 被阅读0次

环境配置

安装 fastlane (以下操作二选一)

1.1 使用 homebrew 管理(未安装 homebrew 可以点击查看如何安装)

brew install fastlane

1.2 使用 gem 安装

gem install fastlane

若提示权限不足

sudo gem install fastlane

物料配置

Apple ID + 密码 + 此账号双重认证验证码

1 在桌面创建一个文件夹

我创建了一个名为 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 示例脚本

有了以上准备,将脚本中备注需要替换的物料替换成你自己的物料,就可以运行脚本了,首次使用脚本会在终端提示输入 苹果开发者登入密码 以及双重验证码,验证过后,会在本地存贮一个月的有效期。

import subprocess
import os

# 账号,要填的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
'''
    # 替换为你自己桌面文件的绝对路劲
    with open('/Users/aken/Desktop/fastlaneTest/fastlane/Fastfile', 'w') as file:
        file.write(fastfile_content)
# 执行 fastlane
def call_fastlane():
    try:
        # 替换为你自己桌面文件的绝对路劲
        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__":
    # 替换成你的苹果开发者账号
    appleid = "xxx"
    # 填入你想创建的 bundle id
    app_identifier = "xxx.xxx.xxxx"
    # 你的 app名字
    app_name = "xxxxx"
    # 执行文档脚本
    generate_fastfile(appleid,app_identifier, app_name)
    # 执行创建脚本
    call_fastlane()

相关文章

网友评论

      本文标题:Python 调用 fastlane 自动化创建 App

      本文链接:https://www.haomeiwen.com/subject/zqjgxjtx.html