plusieurs plateformes • Compilé avec Kotlin/JVM pour Android et Kotlin/Native pour iOS • Génération d’un header Objective-C pour iOS • Permet d’utiliser les APIs de la plateforme via le mécanisme expect/actual • KMM en beta (mais stable fi n 2023)
Compose (mais peut utiliser les Views/XML) • Une application SwiftUI (mais peut utiliser UIKit) • Un module shared qui montre comment Kotlin peut appeler les APIs iOS • Un projet Gradle
var configuration = CommandConfiguration( commandName: "swiftlint", abstract: "Lints the code of your projects using SwiftLint." ) @Option( name: .shortAndLong, help: "The path to the directory that contains the workspace or project whose code will be linted.", completion: .directory ) var path: String? @Argument( help: "The target to be linted. When not specified all the targets of the graph are linted." ) var target: String? // ... func run() throws { try SwiftLintService() .run( path: path, targetName: target, strict: strict ) } } }
fetch data } suspend fun compute(records: List<Int>): Int { // TODO: compute } suspend fun saveData(result: Int): Boolean { // TODO: save data } suspend fun doWork() { val records = fetchData() val result = compute(records) val response = saveData(result) println(“Response: $response") } func fetchData() async -> [Int] { // TODO: fetch data } func compute(_ records: [Int]) async -> Int { // TODO: compute } func saveData(_ result: Int) async -> Bool { // TODO: save data } func doWork() async { let records = await fetchData() let result = await compute(records) let response = await saveData(result) print("Response: \(response)") }
en rajoutant un handler dans le cas où la fonction se termine • Mais : • Pas de support pour la cancellation • Les Flows perdent leur type générique (Objective-C ne supporte pas les génériques pour les interfaces)
compilateur (KSP) utilisé via Gradle • Modi fi e le header généré pour le module partagé • Supporte Async/Await, Combine, ou RxSwift github.com/rickclephas/KMP-NativeCoroutines
TEXT NOT NULL ); CREATE INDEX hockeyPlayer_full_name ON hockeyPlayer(full_name); INSERT INTO hockeyPlayer (player_number, full_name) VALUES (15, 'Ryan Getzlaf'); Schéma src/commonMain/sqldelight/com/multiplatforge/hockey/data/Player.sq
seul écran • Exécute de la logique métier • Android : • A un cycle de vie • Persiste l’état à malgré les changements de con fi guration • Fourni un scope pour lancer des coroutines • Principe similaire sous iOS avec SwiftUI
un format similaire à Android vers iOS • Plugin Gradle • Supporte entre autres : • Strings/Traductions • Polices • Couleurs • Images • Fichiers Textes github.com/icerockdev/moko-resources
<string name="mainHeadline">Find your next match </ string> </ resources> Généré (iOS) : en.lproj/Localizable.strings "helloWorld" = "Hello, world!"; "mainHeadline" = "Find your next match";
(comme AppCode) • Cross Kotlin/Swift/Objective-C : • Auto-complétion • Navigation symboles • Refactoring • Debugging • Run con fi gurations pour toutes les plateformes (dont iOS)
avec Ktor Client, GraphQL avec Apollo-Kotlin) • Génération de code Swift à partir de Kotlin (KSP) • Utilisation de librairies Swift depuis Kotlin (pour iOS uniquement) • CI/CD : ne builder/tester/deployer que les modules pour lesquels il y a des changements • UI partagée : Compose Multiplatform, Flutter… • …