### Install Doppler CLI on Windows Source: https://docs.codemagic.io/knowledge-others/import-variables-from-secret-manager Install the Doppler CLI on Windows using Scoop. This involves setting the execution policy, installing Scoop, and adding the Doppler bucket. ```yaml scripts: - name: Install Doppler on Windows script: | Set-ExecutionPolicy RemoteSigned -Scope CurrentUser iex "& {$(irm get.scoop.sh)} -RunAsAdmin" scoop bucket add doppler https://github.com/DopplerHQ/scoop-doppler.git scoop install doppler ``` -------------------------------- ### Creating and Signing an Installer Package Source: https://docs.codemagic.io/yaml/building-a-flutter-app This script creates an unsigned installer package, finds the appropriate signing certificate in the keychain, and then signs the package. ```bash set -x APP_NAME=$(find $(pwd) -name "*.app") cd $(dirname "$APP_NAME") PACKAGE_NAME=$(basename "$APP_NAME" .app).pkg xcrun productbuild --component "$APP_NAME" /Applications/ unsigned.pkg INSTALLER_CERT_NAME=$(keychain list-certificates \ | jq '.[] | select(.common_name | contains("Mac Developer Installer")) | .common_name' | xargs) xcrun productsign --sign "$INSTALLER_CERT_NAME" unsigned.pkg "$PACKAGE_NAME" rm -f unsigned.pkg ``` -------------------------------- ### Install snap package locally Source: https://docs.codemagic.io/yaml-quick-start/building-a-snap-package Command to install a generated `.snap` package on your local machine for testing. Use the `--dangerous` flag if the package is not code signed. ```bash snap install your-package.snap --dangerous ``` -------------------------------- ### Install and Check Version Source: https://docs.codemagic.io/rn-codepush/cli-quick-reference Installs the CodePush CLI globally and checks its version. Ensure you have Node.js and npm installed. ```bash npm install -g @codemagic/code-push-cli code-push --version ``` -------------------------------- ### Install iOS Dependencies with CocoaPods Source: https://docs.codemagic.io/rn-codepush/setup Navigate to the ios directory and run 'pod install' to install native dependencies for CodePush. ```bash cd ios && pod install && cd .. ``` -------------------------------- ### Install Maestro CLI Source: https://docs.codemagic.io/integrations/maestro-integration Install the Maestro CLI on the build machine using a curl command before running Maestro commands. ```yaml scripts: - name: Download Maestro script: curl -Ls "https://get.maestro.mobile.dev" | bash ``` -------------------------------- ### Install Sonar Scanner using Homebrew Source: https://docs.codemagic.io/integrations/sonarcloud-integration Installs the Sonar Scanner CLI tool using Homebrew. Ensure Homebrew is installed and configured in your environment. ```yaml scripts: - name: Install Sonar Scanner script: | brew install sonar-scanner ``` -------------------------------- ### Install Unity Version and Modules on Windows Source: https://docs.codemagic.io/knowledge-others/install-unity-version This script automates the installation of a Unity version and modules on Windows by creating and executing a batch file with Unity Hub CLI commands. ```yaml scripts: - name: Install Unity version script: | New-Item ".\install-unity.bat" #create an empty batch file Set-Content install-unity.bat "`"$env:UNITY_HUB`" -- --headless install -v $env:UNITY_VERSION --changeset $env:UNITY_VERSION_CHANGESET" Add-Content install-unity.bat "`"$env:UNITY_HUB`" -- --headless install-modules --version $env:UNITY_VERSION -m ios android" Start-Process -FilePath ".\install-unity.bat" -Wait -NoNewWindow #start executing the batch file ``` -------------------------------- ### Install Capgo Plugin for Capacitor Source: https://docs.codemagic.io/integrations/capgo-integration Install the Capgo plugin for Capacitor using npm to enable live updates. ```bash npm i @capgo/capacitor-updater ``` -------------------------------- ### Run Fastlane Lane with Bundle Install Source: https://docs.codemagic.io/integrations/fastlane-integration Install project dependencies using 'bundle install' and then execute your Fastlane lane with 'bundle exec fastlane '. This ensures all dependencies are met before running the lane. ```yaml scripts: - name: Run fastlane script: | bundle install bundle exec fastlane beta ``` -------------------------------- ### Windows: Unity Install Older Version Workflow Configuration Source: https://docs.codemagic.io/knowledge-others/install-unity-version Configure a Unity installation workflow on Windows, specifying Unity version and package name. Includes steps for activating Unity license, installing Unity via batch script, and building the Unity project. ```yaml unity-android-workflow: name: Unity Install Older Version Workflow max_build_duration: 120 instance_type: windows_x2 environment: groups: # Add the group environment variables in Codemagic UI (either in Application/Team variables) - https://docs.codemagic.io/variables/environment-variable-groups/ - unity # <-- (Includes UNITY_HOME, UNITY_SERIAL, UNITY_EMAIL and UNITY_PASSWORD) vars: UNITY_VERSION: 2021.3.3f1 UNITY_VERSION_CHANGESET: af2e63e8f9bd BUILD_SCRIPT: BuildAndroid PACKAGE_NAME: "io.codemagic.unity" # <-- Put your package name here e.g. com.domain.myapp android_signing: - unity_test triggering: events: - push branch_patterns: - pattern: "*" include: true cancel_previous_builds: false scripts: - name: Activate Unity License (installed version) script: | cmd.exe /c "$env:$UNITY_HOME/Unity.exe" -batchmode -serial $env:UNITY_SERIAL -username $env:UNITY_EMAIL -password $env:UNITY_PASSWORD -quit -nographics - name: Install Unity version script: | New-Item ".\install-unity.bat" #create an empty batch file Add-Content install-unity.bat "`"C:\ Program Files\Unity Hub\Unity Hub.exe`" -- --headless install -v $env:UNITY_VERSION --changeset $env:UNITY_VERSION_CHANGESET" Add-Content install-unity.bat "`C:\ Program Files\Unity Hub\Unity Hub.exe`" -- --headless install-modules --version $env:UNITY_VERSION -m android android-sdk-ndk-tools android-open-jdk" Start-Process -FilePath ".\install-unity.bat" -Wait -NoNewWindow #start executing the batch file - name: Build Unity Using (installed version) script: | cmd.exe /c "C:\ Program Files\Unity\Hub\Editor\$env:$UNITY_VERSION\Editor\Unity.exe" -batchmode -quit -logFile "$env:CM_BUILD_DIR\android\log.txt" -projectPath . -executeMethod BuildScript.$env:BUILD_SCRIPT -nographics artifacts: - android/*.aab - android/*.apk - android/*.txt publishing: scripts: - name: Deactivate new Unity License using a Command Prompt script: | cmd.exe /c "C:\ Program Files\Unity\Hub\Editor\$env:$UNITY_VERSION\Editor\Unity.exe" -batchmode -quit -returnlicense -nographics ``` -------------------------------- ### Install Re.Pack Plugin for Rock Source: https://docs.codemagic.io/integrations/rock-integration Install the Re.Pack plugin to enable Module Federation-based Super App and microfrontend architectures. No changes to `codemagic.yaml` are required. ```bash npm install @rock-js/plugin-repack ``` -------------------------------- ### Codemagic.yaml Workflow for Emerge Integration Source: https://docs.codemagic.io/integrations/emerge-integration Example Codemagic.yaml configuration to build an iOS IPA and upload it to Emerge Tools. Includes steps for bundle installation, Fastlane plugin setup, IPA building, and uploading. ```yaml scripts: - name: Bundle install script: | bundle install - name: Install Emerge Tools Fastlane plugin script: | fastlane add_plugin emerge - name: Build ipa for distribution script: | xcode-project build-ipa --project "$XCODE_PROJECT" --scheme "$XCODE_SCHEME" - name: Upload archive to Emerge Tools script: | bundle exec fastlane emerge_app_upload ``` -------------------------------- ### Example settings.json file Source: https://docs.codemagic.io/knowledge-others/dart-define-from-file-secrets Define your application configuration variables in a JSON format. ```json { "value_one": "abc", "value_two": "xyz" } ``` -------------------------------- ### Start a New Build with Custom Parameters Source: https://docs.codemagic.io/rest-api/builds This JSON payload demonstrates how to start a build with advanced configurations, including custom labels, environment variables, variable groups, specific software versions, and instance types. This allows for fine-grained control over the build process. ```json { "appId": "5c9c064185dd2310123b8e96", "workflowId": "release", "branch": "master", "labels": ["foo", "bar"], "environment": { "variables": { "ENVIRONMENT_VARIABLE_1": "...", "ENVIRONMENT_VARIABLE_2": "..." }, "groups": [ "variable_group_1", "variable_group_2" ], "softwareVersions": { "xcode": "11.4.1", "flutter": "v1.12.13+hotfix.9" } }, "instanceType": "mac_mini_m2" } ``` -------------------------------- ### React Native Integration Test Setup with Appium and WebDriverIO Source: https://docs.codemagic.io/testing-yaml/testing Set up and run React Native integration tests using Appium and WebDriverIO. This includes installing dependencies, launching the emulator, starting Appium, and executing the test suite. ```yaml scripts: - name: Install npm dependencies # Add Appium and WebDriverIO dependencies script: npm install && npm install -g appium && npm install --save webdriverio @wdio/cli - name: Launch emulator # Insert before the build command script: | react-native run-android & adb wait-for-device - name: Launch Appium script: appium - name: Run WebDriver test suite script: npx wdio ./wdio.conf.js ``` -------------------------------- ### Codemagic YAML for .NET MAUI Android Build Source: https://docs.codemagic.io/yaml-quick-start/building-a-dotnet-maui-app Configures the Codemagic workflow for building a .NET MAUI application for Android. Includes environment setup, SDK installation, MAUI workload installation, and app publishing to Google Play. ```yaml maui-android: name: Dotnet MAUI Android max_build_duration: 120 instance_type: mac_mini_m2 environment: android_signing: - codemagic-key groups: - google_play vars: DOTNET_PATH: $CM_BUILD_DIR/dotnet DOTNET: $CM_BUILD_DIR/dotnet/dotnet PACKAGE_NAME: "io.codemagic.maui.weather" scripts: - name: Install dotnet sdk script: | wget https://dot.net/v1/dotnet-install.sh chmod +x dotnet-install.sh ./dotnet-install.sh --install-dir $DOTNET_PATH - name: Install MAUI script: | $DOTNET nuget locals all --clear $DOTNET workload install android maui \ --source https://aka.ms/dotnet6/nuget/index.json \ --source https://api.nuget.org/v3/index.json - name: Build script: | LATEST_BUILD_NUMBER=$(google-play get-latest-build-number --package-name "$PACKAGE_NAME") if [ -z $LATEST_BUILD_NUMBER ]; then UPDATED_BUILD_NUMBER=$BUILD_NUMBER else UPDATED_BUILD_NUMBER=$(($LATEST_BUILD_NUMBER + 1)) fi cd src $DOTNET publish -f net6.0-android \ -c Release \ -p:AndroidKeyStore=True \ -p:AndroidSigningKeyStore=$CM_KEYSTORE_PATH \ -p:AndroidSigningKeyAlias=$CM_KEY_ALIAS \ -p:AndroidSigningKeyPass=$CM_KEY_PASSWORD \ -p:AndroidSigningStorePass=$CM_KEYSTORE_PASSWORD \ -p:ApplicationVersion=$UPDATED_BUILD_NUMBER \ -p:ApplicationDisplayVersion="1.0.0" \ -o ../artifacts artifacts: - /Users/builder/clone/artifacts/*Signed.aab publishing: google_play: credentials: $GOOGLE_PLAY_SERVICE_ACCOUNT_CREDENTIALS track: internal submit_as_draft: true ``` -------------------------------- ### Set up Keychain for Code Signing Source: https://docs.codemagic.io/yaml-basic-configuration/building-a-flutter-app These scripts initialize the keychain, fetch necessary signing files and certificates, and configure the Xcode project for code signing. Ensure these run after dependency installation and before build commands. ```bash scripts: - name: Set up keychain to be used for code signing using Codemagic CLI 'keychain' command script: keychain initialize - name: Fetch signing files script: | app-store-connect fetch-signing-files "$BUNDLE_ID" \ --platform MAC_OS \ --type MAC_APP_STORE \ --create - name: Fetch Mac Installer Distribution certificates script: | app-store-connect certificates list --type MAC_APP_DISTRIBUTION --save || \ app-store-connect certificates create --type MAC_APP_DISTRIBUTION --save - name: Set up signing certificate script: keychain add-certificates - name: Set up code signing settings on Xcode project script: xcode-project use-profiles ``` -------------------------------- ### Start a New Build with Basic Parameters Source: https://docs.codemagic.io/rest-api/builds Use this cURL command to start a new build, providing the application ID, workflow ID, and branch name. Ensure your API token is included for authentication. ```bash curl -H "Content-Type: application/json" \ -H "x-auth-token: " \ --data '{ "appId": "", "workflowId": "", "branch": "" }' \ -X POST https://api.codemagic.io/builds ``` -------------------------------- ### Running Flutter Doctor Source: https://docs.codemagic.io/getting-started/building-a-flutter-app Use the 'flutter doctor' command to check your Flutter installation and identify any issues with your environment setup. ```bash flutter doctor ``` -------------------------------- ### Codemagic YAML for .NET MAUI iOS Build Source: https://docs.codemagic.io/yaml-quick-start/building-a-dotnet-maui-app Configures the Codemagic workflow for building a .NET MAUI application for iOS. Includes environment setup, SDK installation, MAUI workload installation, Info.plist modification, and app publishing to App Store Connect. ```yaml workflows: maui-ios: name: Dotnet MAUI iOS max_build_duration: 120 instance_type: mac_mini_m2 integrations: app_store_connect: codemagic-api environment: ios_signing: distribution_type: app_store bundle_identifier: io.codemagic.maui.weather vars: DOTNET_PATH: $CM_BUILD_DIR/dotnet DOTNET: $CM_BUILD_DIR/dotnet/dotnet APP_STORE_APPLE_ID: 6444530615 BUNDLE_ID: "io.codemagic.maui.weather" scripts: - name: Install dotnet sdk script: | wget https://dot.net/v1/dotnet-install.sh chmod +x dotnet-install.sh ./dotnet-install.sh --install-dir $DOTNET_PATH - name: Install MAUI script: | $DOTNET nuget locals all --clear $DOTNET workload install ios maui \ --source https://aka.ms/dotnet6/nuget/index.json \ --source https://api.nuget.org/v3/index.json - name: Set Info.plist values script: | # Automatically fill out the encryption compliance setting PLIST=$CM_BUILD_DIR/src/WeatherTwentyOne/Platforms/iOS/Info.plist PLIST_BUDDY=/usr/libexec/PlistBuddy $PLIST_BUDDY -c "Add :ITSAppUsesNonExemptEncryption bool false" $PLIST - name: Set build version and build the app script: | LATEST_BUILD_NUMBER=$(app-store-connect get-latest-testflight-build-number "$APP_STORE_APPLE_ID") if [ -z $LATEST_BUILD_NUMBER ]; then UPDATED_BUILD_NUMBER=$BUILD_NUMBER else UPDATED_BUILD_NUMBER=$(($LATEST_BUILD_NUMBER + 1)) fi CERT_NAME=$(keychain list-certificates | jq -r '.[] | .common_name') PROFILE_NAME=$(find ~/Library/MobileDevice/Provisioning\ Profiles -name "*.mobileprovision" -execdir sh -c '/usr/libexec/PlistBuddy -c "print :Name" /dev/stdin <<< $(security cms -D -i {})' \;) cd src $DOTNET publish -f net6.0-ios \ -c Release \ -p:BuildIpa=True \ -p:ApplicationDisplayVersion="1.0.0" \ -p:ApplicationVersion=$UPDATED_BUILD_NUMBER \ -p:RuntimeIdentifier=ios-arm64 \ -p:CodesignKey="$CERT_NAME" \ -p:CodesignProvision="$PROFILE_NAME" \ -o ../artifacts artifacts: - ./artifacts/*.ipa publishing: app_store_connect: auth: integration ``` -------------------------------- ### List Deployment Metrics Source: https://docs.codemagic.io/rn-codepush/codepush-analytics Run this command to list deployment metrics for a specific app. ```bash code-push deployment ls ``` -------------------------------- ### Regenerate Flutter Project Files Source: https://docs.codemagic.io/troubleshooting/common-ios-issues Add `flutter pub get` to the Post-clone script section to ensure iOS project files are generated before dependency installation, resolving 'Scheme not found' errors. ```yaml flutter pub get ``` -------------------------------- ### Codemagic YAML for React Native iOS Source: https://docs.codemagic.io/yaml-quick-start/migrating-from-app-center This configuration defines a Codemagic workflow for building and distributing an iOS React Native application. It includes environment setup, dependency installation, code signing, build number incrementing, and artifact generation. ```yaml workflows: react-native-ios: name: React Native iOS max_build_duration: 120 instance_type: mac_mini_m2 integrations: app_store_connect: codemagic environment: ios_signing: distribution_type: app_store bundle_identifier: io.codemagic.sample.reactnative vars: XCODE_WORKSPACE: "CodemagicSample.xcworkspace" # <-- Put the name of your Xcode workspace here XCODE_SCHEME: "CodemagicSample" # <-- Put the name of your Xcode scheme here APP_ID: 1555555551 # <-- Put the app id number here. This is found in App Store Connect > App > General > App Information node: v19.7.0 xcode: latest cocoapods: default scripts: - name: Install npm dependencies script: | npm install - name: Install CocoaPods dependencies script: | cd ios && pod install - name: Set Info.plist values script: | # This allows publishing without manually answering the question about encryption PLIST=$CM_BUILD_DIR/$XCODE_SCHEME/Info.plist PLIST_BUDDY=/usr/libexec/PlistBuddy $PLIST_BUDDY -c "Add :ITSAppUsesNonExemptEncryption bool false" $PLIST - name: Set up code signing settings on Xcode project script: | xcode-project use-profiles --warn-only - name: Increment build number script: | cd $CM_BUILD_DIR/ios LATEST_BUILD_NUMBER=$(app-store-connect get-latest-app-store-build-number "$APP_ID") agvtool new-version -all $(($LATEST_BUILD_NUMBER + 1)) - name: Build ipa for distribution script: | xcode-project build-ipa \ --workspace "$CM_BUILD_DIR/ios/$XCODE_WORKSPACE" \ --scheme "$XCODE_SCHEME" artifacts: - build/ios/ipa/*.ipa - /tmp/xcodebuild_logs/*.log - $HOME/Library/Developer/Xcode/DerivedData/**/Build/**/*.app - $HOME/Library/Developer/Xcode/DerivedData/**/Build/**/*.dSYM publishing: email: recipients: - user_1@example.com - user_2@example.com notify: success: true failure: false app_store_connect: auth: integration submit_to_testflight: true beta_groups: # Specify the names of beta tester groups that will get access to the build once it has passed beta review. - group name 1 - group name 2 submit_to_app_store: false ``` -------------------------------- ### Fetch signing files for Xcode project Source: https://docs.codemagic.io/knowledge-codemagic/codemagic-cli-tools Use the app-store-connect tool to fetch or create provisioning profiles and certificates for your app. Ensure you have your App Store Connect API credentials. ```bash app-store-connect fetch-signing-files \ --issuer-id ISSUER_ID \ --key-id KEY_IDENTIFIER \ --private-key PRIVATE_KEY \ --certificate-key PRIVATE_KEY \ MY_BUNDLE_ID ``` -------------------------------- ### Basic Hello World Workflow in codemagic.yaml Source: https://docs.codemagic.io/yaml-basic-configuration/yaml-getting-started A minimal `codemagic.yaml` file to test the setup. The script runs after the repository is cloned. ```yaml workflows: hello-world: name: Hello world workflow scripts: - echo "Hello World!" ``` -------------------------------- ### React Native iOS Workflow Configuration Source: https://docs.codemagic.io/yaml-basic-configuration/building-a-react-native-app Defines the workflow for building React Native iOS applications. Includes environment setup for signing, script execution for dependency installation, prebuilding, native build processes, and publishing to App Store Connect. ```yaml workflows: react-native-ios: name: React Native iOS max_build_duration: 120 instance_type: mac_mini_m2 integrations: app_store_connect: codemagic environment: ios_signing: distribution_type: app_store bundle_identifier: io.codemagic.sample.reactnative vars: BUNDLE_ID: "io.codemagic.sample.reactnative" XCODE_WORKSPACE: "CodemagicSample.xcworkspace" # <-- Put the name of your Xcode workspace here XCODE_SCHEME: "CodemagicSample" # <-- Put the name of your Xcode scheme here APP_STORE_APPLE_ID: 1555555551 scripts: - name: Install npm dependencies script: | npm install - name: Run Expo Prebuild script: | npx expo prebuild - name: Set Info.plist values script: | PLIST=$CM_BUILD_DIR/$XCODE_SCHEME/Info.plist PLIST_BUDDY=/usr/libexec/PlistBuddy $PLIST_BUDDY -c "Add :ITSAppUsesNonExemptEncryption bool false" $PLIST - name: Install CocoaPods dependencies script: | cd ios && pod install - name: Set up provisioning profiles settings on Xcode project script: xcode-project use-profiles - name: Increment build number script: | cd $CM_BUILD_DIR/ios LATEST_BUILD_NUMBER=$(app-store-connect get-latest-app-store-build-number "$APP_STORE_APPLE_ID") agvtool new-version -all $(($LATEST_BUILD_NUMBER + 1)) - name: Build ipa for distribution script: | xcode-project build-ipa \ --workspace "$CM_BUILD_DIR/ios/$XCODE_WORKSPACE" \ --scheme "$XCODE_SCHEME" artifacts: - build/ios/ipa/*.ipa - /tmp/xcodebuild_logs/*.log - $HOME/Library/Developer/Xcode/DerivedData/**/Build/**/*.app - $HOME/Library/Developer/Xcode/DerivedData/**/Build/**/*.dSYM publishing: email: recipients: - user_1@example.com - user_2@example.com notify: success: true failure: false app_store_connect: auth: integration # Configuration related to TestFlight (optional) # Note: This action is performed during post-processing. submit_to_testflight: true beta_groups: # Specify the names of beta tester groups that will get access to the build once it has passed beta review. - group name 1 - group name 2 # Configuration related to App Store (optional) # Note: This action is performed during post-processing. submit_to_app_store: false ``` -------------------------------- ### Basic Hello World Workflow Source: https://docs.codemagic.io/getting-started/yaml A minimal codemagic.yaml file to test the configuration. Scripts in this section run after the repository is cloned. ```yaml workflows: hello-world: name: Hello world workflow scripts: - echo "Hello World!" ``` -------------------------------- ### Run Flutter Web Integration Tests Source: https://docs.codemagic.io/testing-yaml/testing Configure and run Flutter integration tests for web applications. This setup requires enabling web configuration, starting a chromedriver, and specifying the driver and target files. Machine-readable output is not available for web tests. ```yaml scripts: - name: Integration tests script: | flutter config --enable-web chromedriver --port=4444 & flutter -d chrome drive --driver=test_driver/integration_driver.dart --target=integration_test/app_test.dart ``` -------------------------------- ### Manually Notify CodePush of Update Readiness Source: https://docs.codemagic.io/rn-codepush/debugging-and-common-issues When implementing a custom update flow (e.g., using `checkForUpdate` then `install`), call `notifyAppReady()` after the new bundle has successfully started. This prevents CodePush from assuming a crash and rolling back the update on the next restart. ```javascript import codePush from "react-native-code-push"; // ... in your custom update flow after successful JS bundle start codePush.notifyAppReady(); // Or using the legacy alias: // codePush.notifyApplicationReady(); ``` -------------------------------- ### Install .NET SDK in Codemagic Source: https://docs.codemagic.io/yaml-quick-start/building-a-dotnet-maui-app Configures the environment to download and install the .NET SDK using an official install script. Sets environment variables for the .NET installation path. ```yaml environment: vars: DOTNET_PATH: $CM_BUILD_DIR/dotnet DOTNET: $CM_BUILD_DIR/dotnet/dotnet scripts: - name: Install .NET SDK script: | wget https://dot.net/v1/dotnet-install.sh chmod +x dotnet-install.sh ./dotnet-install.sh --install-dir $DOTNET_PATH ``` -------------------------------- ### Initialize Gradle Project for Perfecto Android Source: https://docs.codemagic.io/integrations/perfecto-integration Run these commands in your local terminal to set up a Gradle project for Perfecto Android integration. Ensure you are in the 'PerfectoRunAndroid' directory. ```bash cd PerfectoRun gradle init ./gradlew wrapper ``` -------------------------------- ### Build Response Example Source: https://docs.codemagic.io/rest-api/builds A successful build initiation returns a JSON object containing the unique build ID. ```json { "buildId":"5fabc6414c483700143f4f92" } ``` -------------------------------- ### Install Pods for iOS/macOS Source: https://docs.codemagic.io/yaml/building-a-flutter-app Installs CocoaPods dependencies for your Flutter project. This command searches for the Podfile and runs `pod install`. ```bash find . -name "Podfile" -execdir pod install \; ``` -------------------------------- ### Set up Xcode Project Source: https://docs.codemagic.io/getting-started/building-a-flutter-app Use this command to set up code signing settings on your Xcode project. ```yaml - name: Set up code signing settings on Xcode project script: | xcode-project use-profiles ``` -------------------------------- ### Install Doppler CLI on macOS Source: https://docs.codemagic.io/knowledge-others/import-variables-from-secret-manager Install the Doppler CLI using Homebrew on macOS. Ensure Homebrew is installed and configured before running this script. ```yaml scripts: - name: Install Doppler on macOS script: | brew install gnupg brew install dopplerhq/cli/doppler ``` -------------------------------- ### Verify CodePush CLI Installation Source: https://docs.codemagic.io/rn-codepush/setup Verifies the successful installation of the CodePush CLI by checking its version. If the command is not found, the CLI may not have been installed correctly. ```bash code-push --version ``` -------------------------------- ### Create and Sign Installer Package Source: https://docs.codemagic.io/yaml-basic-configuration/building-a-flutter-app This script creates an unsigned installer package, finds the appropriate signing certificate from the keychain, and then signs the package. It also includes an option to remove the intermediate unsigned package. ```bash scripts: - name: Package application script: | set -x # Command to find the path to your generated app, may be different APP_NAME=$(find $(pwd) -name "*.app") cd $(dirname "$APP_NAME") PACKAGE_NAME=$(basename "$APP_NAME" .app).pkg xcrun productbuild --component "$APP_NAME" /Applications/ unsigned.pkg # Create and unsigned package # Find the installer certificate common name in keychain INSTALLER_CERT_NAME=$(keychain list-certificates \ | jq '.[] | select(.common_name | contains("Mac Developer Installer")) | .common_name' \ | xargs) xcrun productsign --sign "$INSTALLER_CERT_NAME" unsigned.pkg "$PACKAGE_NAME" # Sign the package rm -f unsigned.pkg # Optionally remove the not needed unsigned package ``` -------------------------------- ### Report build status Source: https://docs.codemagic.io/yaml-distributing/post-publish This example demonstrates how to report build status by creating a success file upon successful completion and checking for its existence in a post-publish script. This allows for conditional actions based on build outcome. ```yaml scripts: - name: Report build start script: # build started . . . - name: Build finished successfully script: touch ~/SUCCESS publishing: scripts: - name: Report build status script: | if [ -f ~/SUCCESS ] ; then # build successful else # build failed fi ``` -------------------------------- ### Install Doppler CLI on Linux Source: https://docs.codemagic.io/knowledge-others/import-variables-from-secret-manager Install the Doppler CLI on Linux using a shell script. This command downloads and executes the official installation script. ```yaml scripts: - name: Install Doppler on Linux script: | (curl -Ls --tlsv1.2 --proto \"=https\" \ --retry 3 https://cli.doppler.com/install.sh || \ wget -t 3 -qO- https://cli.doppler.com/install.sh) | \ sudo sh ``` -------------------------------- ### Set up and Run Android UI Tests Source: https://docs.codemagic.io/testing-yaml/testing This two-part script first launches an Android emulator and waits for it to become available. It then executes connected Android tests using Gradle and saves the emulator log. ```yaml scripts: - name: Launch emulator script: | cd $ANDROID_HOME/tools emulator -avd emulator & adb wait-for-device - name: Test script: | set -e ./gradlew connectedAndroidTest adb logcat -d > emulator.log test_report: app/build/outputs/androidTest-results/connected/*.xml ``` -------------------------------- ### List Installed Android SDK Packages Source: https://docs.codemagic.io/specs-macos/xcode-16-2 Use this command to list all installed Android SDK packages and their versions. Ensure the SDK Manager path is correct for your installation. ```bash /usr/local/share/android-sdk/cmdline-tools/latest/bin/sdkmanager --list_installed ``` -------------------------------- ### List Deployments and Keys Source: https://docs.codemagic.io/rn-codepush/cli-quick-reference Lists all deployments for a specific app, including their deployment keys. Use the -k flag to display the keys. ```shell code-push deployment list MyApp-Android -k ``` -------------------------------- ### Setting Up Keychain for Code Signing Source: https://docs.codemagic.io/getting-started/building-a-flutter-app These scripts configure the keychain for code signing, fetch necessary signing files and certificates, and set up Xcode project signing settings. ```bash scripts: - name: Set up keychain to be used for code signing using Codemagic CLI 'keychain' command script: keychain initialize ``` ```bash - name: Fetch signing files script: | app-store-connect fetch-signing-files "$BUNDLE_ID" \ --platform MAC_OS \ --type MAC_APP_STORE \ --create ``` ```bash - name: Fetch Mac Installer Distribution certificates script: | app-store-connect certificates list --type MAC_APP_DISTRIBUTION --save || \ app-store-connect certificates create --type MAC_APP_DISTRIBUTION --save ``` ```bash - name: Set up signing certificate script: keychain add-certificates ``` ```bash - name: Set up code signing settings on Xcode project script: xcode-project use-profiles ``` -------------------------------- ### Install Fastlane Firebase App Distribution Plugin Source: https://docs.codemagic.io/yaml-distributing/firebase-app-distribution Install the Fastlane Firebase App Distribution plugin using Bundler and gem install. This is a prerequisite for using Fastlane to distribute your app. ```yaml - name: Install fastlane-plugin-firebase_app_distribution script: | gem install bundler sudo gem install fastlane-plugin-firebase_app_distribution --user-install ``` -------------------------------- ### Example .env file structure Source: https://docs.codemagic.io/knowledge-others/import-variables-from-env-file Define variables and secrets in a .env file, ensuring multi-line values like private keys and JSON are correctly formatted with preserved line breaks. ```bash APP_STORE_CONNECT_KEY_IDENTIFIER=XXXXXXXXXX APP_STORE_CONNECT_ISSUER_ID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX APP_STORE_CONNECT_PRIVATE_KEY='-----BEGIN PRIVATE KEY----- xxxx xxxx xxxx xxxx -----END PRIVATE KEY-----' CERTIFICATE_PRIVATE_KEY='-----BEGIN RSA PRIVATE KEY----- xxxx xxxx xxxx xxxx -----END RSA PRIVATE KEY-----' GCLOUD_SERVICE_ACCOUNT_CREDENTIALS='{ "type": "service_account", "project_id": "xxxx", "private_key_id": "xxxx", "private_key": "-----BEGIN PRIVATE KEY-----\nXXXX\n-----END PRIVATE KEY-----\n", "client_email": "xxxxx-xxxx@pxxxx.iam.gserviceaccount.com", "client_id": "xxxx", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://oauth2.googleapis.com/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/xxxx-xxxx%40pc-api-xxxx-xxxx.iam.gserviceaccount.com" }' ``` -------------------------------- ### Configure FVM with Brew for Monorepos Source: https://docs.codemagic.io/getting-started/building-a-flutter-app Install and configure FVM using Homebrew for monorepo projects where the FVM config is in a subdirectory. This involves installing FVM and then installing and using a specific version. ```bash - name: Configure FVM script: | brew tap leoafarias/fvm && brew install fvm fvm install && fvm use ``` -------------------------------- ### Sample Workflow for Native iOS Simulator Build Source: https://docs.codemagic.io/yaml-code-signing/ios-simulator-builds This `codemagic.yaml` demonstrates a complete workflow for building an unsigned native iOS app for simulator testing. It includes environment variables, script steps for dependency installation and building, and artifact configuration. ```yaml workflows: simulator-native-ios: name: iOS simulator build max_build_duration: 120 instance_type: mac_mini_m2 environment: vars: XCODE_WORKSPACE: "your_workspace_name.xcworkspace" XCODE_SCHEME: "your_workspace_name" xcode: 13.0 cocoapods: default scripts: - name: Install CocoaPods dependencies script: | pod install - name: Build the .app script: | xcodebuild build \ -workspace "$XCODE_WORKSPACE" \ -scheme "$XCODE_SCHEME" \ -sdk iphonesimulator \ -destination 'platform=iOS Simulator,name=iPhone 15 Pro,OS=18.0' \ -configuration Debug \ CODE_SIGN_IDENTITY="" \ CODE_SIGNING_REQUIRED=NO \ CODE_SIGNING_ALLOWED=NO artifacts: - /tmp/xcodebuild_logs/*.log - $HOME/Library/Developer/Xcode/DerivedData/**/Build/**/*.app - $HOME/Library/Developer/Xcode/DerivedData/**/Build/**/*.dSYM ``` -------------------------------- ### Run Fastlane with Specific Bundler Version Source: https://docs.codemagic.io/integrations/fastlane-integration If your Gemfile.lock specifies a particular bundler version, install it using 'gem install bundler:' before running 'bundle install' and executing your Fastlane lane. ```yaml scripts: - name: Run fastlane script: | gem install bundler:2.2.27 bundle install bundle exec fastlane beta ``` -------------------------------- ### Set up Xcode Project for Code Signing Source: https://docs.codemagic.io/yaml/building-a-flutter-app Use this command to set up code signing settings on your Xcode project. Ensure your project is configured correctly for signing. ```bash xcode-project use-profiles ``` -------------------------------- ### Install SteamCMD on macOS Source: https://docs.codemagic.io/yaml-publishing/steam Installs SteamCMD on macOS by downloading and extracting the archive to the ~/Steam directory. ```bash mkdir ~/Steam curl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_osx.tar.gz" | tar zxvf - -C ~/Steam ``` -------------------------------- ### Install Oculus CLI Tools Source: https://docs.codemagic.io/yaml-quick-start/building-a-vr-oculus-app This script downloads and makes the Oculus Platform Utility tool executable. It's a prerequisite for uploading builds to the Oculus store. ```bash wget -O ovr-platform-util \ "https://www.oculus.com/download_app/?id=1462426033810370&access_token=OC%7C1462426033810370%7C" chmod +x ./ovr-platform-util ``` -------------------------------- ### Install Pods for iOS Source: https://docs.codemagic.io/getting-started/building-a-flutter-app Installs CocoaPods dependencies for your Flutter project on macOS. Ensure you have Podfile in the project. ```yaml - name: Install pods script: | find . -name "Podfile" -execdir pod install \; ```