5

I'm building an iOS app locally using Fastlane, without any problems.

I'm using match with a separate repo, to keep track of certificates and provisioning profiles.

Locally it works fine.

On Bitrise, however, I get this error:

[05:23:16]: All required keys, certificates and provisioning profiles are installed 
[05:23:16]: Setting Provisioning Profile type to 'app-store'
[05:23:16]: -----------------------
[05:23:16]: --- Step: build_app ---
[05:23:16]: -----------------------
[05:23:16]: $ xcodebuild -list -workspace Myapp.xcworkspace -configuration Debug
[05:23:17]: $ xcodebuild -showBuildSettings -workspace Myapp.xcworkspace -scheme Myapp -configuration Debug
[05:23:20]: Couldn't automatically detect the provisioning profile mapping
[05:23:20]: Since Xcode 9 you need to provide an explicit mapping of what
[05:23:20]: provisioning profile to use for each target of your app
[05:23:20]: No such file or directory @ rb_sysopen - /Users/vagrant/git/Pods/Target Support Files/Pods-Myapp/Pods-Myapp.debug.xcconfig
[05:23:20]: Detected provisioning profile mapping: {:"com.myapp.myapp"=>"match AppStore com.myapp.myapp"}

I tried explicitly mapping the provisioning profile in my Fastfile:

lane :beta do
    clear_derived_data
    increment_build_number
    match(app_identifier: "com.myapp.myapp", type: "appstore", clone_branch_directly: true)
    build_app(
        workspace: "Myapp.xcworkspace",
        scheme: "Myapp",
        configuration: "Debug",
        export_options: {
            method: "app-store",
            provisioningProfiles: { 
                "com.myapp.myapp" => "match AppStore com.myapp.myapp"
            }
        }
    )
    upload_to_testflight(skip_waiting_for_build_processing: true)
end

Any idea what I need to resolve this?

4

2 回答 2

2

第 1 部分:解决此问题并了解正在发生的事情

为了在本地重现/解决此问题,我建议禁用自动签名。这样,您将更接近 CI/CD 配置。您可能在本地有权访问允许您使其在本地工作的证书。禁用自动代码签名将准确显示您的 XCode 正在使用哪些证书。为了实现这一点,您可以使用disable_automatic_code_signing命令。

disable_automatic_code_signing(
    path: "demo-project/demo/demo.xcodeproj"
)

完成此操作后,您可以进入本地 XCode 查看它使用的配置文件。这是第一步。我还建议从您的库中删除所有本地配置文件。(更接近于 Bitrise 配置,一旦您开始流程,就没有任何加载的配置文件)。以下命令将实现:

cd ~/Library/MobileDevice/Provisioning\ Profiles
rm -fr *

完成此操作后,很可能不允许您使用所需的目标(和配置)导出存档。希望它会像远程失败一样在本地失败。从那时起,您可以进入您的 XCode 以查看与match一起下载的不同配置文件,并找出它无法自动解决它的原因。

第 2 部分:对正在发生的事情以及如何解决它的有根据的猜测

我怀疑您正在尝试使用 iPhone 开发人员代码签名身份进行代码签名,但您使用的 match 命令检索分发证书(iOS 分发签名身份)。使用自动签名,XCode 正在寻找与您的目标和配置相匹配的配置文件。它尝试查找 iOS 开发人员证书,但这不是您使用match获取的内容。

这个问题的一个简单解决方案(如果这是问题)是在 build_app 之前和之后更改签名标识方法。你可以像这样实现它:

automatic_code_signing(
    path: "demo.xcodeproj",
    code_sign_identity: "iPhone Distribution"
)

或者直接在 build_app / gym 中使用 code_sign_identity 参数:

build_app(
    workspace: "Myapp.xcworkspace",
    scheme: "Myapp",
    configuration: "Debug",
    codesigning_identity: "iPhone Distribution" # or iPhone Developer
)
于 2019-02-13T13:48:41.257 回答
0

既然您使用的是 Bitrise,为什么不使用可以自动处理代码签名和部署的集成呢?我最近从 Fastlane 步骤转移到了 Bitrise 步骤。在这里查看我的答案:https ://stackoverflow.com/a/60836343/1271474

于 2020-03-24T17:53:27.633 回答