# Getting started with iOS projects

Developing for iOS is complex - our aim is to make it as easy as possible for you! In this guide, we’ll walk you through how to add an iOS project to Bitrise, how to run Xcode tests, manage your code signing files, and deploy the finished app to [bitrise.io](https://www.bitrise.io/) and to the App Store.

:::tip[Integrating fastlane to Bitrise]

You can run your fastlane lane on Bitrise with the same commands you would use locally. Bitrise’s automated Step provides extra functionality to your lane and speed up your builds: [fastlane](https://github.com/bitrise-io/steps-fastlane).

:::

## Adding an iOS project to Bitrise

Add your project the same way as any other: see [Adding a new project](/bitrise-ci/getting-started/adding-a-new-project) for the full walkthrough of the wizard. This section covers what's specific to iOS.

### How the scanner detects an iOS project

The project scanner looks for `.xcodeproj` files and `.xcworkspace` directories, then checks each one's build settings: if `SDKROOT` is set to `iphoneos` (or `SUPPORTED_PLATFORMS` includes it), the scanner registers the project as iOS. A project that's already a member of a workspace isn't listed separately, since the workspace covers it.

If your repository has no Xcode project or workspace, the scanner falls back to a `Package.swift` file and treats it as a Swift package. It also detects a `Podfile` for CocoaPods and a `Cartfile` for Carthage, and adjusts the generated Workflow to install those dependencies.

### What you can configure

During the **CI configuration** stage, the wizard shows:

- **Project or workspace path**: the `.xcodeproj`, `.xcworkspace`, or `Package.swift` file to build.
- **Scheme name**: any shared scheme found in your project or workspace. The scanner can only detect shared schemes, not user-specific ones.
- **Distribution method**: how Bitrise exports your app, for example App Store, Ad Hoc, Enterprise, or Development. This option isn't shown for Swift packages, since those aren't archived.

## Testing your iOS app

If you have test targets defined, the default Workflows of an iOS project include the two Steps you need to run your Xcode tests, and view their results on [bitrise.io](https://www.bitrise.io/):

- **Xcode Test for iOS**
- **Deploy to Bitrise.io**

The **Xcode Test for iOS** Step runs the pre-defined Xcode tests. It has a default configuration that does not need to be modified: if the tests are written correctly, they will work. You can find the same configuration options in Xcode, too.

:::tip[Checking your selected stack]

We recommend checking that the stack selected for your project has the same Xcode version you used to build the project. For example, if your simulator test fails with the Ineligible destinations for the scheme message, then make sure the Xcode version in the **Stacks & Machines** section is correct. You can read more about our stacks: [Build stacks](/bitrise-build-hub/infrastructure/build-stacks/about-build-stacks).

:::

The Deploy to Bitrise.io Step will deploy the following to the **Logs** and **Artifacts** tab of the build:

- Your Xcode test results.
- Your raw xcodebuildoutput log.

The **Deploy to Bitrise.io** Step also exports the results of the **Xcode Test for iOS** Step to [test reports](/bitrise-ci/testing/test-reports/deploying-test-results).

## Creating a signed IPA for Xcode projects

:::note[Overview on iOS code signing in Bitrise]

For a comprehensive overview on what Steps are available for code signing asset management, visit the [iOS code signing page](/bitrise-ci/code-signing/ios-code-signing/creating-a-signed-ipa-for-xcode-projects).

:::

You can easily create a signed IPA file for your Xcode project with Bitrise.

- You have set up [Apple service connection](/bitrise-platform/integrations/apple-services-connection/about-connecting-to-apple-services) on Bitrise.
- Your [code signing files are managed correctly](/bitrise-ci/code-signing/ios-code-signing/creating-a-signed-ipa-for-xcode-projects).
- You set the relevant inputs of our **Xcode Archive & Export for iOS** Step.

:::important[Upload the distribution AND the development signing certificates]

We strongly recommend uploading BOTH the development and distribution signing certificates for your project. If you don't have an uploaded development signing certificate, Steps with automatic provisioning options will generate one on the fly every time you start a build. This can eventually lead to reaching the maximum number of certificates, blocking you from starting new builds.

:::

If you’re all set, proceed to setting up IPA export in your Workflow.

**Workflow Editor**

1. Make sure the necessary [code signing files have been collected and uploaded](/bitrise-ci/code-signing/ios-code-signing/managing-ios-code-signing-files---automatic-provisioning#uploading-ios-code-signing-certificates-to-bitrise).
1. Make sure you have the **Xcode Archive & Export for iOS** Step in your Workflow.
1. Set the **Distribution method** input of the Step.

   ![xcode-archive.png](/img/_paligo/uuid-fced107c-9b69-e5af-1472-4d96fbada364.png)

   The options are:

   - `app-store`: Choose this if you want to deploy the app to the App Store. Requires a Distribution certificate and an App Store provisioning profile.
   - `ad-hoc`: Choose this if you want to deploy the app to ad-hoc testers. Requires a Distribution certificate and an Ad Hoc provisioning profile.
   - `enterprise`: Choose this if you have an Apple Enterprise account and want to use that to distribute your app.
   - `development`: Choose this for internal testing. Requires a Developer certificate and a Development provisioning profile.
1. Set the **Automatic code signing** input to the Apple service connection you want to use for code signing. The available options are:

   - `off` if you don’t use automatic code signing.
   - `api-key` [if you use API key authorization](/bitrise-platform/integrations/apple-services-connection/about-connecting-to-apple-services).
   - `apple-id` [if you use Apple ID authorization](/bitrise-platform/integrations/apple-services-connection/about-connecting-to-apple-services).
1. Save the Workflow, and start a new build.

**Configuration YAML**

1. Make sure all the [necessary code signing files](/bitrise-ci/code-signing/ios-code-signing/creating-a-signed-ipa-for-xcode-projects) are available for your build.
1. Open the `bitrise.yml` file of your app.
1. Make sure you have the `xcode-archive` Step in your Workflow.

   ```yaml
   my-workflow:
     steps:
     - xcode-archive:
         inputs:
   ```
1. Set the `distribution_method` input to the correct value. The available options are:

   - `app-store`: Choose this if you want to deploy the app to the App Store. Requires a Distribution certificate and an App Store provisioning profile.
   - `ad-hoc`: Choose this if you want to deploy the app to ad-hoc testers. Requires a Distribution certificate and an Ad Hoc provisioning profile.
   - `enterprise`: Choose this if you have an Apple Enterprise account and want to use that to distribute your app.
   - `development`: Choose this for internal testing. Requires a Developer certificate and a Development provisioning profile.

   ```yaml
   my-workflow:
     steps:
     - xcode-archive:
         inputs:
         - distribution_method: development
   ```
1. Set the `automatic_code_signing` input to the Apple service connection you want to use for code signing. The available options are:

   - `off` if you don’t do automatic code signing.
   - `api-key` [if you use API key authorization](/bitrise-platform/integrations/apple-services-connection/about-connecting-to-apple-services).
   - `apple-id` [if you use Apple ID authorization](/bitrise-platform/integrations/apple-services-connection/about-connecting-to-apple-services).

   ```yaml
   my-workflow:
     steps:
     - xcode-archive:
         inputs:
         - automatic_code_signing: api-key
         - distribution_method: development
   ```

That’s all. Xcode will automatically select the right signing files based on your project’s Bundle ID and Team ID settings, and the export method you set.

### Signing an IPA file with a different team’s code signing file

You might want to sign the IPA file with a different team’s code signing files. For example:

- If you use your company’s code signing files for internal builds, but your client’s code signing files are used for App Store distribution.
- If you use Apple ID for automatic code signing and the Apple ID belongs to multiple teams, use The Developer Portal team to use for this export input to specify which team should be used for automatic code signing asset management.

To do so:

1. Make sure the right code signing files of the new development team are uploaded to Bitrise.
1. Set the The Developer Portal team to use for this export option as well (in addition to the **Distribution method**).
1. Set the **Distribution method**.

## Deploying the app to App Store Connect

Keep in mind that every time you want to push an app to App Store Connect, it must have a unique build and version number: [increment either or both](/bitrise-ci/run-and-analyze-builds/build-numbering-and-app-versioning) before deploying.

1. Make sure you have a working [connection to your Apple Developer account](/bitrise-platform/integrations/apple-services-connection/about-connecting-to-apple-services).
1. Generate an IPA file on your own machine at least once.
1. [Upload all necessary code signing files](/bitrise-ci/code-signing/ios-code-signing/creating-a-signed-ipa-for-xcode-projects) to Bitrise.

   To deploy an app to App Store Connect, you need a Distribution type certificate and an App Store type provisioning profile.
1. Make sure the **Xcode Archive & Export for iOS** Step is in your Workflow.
1. Set the **Automatic code signing** input to the Apple service connection you want to use for code signing. The available options are:

   - `off` if you don’t use automatic code signing, or if you exclusively use Step inputs for Apple service authentication.
   - `api-key` if you use [API key authorization](/bitrise-platform/integrations/apple-services-connection/about-connecting-to-apple-services).
   - `apple-id` if you use [Apple ID authorization](/bitrise-platform/integrations/apple-services-connection/about-connecting-to-apple-services).
1. Set the **Distribution method** input of the Step to `app-store`.

   The Step will store the path of the exported .ipa file in the $BITRISE_IPA_PATH Environment Variable.
1. Add the **Deploy to App Store Connect** Step to your Workflow.
1. Fill the required inputs.

   - Either the app’s Apple ID or its Bundle ID is a required input. One of the two must be provided.
   - If you set the **Submit for Review** to `yes`, the Step will wait for your submission to be processed on App Store Connect and then submit the given version of the app for review.
   - The default value of the **Skip App Version Update** input is `No`. Change it only if you incremented the app version number in another way.
   - If you authenticate with your Apple ID and the account is linked to multiple teams, provide either the **Apple ID: Team ID** or the **Apple ID: Team name** input.
1. Start a build.

If all goes well, your app will be submitted to App Store and you can distribute it via Testflight or via the App Store!
