Most of the focus of Kotlin Multiplatform has, understandably, been on targeting the development of apps that run on Android and iOS. However, other platforms are supported so when I saw following announcement of SQLDelight’s support for macOS I was curious to see what would be involved in developing a basic app on that platform that uses same shared Kotlin code used in PeopleInSpace (A little bit more background on initial effort working with Android and iOS in following post Minimal Kotlin Multiplatform project using Compose and SwiftUI)
SQLDelight 1.2.2 released with windows/watchOS/tvOS/macOS support!https://t.co/vK27TSSVqF
— Alec Strong (@Strongolopolis) January 23, 2020
also the whole thing is on github actions now! There's even an EAP channel for the intellij plugin that automatically gets pushed too!!! Wow!!!!!
The Android, iOS and watchOS apps in PeopleInSpace had just displayed a list of astronauts currently in space but, given
additional real estate at our disposal on macOS, I thought I should expand to include other information available from
People In Space API endpoint so decided to also show current position of ISS (International Space Station)
Updated Ktor client code
There isn’t anything macOS specific here but did add use of API that returns ISS position.
macOS SwiftUI code
The SwiftUI code used is similar to that used for iOS and watchOS but now includes use of a Map View to show ISS position (along with associated
update to View Model). This is using Combine’s Timer.publish()
to periodically
poll for updated position. Another approach might be to do the polling in shared Kotlin Code (perhaps an exercise for someone if they
want to create PR for this :) )
Gradle updates
These are the main updates to build.gradle
for shared code module.
Note
This is currently using 1.3.5-native-mt
version of Kotlin Coroutines. Ktor does not currently fully work with this version so, for
now this is using runBlocking
workaround when invoking API requests - more info in this Ktor issue
Featured in Kotlin Weekly Issue #194
Related tweet
Just wrote short blog article on starting to use #KotlinMultiplatform on macOS https://t.co/XDrUa7QxOf https://t.co/KGzdFTcE45
— John O'Reilly (@joreilly) April 18, 2020