In this blog we explain how to use Bitrise to push iOS builds to the App Store automatically (auto-deploy). First we look at how to get the API key from the Apple App Store and how to connect it to Bitrise. Then we show how to connect your Apple Service to your app's team in Bitrise. In the final step, we add 'auto provision' to your workflow in Bitrise.
Introduction
To set up automatic distribution (auto-deployment) in Bitrise, every build has to be signed correctly with the right provisioning profile. In this guide we explain the steps needed to connect Bitrise to your App Store Connect account, so every build is uploaded automatically. That way, profiles no longer have to be generated and uploaded by hand.
The first two steps of this guide take place in App Store Connect and require the Account Holder or Admin role. If you do not have one of these roles, someone else has to carry out these steps. You can send them this guide and ask them to complete steps 1 and 2. At the end of step 2, certain information needs to be collected. These steps describe clearly what is needed to set up the configuration in Bitrise later. For that, you need the following:
- API key file (this is a .p8 file)
- Issuer ID
- Key ID
If someone else carries out steps 1 and 2, make sure they send you these three items.
1. Request access to the App Store Connect API
First, we need to request access to the App Store Connect API. This can be done by a user with the Account Holder role. If you have this role, you can request access with the following steps:
- Go to App Store Connect and log in.
- Select Users and Access.
- Next to the title, select the Keys tab.
- Click the Request Access button.

- You will receive an email once the request has been approved. You can only continue after approval. The email looks roughly like this:

2. Generate an API key in App Store Connect
Once access to the App Store Connect API has been approved, we need to generate an API key. Only a user with the Admin role can do this. If you have this role, follow these steps:
- Go to App Store Connect and log in.
- Select Users and Access.
- Next to the title, select the Keys tab.
- Click the Generate API Key button.

- Name the key
Bitrise, select the Admin role under Access and click Generate. - Once the API key has been generated, select Download API Key and save the
.p8file somewhere safe. You will need this file in Bitrise later.

- Above the generated key you will see the Issuer ID. Click the Copy button next to it to copy the value. You will need to enter this value in Bitrise later.
- Next to the Key ID, click the Copy Key ID button to copy the value. You will also need to enter this value in Bitrise later.
3. Connect an Apple Service account in Bitrise
Now that the key has been generated and downloaded, we can use it in Bitrise to connect our Apple account to our Bitrise account. Take the following steps:
- Go to Bitrise and log in.
- Select View Dashboard.
- Click your profile in the top right corner to open the dropdown menu and select Account Settings.

- Select Apple Service Connection in the menu on the left (under CONNECTED ACCOUNTS).

- Click the Add connection button.
- Enter a name in the pop-up (we recommend using the name of your Apple Developer organisation here).
- Under Issuer ID, paste the issuer ID you copied from App Store Connect.
- Under Key ID, paste the key ID you copied from App Store Connect.
- Finally, select the Upload a Private Key (.p8) button and find the file you downloaded earlier.
- When everything is set, click the Connect button to save your connection.

4. Add the Apple Service connection to your app's team in Bitrise
Once the Apple Service Connection has been created, it still needs to be added to your app's team. You have to do this for each app separately:
- Open the app you want to add the connection to (via the dashboard or the Search for app... search bar in the top left corner).
- Once you have opened the app, select the Team tab.

- Scroll all the way down to Apple Service connection and select Connection not set under API key authentication (recommended). A dropdown menu with all your connections now appears.
- Select the connection you created in the previous step.

- That's it! The changes have been saved automatically.
5. Add iOS Auto Provision to your workflow in Bitrise
Now that the Apple Service connection is set up and linked to our team, we can use it to provision our apps automatically (auto provision) during our workflow:
- Open the right app.
- Select the Workflow tab to open the workflow editor.

- In the editor, click the + button anywhere in your flow to add a new step. Make sure you add this step above any step that builds your app (for example above Export Archive & Export for iOS).

- The step picker opens. Type
iOS Auto Provisionin the search bar to filter the results and select iOS Auto Provision with App Store Connect API (do not choose the Apple ID option). - In the editor of the step you just created, we only need to change one thing. Scroll down until you see Distribution type (Required). The text field probably says
development. We need to change this. Click the Insert variable button on the right of this section.

- In the pop-up that opens, select $BITRISE_EXPORT_METHOD. You can filter the results by typing in the search bar. Selecting this makes sure the export method is always taken from the environment variables, so you can change it without having to edit the workflow itself.
- Remove any other profiling steps from your workflow. You probably have a step called Certificate and profile installer. Click this step to open the editor and click the bin icon to remove it.

- Last but not least: make sure you save the changes. Do this by clicking the button in the top right corner or use the shortcut CMD + S (on a Mac).

.avif)




