AdHoc 和 Appstore 使用 Fastlane 匹配构建

问题描述

我希望能够为 adhoc 进行 Firebase distribution 构建,并为 TestFlight/AppStore 进行 appstore 构建。我也在使用 CI/CD 系统 (CircleCI)。我使用 Fastlane match 进行构建签名。我的问题是,当进行不同类型的构建时,如何在不同类型的证书之间进行切换?

我的想法是在 Xcode 中设置调试配置临时签名证书,以及发布配置应用商店证书。但是,当我测试这种方法时,结果发现 adhoc 构建在应用启动后立即崩溃,所以看起来这种方法是不正确的。

enter image description here

这是我的 Fastfile:

platform :ios do
  before_all do
    setup_circle_ci
  end

  desc "Runs tests and build the app "
  lane :testandbuild do |options|
     commit = last_git_commit
     # Uncomment the line if you want to increment build number  
     # increment_build_number(xcodeproj: "MyApp.xcodeproj")
     scan(
        scheme: "MyApp"
    )
    if(options[:branch] == "main")
      increment_build_number
      keyFilePath = File.join(Dir.pwd,"appStoreKey.p8")
      app_store_connect_api_key(
        key_id: options[:key_id],issuer_id: options[:issuer_id],key_filepath: keyFilePath,# duration: 1200,in_house: false,)
      match(type: "appstore",readonly: "false")
      build_app(
          scheme: "MyApp",configuration: "Release"
      )
      upload_to_testflight(
        skip_waiting_for_build_processing: true
      )
    else
       match(type: "adhoc")
       gym(export_method: "ad-hoc",scheme: "MyApp",configuration: "Debug",output_directory: "../output")
       firebase_app_distribution(
               groups: 'dev-team',release_notes: "Branch: #{options[:branch]}. Message: #{commit[:message]}",firebase_cli_token: options[:firebase_cli_token]
       )
    end       
  end
end

解决方法

我在健身房使用类似以下的东西。

gym(
    workspace: xcodeworkspace,scheme: environment,configuration: environment,silent: true,clean: true,export_method: "ad-hoc",export_options: {
        provisioningProfiles: { 
            app_identifier => app_profile_name,balance_widget_identifier => balance_widget_profile_name
        }
    }
)

这样我也可以为“今天的扩展”定义不同的配置文件(针对不同的构建)。

,

我在我添加的 gym 中找到了解决方案
xcargs: "PROVISIONING_PROFILE_SPECIFIER='match AdHoc myapp.com'" 对于 adhoc 构建和 appStore 构建,我添加了 xcargs: "PROVISIONING_PROFILE_SPECIFIER='match AppStore myapp.com'"

我删除了 AdHoc 构建 configuration: "Debug"