See also: KotlinLogo-ScreenSaver for a more complex implementation and more references.
- KotlinScreenSaver: an Xcode screen saver project
src/appleMain:KotlinScreenSaverView: an abstract screen saver class that the Swift code delegates calls to, choose the concrete implementation used at the top of this fileMyAppKitScreenSaverView: demo of AppKit being used to put content on the screen with Kotlin codeMyComposeScreenSaverView: demo of Compose Multiplatform rendering on macOS native targetMain.kt: a macOS native main function to run the Compose code on native, in a window, without needing to package and load a screen saver
src/commonMaincontains the shared Compose UI codesrc/jvmMaincontains a JVM entry point to run the Compose code as a desktop app, with Compose Hot Reload configured for easier editing
Build the screen saver:
cd KotlinScreenSaver
xcodebuild -scheme KotlinScreenSaver build
Run the native app:
./gradlew runDebugExecutableMacosArm64
Run the JVM desktop app with Compose Hot Reload:
./gradlew hotRunJvm --mainClass "MainKt" --auto