Search code examples
xcodecode-signingprovisioning-profilefastlane

Fastlane retrieve provisioning profile path from identifier


Is there any fastlane/CLI tool that you can find the path and name of a provisioning profile, based on the UDID?


I am trying to set up fastlane to do the code signing. I am using match, but it's not working for my use case, because the provisioning profile needs to be changed.

I have 2 lanes, both using RELEASE configuration:

  • submit_app_store, with match App Store profile, to upload a Release build to Test Flight
  • deploy_qa_prod, with match AdHoc profile, to upload a Release build to our QA platform

I am trying to call update_project_provisioning, but I need to give it a path to the profile and I only have the specifier of the provisioning profiles, like match AdHoc APP_ID.

I would like a command that transforms this specifier into a path.


Fastlane code:

lane :deploy_qa_prod do
  configuration = "Release"
  app_identifier = ...
  provisioning_profile = "match AdHoc #{app_identifier}"
  # In the other lane: provisioning_profile = "match AppStore #{app_identifier}"

  sync_code_signing(
    type: "adhoc",
    app_identifier: app_identifier,
    readonly: true
  )

  update_project_provisioning(
     xcodeproj: ...,
     target_filter: ...,
     # profile: provisioning_profile, <--- This is the problematic line
     build_configuration: configuration
  )

  build_app(
     scheme: ...,
     workspace: ...,
     configuration: configuration
     export_options: {
       method: "ad-hoc",
       provisioningProfiles: {
         app_identifier => provisioning_profile
       }
     }
   )

   pilot(......)
   # In the other lane: upload_to_qa(......)

Solution

  • Recommended solution:

    I moved away from using only DEBUG and RELEASE configurations.

    Instead, I defined 5 different configurations:

    • Develop (Beta)
    • Develop (Prod)
    • AdHoc (Beta)
    • AdHoc (Prod) *
    • AppStore (Prod) *

    * My original RELEASE configurations, when posting this question.

    This way, I can have separate certificate and provisioning profiles defined for each configuration, and I no longer need to change them from fastlane.

    If you defined some User-Defined properties in Build Settings, avoid duplicating them 5 times by using .xcconfig files. You can read more about them here for example.


    Hacky solution, directly answering my question

    I do not recommend doing this, and instead go with separate configurations. But if you need a temporary quick fix, then:

    Unfortunately (or fortunately), there's no non-hacky way of doing this.

    What I noticed is that the sync_code_signing (aka match) calls sigh under the hood, which will create environmental variables for the downloaded provisioning profiles.

    The name of these variables follows the following format: sigh_#{app_identifier}_#{match_type}_profile-path (Ex: sigh_com.yourDomain.yourAppName_adhoc_profile-path)

    You can then use this variable when you call update_project_provisioning:

        app_identifier = ...
        match_type = "adhoc"
        configuration = "Release"
    
        sync_code_signing(
            type: match_type,
            app_identifier: app_identifier,
            readonly: true
        )
    
        profile_path = ENV["sigh_#{app_identifier}_#{match_type}_profile-path"]
     
        update_project_provisioning(
          xcodeproj: ...,
          target_filter: ...,
          profile: profile_path,
          build_configuration: configuration
        )
        
        ...