fastlane iOS打包 安装与使用

1、安装 fastlane

sudo gem install fastlane

或者

brew install fastlane

 

2、进入工程目录下 终端输入 fastlane init 接着输入3 然后control + c退出 接着编写 Fastfile文件

【钉钉】 Fastfile文件

default_platform(:ios)

platform :ios do
  desc "Description of what the lane does"
  lane :custom_lane do
    # add actions here: https://docs.fastlane.tools/actions
  end

  lane :fir do 
    time = Time.new.strftime("%Y%m%d") #获取时间格式
    version = "1.0.0"#获取版本号
    ipaName = "Debug#{version}_#{time}.ipa"
     gym(
       scheme:"QingTeng", #项目名称
       # export_method:"app-store",#打包的类型  ad-hoc
       export_method:"ad-hoc",#打包的类型  
       configuration:"Debug",#模式,默认Release,还有Debug 
       output_name:"#{ipaName}",#输出的包名
       output_directory:"~/Desktop/Ipa",#输出的位置
       # clean: true,
       # include_symbols:false,
       # include_bitcode:false
     )
    firim(firim_api_token: "fir的token",app_changelog:"版本更新")
    din
  end

  lane :din do
  dingTalk_url = "https://oapi.dingtalk.com/robot/send?access_token=钉钉的token"
  markdown = {"at": {
        "atMobiles":[
            "要at的人的电话","要at的人的电话"
        ],"isAtAll": false},"msgtype": "text","text": {"content":"iOS已更新 可以加更新地址等信息"}} 

  uri = URI.parse(dingTalk_url)
  https = Net::HTTP.new(uri.host, uri.port)
  https.use_ssl = true
  request = Net::HTTP::Post.new(uri.request_uri)
  request.add_field('Content-Type', 'application/json')
  request.body = markdown.to_json
  response = https.request(request)

  end
end

飞书-【优化版】

default_platform(:ios)

platform :ios do
  desc "Description of what the lane does"
  lane :custom_lane do
    # add actions here: https://docs.fastlane.tools/actions
  end
  
  lane :pg do |options|
    time = Time.new.strftime("%Y%m%d") #获取时间格式
    version = "1.0.0"#获取版本号
    ipaName = "Debug#{version}_#{time}.ipa"
     gym(
       scheme:"Lilycash", #项目名称
       # export_method:"app-store",#打包的类型  ad-hoc
       export_method:"ad-hoc",#打包的类型  
       configuration:"Debug",#模式,默认Release,还有Debug 
       output_name:"#{ipaName}",#输出的包名
       output_directory:"~/Desktop/Ipa",#输出的位置
       # clean: true,
       # include_symbols:false,
       # include_bitcode:false
     )

   pgyer(api_key: "蒲公英key", update_description: options[:desc])
   fs options
  end

  lane :fs do |options|
     dingTalk_url = "飞书自定义机器人地址"
  markdown = {
        "msg_type": "post",
        "content": {
                "post": {
                        "zh_cn": {
                                "title": "安装包更新通知",
                                "content": [
                                        [{
                                                        "tag": "text",
                                                        "text": options[:desc]
                                                },
                                                {
                                                        "tag": "a",
                                                        "text": "下载地址",
                                                        "href": "https://www.pgyer.com/****"
                                                }
                                        ]
                                ]
                        }
                }
        }
}

  uri = URI.parse(dingTalk_url)
  https = Net::HTTP.new(uri.host, uri.port)
  https.use_ssl = true
  request = Net::HTTP::Post.new(uri.request_uri)
  request.add_field('Content-Type', 'application/json')
  request.body = markdown.to_json
  response = https.request(request)
  end
end

 

4、安装蒲公英或者fir插件

fastlane add_plugin pgyer
fastlane add_plugin firim

5、最后终端输入 fastlane fir 即可进行打包上传到fir 并通知到钉钉

 飞书使用  【fastlane fs desc:更新了***】

posted @ 2022-02-09 15:10  ZhangShengjie  阅读(311)  评论(0编辑  收藏  举报