How do I enable App Groups and other capabilities for iOS bundle IDs using Codemagic CLI?

Last updated: March 2, 2026

Context

When working with iOS apps that require specific capabilities like App Groups, Push Notifications, or Associated Domains, you need to enable these capabilities for your bundle ID. While App Group identifiers must be created manually in the Apple Developer Portal, you can use Codemagic CLI commands to create bundle IDs and enable capabilities programmatically.

Answer

You can create a bundle ID and enable capabilities using the Codemagic CLI. Here's how to do it:

Step 1: First, manually create your App Group identifier in the Apple Developer Portal (this cannot be done via CLI).

Step 2: Use the following YAML configuration to create a bundle ID and enable capabilities:

ios-bundle-id-setup:
  integrations:
    app_store_connect: <APP_STORE_CONNECT_API_KEY>
  environment:
    vars:
      BUNDLE_ID: <BUNDLE_ID>
  scripts:
    - name: Create bundle ID
      script: |
        CREATE_OUTPUT=$(app-store-connect bundle-ids create $BUNDLE_ID --platform IOS)
        
        echo "$CREATE_OUTPUT"

        # Extracts the Bundle ID Resource ID
        BUNDLE_ID_RESOURCE_ID=$(echo "$CREATE_OUTPUT" | grep -oE '^Id: [A-Za-z0-9]+' | awk '{print $2}')
        
        if [ -z "$BUNDLE_ID_RESOURCE_ID" ]; then
          echo "Failed to extract Bundle ID Resource ID from output"
          exit 1
        fi

        echo "Extracted Bundle ID Resource ID: $BUNDLE_ID_RESOURCE_ID"
        echo "BUNDLE_ID_RESOURCE_ID=$BUNDLE_ID_RESOURCE_ID" >> $CM_ENV

    - name: Enable capabilities
      script: |
        app-store-connect bundle-ids enable-capabilities $BUNDLE_ID_RESOURCE_ID \
          --capability "Associated Domains" "Push Notifications" "App Groups"

Important notes:

  • To enable multiple capabilities, list them all after the --capability flag separated by spaces, not as separate --capability flags

  • The Bundle ID Resource ID is automatically extracted from the creation output and used to enable capabilities

  • You cannot configure specific App Group identifiers (like group.com.example) via the CLI - this must be done manually in the Apple Developer Portal

You can find all supported capabilities in the Codemagic CLI tools documentation.