Skip to content

Bridging Swift Kotlin

Ali Sadeghi edited this page Jan 21, 2026 · 4 revisions

Bridging Swift-Kotlin Skill

Auto-activates when: User mentions "Swift bridge", "iOS integration", "native SDK"

Swift-to-Kotlin Integration Patterns

Uses interface injection to integrate iOS-specific SDKs while maintaining Clean Architecture.

Pattern

1. Define Kotlin interface (commonMain)
2. Implement in Kotlin (androidMain) - usually stub
3. Implement in Swift (iosMain via expect/actual)
4. Inject via Koin DI

Examples

Biometric Authentication

> Integrate iOS Face ID authentication into the login feature

Generates:

// commonMain - Interface
interface BiometricAuthenticator {
    suspend fun authenticate(reason: String): Either<Boolean>
}

// androidMain - Android implementation
actual class BiometricAuthenticatorImpl : BiometricAuthenticator {
    override suspend fun authenticate(reason: String): Either<Boolean> {
        // Android BiometricPrompt implementation
    }
}

// iosMain - expect/actual bridge
expect class BiometricAuthenticatorImpl() : BiometricAuthenticator

// iosMain Swift bridge
@Composable
actual fun rememberBiometricAuthenticator(): BiometricAuthenticator {
    return remember { BiometricAuthenticatorSwiftBridge() }
}
// Swift implementation
class BiometricAuthenticatorSwiftBridge: BiometricAuthenticator {
    func authenticate(reason: String) async -> Either<Bool> {
        let context = LAContext()
        // Face ID implementation
    }
}

Camera Integration

> Add iOS camera capture to the profile photo feature

Payment Processing

> Integrate Apple Pay into the checkout feature

Push Notifications

> Add iOS push notification handling to the messaging feature

Spec Integration

When adding bridges to existing features:

  • Checks for .claude/docs/{feature}/spec.md
  • If spec exists: drafts spec updates for bridge interfaces
  • Updates spec's Integration Points section after implementation

Back to Skills

Clone this wiki locally