Is it possible to do desktop native app yet (at le...
# amper
s
Is it possible to do desktop native app yet (at least Mac OS), something along these lines: https://github.com/ktorio/ktor-documentation/blob/3.0.0/codeSnippets/snippets/embedded-server-native/build.gradle.kts
j
I think you should be able to use the
macos/app
product type for this purpose
If you want to have both a linux and a macOS app from the same code, you should be able to achieve that by putting all your code in a shared module of type
lib
and then have one module for each application with the corresponding product type.
👍 1
s
Unfortunately, doesn't work for ktor (but does work for hello world).
j
Sorry to hear that :/ Could you please elaborate on what doesn't work? Like the error you get, or the blocking issues you faced? It would be quite useful to know. And if you have a toy project to share it's even better :)
s
Copy code
product: macos/app

dependencies:
  - io.ktor:ktor-server-core:2.3.12
  - io.ktor:ktor-server-cio:2.3.12
and then
Copy code
00:03.958 INFO  :kstatic:compileMacosArm64 Calling konanc -g -ea -produce library -module-name kstatic -target macos_arm64 -Xmulti-platform -language-version 1.9 -api-version 1.9 -output 
00:05.271 ERROR :kstatic:compileMacosX64  
.../src/main.kt:1:8: error: unresolved reference: io
00:05.276 ERROR :kstatic:compileMacosX64  import io.ktor.server.application.*
Vanilla ktor server with cio:
Copy code
import io.ktor.server.application.*
import io.ktor.server.engine.*
import io.ktor.server.cio.*
import io.ktor.server.response.*
import io.ktor.server.routing.*

fun main() {
    embeddedServer(CIO, port = 8080, host = "0.0.0.0", module = Application::module)
        .start(wait = true)
}

fun Application.module() {
    routing {
        get("/") {
            call.respondText("Hello World!")
        }
    }
}
Same result with ktor 3
j
Thank you!