如何使用 fastlane 将我的 iOS 应用程序编译成 .xcarchive,然后单独签名并制作 IPA?

How do I use fastlane to compile my iOS app into an .xcarchive, then separately sign and make an IPA?

我正在为客户制作 iOS 应用程序,但无权访问他们的配置文件或签名证书。

我想给我的客户一个已经编译好的应用程序版本,这样他们所需要做的就是对其进行签名,然后将其上传到 TestFlight 和 App Store。

之前我给我的客户提供了整个 .xcodeproj,在本例中是从 Unity 游戏中导出的,但是他们使用不同版本的 Xcode 和使用 CocoaPods 时出现问题在另一台机器上。

by exporting my iOS app to an .xcarchive without any provisioning profiles or signing certificates, then give them the .xcarchive and have them sign it, make an .ipa,并将其上传到 App Store。我目前正在使用 fastlane 进行自动化构建,并希望继续使用这个新解决方案。

您可以在 fastlane 中使用以下内容导出 MyArchiveName.xcarchive

  build_app(
    configuration: "Release",
    project: "Path/To/My.xcodeproj",
    export_method: "app-store",
    export_options: {iCloudContainerEnvironment: "Production"},
    skip_codesigning: true,
    skip_package_ipa: true,
    archive_path: "MyArchiveName.xcarchive"
 )

然后你可以拿 MyArchiveName.xcarchive 给你的客户,然后他们可以 运行 在 fastlane 中进行以下构建:

lane :sign_xcarchive_and_publish do
  default_platform(:ios)
  sync_code_signing(
    type: "appstore"
  )

  # You must create a fake xcodeproj to pass in.
  # This is needed to work around this issue in fastlane: https://github.com/fastlane/fastlane/issues/13528
  # See also: https://github.com/fastlane/fastlane/issues/11402 and https://github.com/fastlane/fastlane/issues/15876
  xcodeproj_path = File.expand_path("../fake.xcodeproj")
  Xcodeproj::Project.new(xcodeproj_path).save

  build_app(
    configuration: "Release",
    project: xcodeproj_path,
    output_name: "MyOutput.ipa",
    export_method: "app-store",
    export_options: { iCloudContainerEnvironment: "Production" },
    export_team_id: CredentialsManager::AppfileConfig.try_fetch_value(:team_id), # This requires the team_id to be set in the fastlane `Appfile`
    skip_build_archive: true,
    skip_package_dependencies_resolution: true,
    archive_path: "MyArchiveName.xcarchive"
 )

  upload_to_testflight(
    skip_submission: true,
    skip_waiting_for_build_processing: true
  )
end

请注意,您需要验证插件是否已正确构建和签名。我还没有遇到问题,但可能会遇到更复杂的构建。另请注意,这仅适用于客户端直接上传到应用商店,我没有尝试过任何其他类型的签名。