美文网首页
(Xcode) 使用 Fastlane 自动打包

(Xcode) 使用 Fastlane 自动打包

作者: 布呐呐u | 来源:发表于2024-08-30 14:39 被阅读0次
安装
  • 终端执行如下指令
brew install fastlane
初始化
  • cd 项目根目录,终端执行如下指令
fastlane init
  • 依据提示自行选择下一步操作

  • 随后在项目根目录自动生成 Gemfile 文件,内容如下

source "https://rubygems.org"

gem "fastlane"

gem "cocoapods"

plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
eval_gemfile(plugins_path) if File.exist?(plugins_path)
  • 同时自动生成 fastlane 文件夹,及其子文件
    1)Appfile
    2)Fastfile

通常情况下,通过 Xcode 登录Apple ID,勾选自动管理证书,Appfile 文件无需特殊配置

通常情况下,自动打包,Fastfile 文件配置如下

default_platform(:ios)

platform :ios do
  lane :beta do
      build_app(scheme: "MyApp",
            workspace: "Example.xcworkspace",
            include_bitcode: true)
  end
end

若上传第三方平台(如蒲公英) Fastfile 文件,自定义内容如下

default_platform(:ios)

platform :ios do
  desc "uploaded pgyer"

  lane :dev do

    gym(
        clean:true,
        scheme:"TestScheme",
        configuration:"Debug",
        export_method:"development",
    )
    
    // 蒲公英平台 api_key
    api_key   = "xxxx"

    pgyer(api_key: "#{api_key}")

    sh "./notice.sh"

  end
end

通过 curl 指令发送 Webhook 通知消息

#!/bin/bash
  
# Webhook
WEBHOOK_URL="https://oapi.dingtalk.com/xxxx"
 
# 文本信息
MESSAGE='{
    "msgtype": "markdown",
    "markdown": {
        "title":"发包通知🚀🚀🚀",
        "text":"**春江水暖,本鸭先知** 😊
        \r **iOS 测试包** 
        \r **下载链接** https://www.pgyer.com/xxxx"
    }
}'

# 通过 curl 指令发送 Webhook
curl -H "Content-Type: application/json" -X POST -d "$MESSAGE" "$WEBHOOK_URL"
安装蒲公英插件
  • 终端执行如下指令
fastlane add_plugin pgyer

相关文章

网友评论

      本文标题:(Xcode) 使用 Fastlane 自动打包

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