Fastlane比赛建立临时和应用商店

时间:2019-01-07 07:17:47

标签: ios xcode fastlane fastlane-match fastlane-gym

我正在使用Fastlane matchgym来构建我的应用程序并将其从CI(比特升)分发到Fabric。如Fastlane docs

中所述,使用AdHoc配置文件将我的Xcode设置设置为使用Release配置的手动设置

现在,我想从CI分发到Appstore,但是失败,因为Xcode Release配置被设置为使用AdHoc配置文件,并且Match安装了AppStore配置文件。

+---------------------------------------------------------------+-----------------------------------------------------------------------------+
|                                                           Summary for gym 2.112.0                                                           |
+---------------------------------------------------------------+-----------------------------------------------------------------------------+
| scheme                                                        | AeroNavMap                                                                  |
| export_method                                                 | app-store                                                                   |
| export_xcargs                                                 | -allowProvisioningUpdates                                                   |
| export_options.provisioningProfiles.net.tequilaapps.airnavmap | match AppStore net.tequilaapps.airnavmap                                    |
| workspace                                                     | ./PEMap.xcworkspace                                                         |
| destination                                                   | generic/platform=iOS                                                        |
| output_name                                                   | AeroNavMap                                                                  |
| build_path                                                    | /Users/vagrant/Library/Developer/Xcode/Archives/2019-01-06                  |
| clean                                                         | false                                                                       |
| output_directory                                              | .                                                                           |
| silent                                                        | false                                                                       |
| skip_package_ipa                                              | false                                                                       |
| result_bundle                                                 | false                                                                       |
| buildlog_path                                                 | /var/folders/90/5stft2v13fb_m_gv3c8x9nwc0000gn/T/fastlane_logs957341986/gym |
| skip_profile_detection                                        | false                                                                       |
| xcode_path                                                    | /Applications/Xcode.app                                                     |
+---------------------------------------------------------------+-----------------------------------------------------------------------------+
[13:47:38]: $ set -o pipefail && xcodebuild -workspace ./PEMap.xcworkspace -scheme AeroNavMap -destination 'generic/platform=iOS' -archivePath /Users/vagrant/Library/Developer/Xcode/Archives/2019-01-06/AeroNavMap\ 2019-01-06\ 13.47.38.xcarchive archive | tee /var/folders/90/5stft2v13fb_m_gv3c8x9nwc0000gn/T/fastlane_logs957341986/gym/AeroNavMap-AeroNavMap.log | xcpretty
[13:47:42]: ▸ ❌  error: No profile for team 'XXXXXXXX' matching 'match AdHoc net.tequilaapps.airnavmap' found: Xcode couldn't find any provisioning profiles matching 'G9MA9G2SST/match AdHoc net.tequilaapps.airnavmap'. Install the profile (by dragging and dropping it onto Xcode's dock item) or select a different one in the General tab of the target editor. (in target 'AeroNavMap')
[13:47:42]: ▸ ** ARCHIVE FAILED *

这一切都说得通,但问题是我应该如何设置Xcode,以便可以拥有两个Fastlane通道,一个用于AppStore构建,另一个用于AdHoc。

可以创建一个新的Xcode配置AppStore,在其中设置AppStore设置配置文件,但这引起了另一个问题,即我的自定义框架无法构建。类似的to this question。我有许多自定义框架,我也需要在其Xcode项目中创建相同的AppStore配置,但这实在是一个骇客解决方案。

我尝试强制gym如下使用AppStore配置文件,但这无济于事。 Xcode中设置的AdHoc配置文件仍在使用。

  desc "Builds the app for the AppStore"
  lane :build_appstore do
      match(type: "appstore", readonly: true)
      build_app(
          scheme: "AeroNavMap",
          export_method: "app-store", 
          skip_profile_detection: true,
          export_options: { provisioningProfiles: { "net.tequilaapps.airnavmap" => "match AppStore net.tequilaapps.airnavmap"}}
          )
  end

我当前的解决方案是在构建之前手动更新xcodeproj,但这也不是很干净

  lane :build_appstore do
      match(type: "appstore", readonly: true)
      if Helper.ci? 
        UI.message "Patching Xcode proj to use AppStore profile"
        `sed -i.bak -e 's/match AdHoc net.tequilaapps.airnavmap/match AppStore net.tequilaapps.airnavmap/g' ../PEMap/PEMap.xcodeproj/project.pbxproj`
      end
      build_app(scheme: "AeroNavMap", export_method: "app-store")
  end

1 个答案:

答案 0 :(得分:0)

存档构建文件时(使用Xcode或Gym)有两个代码签名阶段:构建时使用的代码签名身份(在Xcode中是目标的构建设置中设置的)和导出存档时使用的代码签名身份。 (当您通过Xcode手动导出存档时,您在组织者的导出对话框中选择的那个)

当调用健身房时,我们在Fastfiles中所做的设置都设置为相同的值。我们使用xcargs覆盖构建设置,并在那里使用与export_options中设置的签名相同的签名:

MY_APP_ID = "com.foo.bar"
MY_PROFILE = "match AppStore com.foo.bar"
MY_TEAM = …

match(
    app_identifier: MY_APP_ID,
    type: "appstore",
    readonly: true
)

settings_to_override = {
  :BUNDLE_IDENTIFIER => MY_APP_ID,
  :PROVISIONING_PROFILE_SPECIFIER => MY_PROFILE,
  :DEVELOPMENT_TEAM => MY_TEAM
}

gym(
    workspace: WORKSPACE_PATH,
    scheme: "Foo",
    configuration: "Production",
    xcargs: settings_to_override,
    export_method: "app-store",
    export_options: {
        provisioningProfiles: { 
            MY_APP_ID => MY_PROFILE
        }
    }
)

贷记https://github.com/AliSoftware