This repo contains all the downloadable materials and projects associated with the Swift SDK for Android module in:
- This course is part of Program, which you can take as either on-demand or live bootcamp from Kodeco.
Learn how to integrate Swift code into your Android applications using Swift SDK for Android! This 3-lesson module teaches you how to build a hybrid Task Manager app that leverages Swift for business logic while maintaining a native Kotlin UI with Jetpack Compose.
By the end of this module, you'll have created a fully functional Task Manager app that demonstrates real-world Swift-Android integration patterns.
Before building these projects, ensure you have:
- macOS 13.0+ (Ventura or later) or Ubuntu 20.04+ / Debian 12+
- Android Studio (Iguana 2023.2.1 or later)
- Android SDK with API Level 34
- Android NDK 27
- Java 17 (bundled with Android Studio)
- Git for cloning the repository
Swiftly is the official Swift toolchain manager that makes it easy to install and manage Swift versions.
curl -L https://swift-server.github.io/swiftly/swiftly-install.sh | bashcurl -L https://swift-server.github.io/swiftly/swiftly-install.sh | bashAfter installation, restart your terminal or run:
source ~/.local/share/swiftly/env.shVerify installation:
swiftly --versionInstall the Swift 6.3 development snapshot (required for Swift SDK for Android):
swiftly install 6.3-snapshot
swiftly use 6.3-snapshotVerify Swift installation:
swift --version
# Should show: Swift version 6.3-devInstall the Swift SDK for Android using swiftly:
swift sdk install https://download.swift.org/swift-6.3-branch/android-sdk/swift-6.3-DEVELOPMENT-SNAPSHOT-2026-01-16-a/swift-6.3-DEVELOPMENT-SNAPSHOT-2026-01-16-a_android.artifactbundle.tar.gz --checksum 080da5553cdd12d286f715d86527089e7c924093733f8f4e1195f2bd2137d45cNote: Check swift.org/install for the latest snapshot URL and checksum if this is outdated.
Verify SDK installation:
swift sdk list
# Should show Android SDK targets-
Open Android Studio and install:
- Android SDK Platform 34
- Android NDK 27.2.12479018 (via SDK Manager → SDK Tools → NDK)
- Android SDK Build-Tools 34.0.0
-
Configure NDK Path:
- Open Preferences → Appearance & Behavior → System Settings → Android SDK
- Go to SDK Tools tab
- Check NDK (Side by side)
- Note the NDK path (typically
~/Library/Android/sdk/ndk/27.2.12479018)
-
Set Environment Variables (add to
~/.zshrcor~/.bash_profile):
export ANDROID_HOME=$HOME/Library/Android/sdk
export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/27.2.12479018
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/binThen reload your shell:
source ~/.zshrc # or source ~/.bash_profile- Clone the repository:
git clone https://github.com/kodecocodes/m3-swfa-materials.git
cd m3-swfa-materials- Navigate to a project (e.g., Lesson 1 Final):
cd 01-swift-java-interop/Final- Build Swift code:
./gradlew buildSwiftThis task:
- Compiles Swift for 3 architectures (arm64-v8a, armeabi-v7a, x86_64)
- Generates libTaskManagerKit.so for each architecture
- Copies all libraries to
app/src/main/jniLibs/ - Includes Swift runtime libraries (~28 files per architecture)
- Build the Android app:
./gradlew assembleDebugOr open the project in Android Studio and click Run
Issue: Swift SDK not found
- Solution: Run
swift sdk listto verify SDKs are installed - Ensure you're using Swift 6.3 snapshot:
swiftly use 6.3-snapshot
Issue: NDK not found
- Solution: Set
ANDROID_NDK_HOMEenvironment variable - Verify NDK is installed:
ls $ANDROID_HOME/ndk/
Issue: buildSwift task fails
- Solution: Check Swift installation:
swift --version - Ensure all 3 Android SDKs are installed:
swift sdk list
Issue: Build succeeds but app crashes on launch
- Solution: Verify correct libraries are in
jniLibs/folders - Check that Swift runtime libraries were copied (should be ~29 files per architecture)
- For Emulator: Use x86_64 image (API 28+)
- For Physical Device: Use ARM64 device (most modern Android phones)
- Grant Permissions: Camera permission required for Lessons 2 & 3
m3-swfa-materials/
├── 01-swift-java-interop/
│ ├── Starter/ # Basic Android UI, no Swift integration
│ └── Final/ # Complete with Swift validation
├── 02-platform-integration/
│ ├── Starter/ # Copy of Lesson 1 Final (clean)
│ └── Final/ # + Camera + Swift image processing
├── 03-data-persistence/
│ ├── Starter/ # Copy of Lesson 2 Final (clean)
│ └── Final/ # + Persistence + CRUD operations
├── images/ # Screenshots and assets
├── scratch/ # Development documentation
└── README.md # This file
Each project contains:
- TaskManagerKit/ - Swift package with business logic
- app/ - Android app with Kotlin/Compose UI
- build.gradle - Custom buildSwift task configuration
- README.md - Project-specific documentation
After completing all three lessons, your Task Manager app will feature:
Lesson 1: Swift-Java Interoperability
- Swift-based validation for task titles (3-50 characters) and descriptions (10-200 characters)
- Bidirectional JNI communication between Kotlin and Swift
- Type-safe data marshaling across language boundaries
Lesson 2: Platform Integration
- Camera capture using CameraX
- Real-time image processing with Swift filters:
- Grayscale conversion
- Blur effects
- Brightness adjustments
- Photo attachment to tasks
Lesson 3: Data Persistence & Testing
- JSON-based task persistence (tasks survive app restarts)
- Photo persistence
- Full CRUD operations (Create, Read, Update, Delete)
- Material Design 3 UI with priority badges
- Hybrid Architecture: Swift handles business logic and validation, Kotlin handles UI
- Production Patterns: Repository pattern, singleton managers, proper error handling
- Modern UI: Material Design 3 with Jetpack Compose
- Real-World Integration: Demonstrates practical Swift SDK for Android usage
Each edition has its own branch, named versions/[VERSION]. The default branch for this repo is for the most recent edition.
| Branch | Version | Release Date |
|---|---|---|
| versions/1.0 | 1.0 | YYYY-MM-DD |
