# iOS Build and Release Guide - TorqueVaultKMP This document provides step-by-step instructions to set up the environment and release the iOS application from a Kotlin Multiplatform (KMP) project to the App Store. ## 1. Environment Setup on macOS ### Setup JDK 17 The project requires JDK 17 to run Gradle tasks and build the iOS framework. 1. **Check current Java version:** ```bash java -version ``` If it returns `openjdk version "xx.x.x"`, you can skip to **Install Xcode**. 2. **Install via Homebrew (if not installed):** ```bash brew install openjdk@17 ``` 3. **Configure Environment Variables:** Run the following commands to link the JDK and update your `.zshrc`: ```bash sudo ln -sfn /opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-17.jdk echo 'export PATH="/opt/homebrew/opt/openjdk@17/bin:$PATH"' >> ~/.zshrc echo 'export JAVA_HOME=$(/usr/libexec/java_home -v 17)' >> ~/.zshrc source ~/.zshrc ``` ### Setup Xcode 1. **Check if Xcode is installed:** Ensure you have the latest version of Xcode from the App Store. 2. **Check Command Line Tools:** ```bash xcode-select -p ``` If it returns a path, tools are installed. Otherwise, run: `xcode-select --install`. ## 2. Xcode Project Configuration 1. **Open the Project:** Open `/iosApp/iosApp.xcodeproj` in Xcode. 2. **Setup Signing & Capabilities:** - Select the **iosApp** project in the Project Navigator. - Go to the **Signing & Capabilities** tab. - Select your **Team** (Apple Developer Account). - Verify the **Bundle Identifier** (must match the ID registered in App Store Connect, e.g., `com.digitoolsolutions.app.torquevaultkmp`). 3. **Update Version and Build:** - In the **General** tab, update: - **Version**: e.g., `1.0.2` (Should match `versionName` in `composeApp/build.gradle.kts`). - **Build**: e.g., `2` (Should match `versionCode` in `composeApp/build.gradle.kts` and must be incremented for each upload). --- ## 3. Build and Upload Process ### Step 1: Clean Project Before building the release version, perform a clean directly in Xcode to avoid cache issues: - Go to **Product** -> **Clean Build Folder** (or press `Shift + Command + K`). - *Note: This will also trigger a clean for the Kotlin framework if configured in the build script.* ### Step 2: Create Archive in Xcode 1. In Xcode, select the build target as **Any iOS Device (arm64)** from the toolbar. 2. Go to **Product** -> **Archive**. 3. Xcode will start building. The Kotlin framework (`ComposeApp`) will be automatically compiled via the Gradle build phase script. ### Step 3: Upload to App Store Connect 1. Once the Archive is complete, the **Organizer** window will appear. 2. Select the latest build and click **Distribute App**. 3. Choose **App Store Connect** and then **Upload**. 4. Follow the prompts (Validate, Re-sign). 5. Wait for the success notification. --- ## 4. App Store Connect Management 1. Log in to [App Store Connect](https://appstoreconnect.apple.com/). 2. Select your app **TorqueVault**. 3. Check the build status in the **TestFlight** tab to ensure it has finished processing. 4. When ready, go back to the **App Store** tab, select the build, and click **Submit for Review**. ## Important Notes - **Framework Name**: The main framework is named `ComposeApp`. If you change `baseName` in `build.gradle.kts`, you must update the Xcode configuration accordingly. - **Permissions**: Ensure all required permissions (Bluetooth, Camera, etc.) are declared in `Info.plist`. - **Dependencies**: If the project uses native libraries via CocoaPods or Swift Package Manager, ensure they are correctly installed before building.