Skip to content

feat: Support ANDROID_NDK_ROOT as fallback for ANDROID_NDK_HOME #226

@organicnz

Description

@organicnz

Problem

The Swift SDK only checks ANDROID_NDK_HOME to locate the NDK. However, Android Studio and Gradle use ANDROID_NDK_ROOT as the standard. This causes friction for developers with existing Android environments.

Who is affected

  • Android Studio users (IDE sets ANDROID_NDK_ROOT)
  • CI/CD pipelines (GitHub Actions Android setup uses ANDROID_NDK_ROOT)
  • Teams with mixed Kotlin/Swift Android projects

Current behavior

echo $ANDROID_NDK_ROOT  # /Users/dev/Library/Android/sdk/ndk/27.0.12077973
./setup-android-sdk.sh
# error: ANDROID_NDK_HOME not set

Proposed Solution

Check both environment variables with ANDROID_NDK_HOME taking precedence:

ANDROID_NDK="${ANDROID_NDK_HOME:-$ANDROID_NDK_ROOT}"

if [ -z "$ANDROID_NDK" ]; then
    echo "error: Set ANDROID_NDK_HOME or ANDROID_NDK_ROOT"
    exit 1
fi

Benefits

  • Zero friction for existing Android developers
  • Works out-of-the-box with Android Studio
  • CI/CD pipelines work without extra config
  • Backwards compatible
  • One-line fix

Environment

  • OS: 26.2 (25C56) (Tahoe)
  • Shell: zsh
  • Swift: 6.3-DEVELOPMENT-SNAPSHOT
  • Android NDK: r27d
  • Swift SDK for Android: 6.3 snapshot

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions