Conditionally utilize different Xcode provisioning profiles

Conditionally Deploy by Branch

You may want a build on a specific branch to deploy to the App Store, while all other branches deploy as ad-hoc. This can be accomplished with Fastlane and setting specific profiles using PROVISIONING_PROFILE_SPECIFIER.

Fastlane setup

Then you can adjust your Fastfile to have an if/else conditional like the following:

# fastlane/Fastfile
default_platform(:ios)

platform :ios do
  before_all do
    setup_circle_ci
  end

  desc "Runs tests and build the app"
  lane :testandbuild do |options|
    if(options[:branch] == "main")
      match(type: "appstore", readonly: "false")
      build_app
    else
       match(type: "adhoc")
       gym(export_method: "ad-hoc")
    end       
  end
end

Beyond the above you will also need to specify the PROVISIONING_PROFILE_SPECIFIER, information on that here:

https://docs.fastlane.tools/codesigning/xcode-project/#build-settings

Once the above is done it is just a matter of passing in the branch as an option to your Fastlane run command. Like the following:

- run: bundle exec fastlane ios testandbuild branch:${CIRCLE_BRANCH}
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Article is closed for comments.