# Xcode Cloud

Source: https://help.testapp.io/xcode-cloud/

**Upload the IPA to TestApp.io from Xcode Cloud**

This guide provides steps to upload your iOS application's IPA file to TestApp.io using a post-build script in Xcode Cloud.

## Prerequisites

Before you begin, ensure you have the following TestApp.io environment variables:

- `TESTAPPIO_APP_ID`
- `TESTAPPIO_API_TOKEN`

These values can be found in your TestApp.io portal: the API token at [Profile -> API Tokens](https://portal.testapp.io/profile/tokens), and the App ID under [App -> Integrations -> Releases](https://portal.testapp.io/apps).

![Environment variables for TestApp.io inside Xcode Cloud workflow](https://f000.backblazeb2.com/file/help-testappio/2024/01/image_o.png)

## TA-CLI Configuration

For detailed information on TA-CLI parameters, refer to the [TestApp.io CLI documentation](https://help.testapp.io/ta-cli). Adjust the script parameters like `--git_release_notes`, `--git_commit_id`, `--notify`, etc., as required for your setup.

## Script Setup

Create a directory named `ci_scripts` at the root of your project.

Inside `ci_scripts`, create a file named `ci_post_xcodebuild.sh`.

Copy and paste the following script into `ci_post_xcodebuild.sh`:

```sh
if [ "$CI_PRODUCT_PLATFORM" = "iOS" ]; then
    echo "Uploading to TestApp.io"

    # Set the install directory
    export INSTALL_DIR=$(pwd)

    # Download and install TestApp.io CLI
    curl -Ls https://github.com/testappio/cli/releases/latest/download/install | bash

    # Make the CLI executable
    chmod +x ${INSTALL_DIR}/ta-cli

    # Find the .ipa file in the specified directory
    IPA_FILE=$(find "$CI_AD_HOC_SIGNED_APP_PATH" -name "*.ipa" -print -quit)

    # Check if an .ipa file was found
    if [ -z "$IPA_FILE" ]; then
        echo "No .ipa file found in $CI_AD_HOC_SIGNED_APP_PATH"
        exit 1
    fi

    # Publish using the found .ipa file
    ${INSTALL_DIR}/ta-cli publish --api_token=$TESTAPPIO_API_TOKEN --app_id=$TESTAPPIO_APP_ID --release="ios" --ipa="$IPA_FILE" --git_release_notes=true --git_commit_id=true --archive_latest_release=false --notify=true --source="Xcode Cloud"
fi
```

Ensure the script is executable by running `chmod +x ci_scripts/ci_post_xcodebuild.sh` in your project directory.

## Usage

After setting up the script, it will automatically execute in Xcode Cloud's post-build phase for iOS platform builds, uploading the IPA to TestApp.io.

![Xcode Cloud post script](https://f000.backblazeb2.com/file/help-testappio/2024/01/Screenshot-2024-01-04-at-6.18.09-PM_o.png)

> **Tip:** Once your CI/CD pipeline uploads a build, team members using the [TestApp.io mobile app](https://help.testapp.io/mobile-app-getting-started/) receive a push notification and can install the build with a single tap. You can also create [share links](https://help.testapp.io/how-to-share/) to distribute builds to external testers and clients.

---

Need help? [Contact us](https://testapp.io/contact-us/). we're happy to assist!
