Fastlane cannot find provisioning profile on Bitrise
Asked Answered
I

2

7

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?

Impellent answered 4/2, 2018 at 13:42 Comment(4)
Having the same issue: working locally but getting this issue on Bitrise. Did you manage to solve it in the end? – Daunt
No, I gave up.. – Impellent
For me, adding a pod update, and disabling xcode managing signing automatically made it work. – Daunt
Finally found the problem with fastlane and profile: Create a profile with a name that does not have any space like 'xxx_Adhoc' – Reynalda
K
3

Part 1: Resolving this and understanding what is happening

In order to reproduce locally / resolve this, I would suggest to disable automatic signing. This way, you will be much closer to your CI/CD configuration. You might locally have access to certificates that allow you to make it work locally. Disabling automatic code signing will show you exactly which certificates your XCode is using. In order to achieve that, you can use the disable_automatic_code_signing command.

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

Once this is done, you can go in your local XCode see what profile it is using. This is the first step. I would also suggest to remove all local provisioning profiles from your library. (Much more Closer to Bitrise configuration that does not have any loaded profiles once you start a flow). The following commands will achieve that:

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

Once this is done, it is very likely that it will not allow you to export an archive using the target (and configuration) you want. Hopefully, it will fail locally the same way it is failing remotely. From then you can go in your XCode to see the different provisioning profiles that were downloaded with match and figure out why it is not able to automatically resolve it.

Part 2: an educated guess on what is happening and how to resolve it

My suspicion is that you are trying to code sign with an iPhone Developer code sign identity but the match command you are using retrieves a distribution certificate (iOS Distribution signing identity). Using automatic signing, XCode is looking for provisioning profiles that match your target and configuration. It attempts to find an iOS Developer certificate, but this is not what you are fetching using match.

A simple solution to this problem (if this is the problem) would be to change the sign identity method before and after you build_app. You can achieve it like this:

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

Or directly inside your build_app / gym with the code_sign_identity parameter:

build_app(
    workspace: "Myapp.xcworkspace",
    scheme: "Myapp",
    configuration: "Debug",
    codesigning_identity: "iPhone Distribution" # or iPhone Developer
)
Kobi answered 13/2, 2019 at 13:48 Comment(0)
P
1

Since you are using Bitrise, why not use their integrations which can take care of code signing and deployment automatically? I recently moved from Fastlane steps to Bitrise steps. See my answer here: https://mcmap.net/q/1625889/-store-bitrise-provisioning-profiles-in-the-git-repository

Perdition answered 24/3, 2020 at 17:53 Comment(0)

© 2022 - 2024 β€” McMap. All rights reserved.