iOS(Swift) fastlane集成,发送 testfli

2022-03-11  本文已影响0人  简单coder

接上篇: iOS(Swift) fastlane集成,分发蒲公英,fir

fastlane 文件源码


default_platform(:ios)

platform :ios do
  desc "Push a new beta build to TestFlight"
  lane :beta do
    # puts "beta测试"
    increment_build_number(xcodeproj: "quick.xcodeproj")
    puts "************打包开始😊************"
    build_app(
      clean: false,
      scheme: "quick",
      workspace: "quick.xcworkspace", 
      scheme: "quick",
      output_directory: "fastlane/build/test/",
      output_name: "quick.ipa",
      xcargs: [
        "-allowProvisioningUpdates"
      ],
      configuration: "Release",#打包方式1:Debug 2:Test 3:PreRelease 4:Release"
      silent: false,#在构建时隐藏终端不必要输出的信息
      export_method: "app-store", # app-store, ad-hoc, package, enterprise, development, developer-id
      # codesigning_identity: "Apple Distribution: Chongqing Taoqu Network Technology Co., Ltd. (FK4PHF763J)",
    )
    # notification(app_icon:"../quick/Assets/Assets.xcassets/AppIcon.appiconset",title:"发包中",subtitle: "打包成功,已导出安装包>>>>>>>>", message: "准备发布中....")
    puts "************打包结束😊************"

    puts "************上传testflight开始😊************"
    api_key = app_store_connect_api_key(
        key_id: "VF**********66",
        issuer_id: "91be5**********6ae18152",
        key_filepath: "cer/AuthKey_VF2FK5D566.p8",
        duration: 1200, # optional (maximum 1200)
        in_house: false # optional but may be required if using match/sigh
      )

    upload_to_testflight(
      api_key: api_key,
      skip_waiting_for_build_processing: true,
      # username: "1xxxx@163.com",
      # app_identifier: "com.sxx.xxx",
      ipa: "fastlane/build/test/quick.ipa",
      skip_submission:true
     )
    # notification(app_icon:"icon.png",title:"LoanManager",subtitle: "IPA上传成功", message: "自动打包完成!")
    puts "************上传testflight结束😊************"

    puts "************发送钉钉消息开始😊************"
        ipa_path = ENV['FASTLANE_IPA_OUTPUT_PATH']
        version_number = get_ipa_info_plist_value(ipa: ipa_path, key: "CFBundleShortVersionString")#获取 info 属性
        build_number = get_ipa_info_plist_value(ipa: ipa_path, key: "CFBundleVersion")
    branch_name = git_branch
    commit = last_git_commit#提交
    commit_hash = commit[:abbreviated_commit_hash]#提交 hash
    commit_author = commit[:author]#作者
    commit_info = "> last commit hash: #{commit_hash}, author: #{commit_author}"#提交信息
        build_message = "quick_TestFlight(#{branch_name}) \n版本号: #{version_number}.#{build_number}\n testflight 已更新"

    sh("ruby ./dingSuccess.rb '#{build_message}'")
    puts "************发送钉钉消息结束😊************"
    # if a == "222"
    # end
  end

  after_all do |lane|
    
  end

  error do |lane, exception|
    puts "操作失败了"
  end
end

命令参数说明

其实也没啥好说的,稍微要注意下的是,脚本执行完后,会向 ENV 填充参数,比如ipa_path = ENV['FASTLANE_IPA_OUTPUT_PATH'],需要的信息可以从 action 列表中获取,git 操作的信息也可以获取到,如果你是 ci/cd 操作的话,甚至应该做到git pull,increment_build_number增加构建号,pod update,git push,git checkout .等等操作,由于我是本地执行,省去了这些步骤,其实没啥好说的,一点点测试 API 就能慢慢做完,这东西除了基本的知识的话,剩下的就是耐心了.

build_app

upload_to_testflight

成功 dingding 脚本

require "dingbot"

DingBot.endpoint='https://oapi.dingtalk.com/robot/send'
DingBot.access_token = 'd4d823d55b0e0d******************564e0189f7bff6b54ad63f51'
DingBot.secret = "SEC23eb83c18d5fbeb******************1acfbaec0427c96" # sign secret


def send_text
    msg = ARGV[0] || "tf 更新,无更新信息"
    message = DingBot::Message::Text.new(
        msg,
        ['18******************012'],
        false
    )
    DingBot.send_msg(message)
  end
send_text

申请 key



问题1: 描述资源文件冲突

error: QuickKit has conflicting provisioning settings. QuickKit is automatically signed, but code signing identity Apple Distribution: Chongqing Taoqu Network Technology Co., Ltd. (FK4PHF763J) has been manually specified. Set the code signing identity value to "Apple Development" in the build settings editor, or switch to manual signing in the Signing & Capabilities editor. (in target 'QuickKit' from project 'quick')

问题2: 出口合规证明

<key>ITSAppUsesNonExemptEncryption</key>
    <false/>

感谢

iOS+Fastlane自动打包发布到TestFlight

上一篇下一篇

猜你喜欢

热点阅读