Before wasting time, can I use Ktor in a watchOS a...
# ktor
t
Before wasting time, can I use Ktor in a watchOS app/target?
t
Ktor client with iOS engine works for me in a watchOS app
t
Interesting. May I ask how your gradle is set up? I am using cocoapods integration, which calls the gradle process, passing in the Xcode params. I have something like this:
Copy code
val buildForWatchARM = project.findProperty("kotlin.native.cocoapods.target") == "watchos_arm"
    if (buildForWatchARM) {
        watchosArm32("watchos32")
        watchosArm64("watchos64")

        val watchosMain = sourceSets.maybeCreate("watchosMain")
        sourceSets["watchos64Main"].dependsOn(watchosMain)
        sourceSets["watchos32Main"].dependsOn(watchosMain)

    } else {
        watchosX64("watchos") // simulator
    }
and then a section like so:
Copy code
val watchosMain by getting {
            dependencies {
                implementation("io.ktor:ktor-client-ios:$ktorVersion")
            }
        }
but when I try to build the framework within AS, I get errors like so:
Copy code
Could not resolve io.ktor:ktor-client-core:1.6.0.
...
No matching variant of io.ktor:ktor-client-core:1.6.0 was found.
Or are you perhaps linking directly to the generated iOS framework from the watchOS extension?
t
Maybe the new
watchosX64
target is not supported yet in Ktor
I am using
watchosX86
for simulator
t
Good point. I am trying simulator first.
sweet. that got me much further.
do you have a specific watchosMain target set up, or do you re-use the iosMain target?
t
I have all Ktor code in an appleMain source set which is shared between ios and watchos
And common / jvm source sets of course
t
good idea. will look into how to share them. thanks for the help!
t
Great! Upvoted.
Now can you throw in a PR for maccatalyst? 😉
t
Haha unfortunately that's not as easy as this PR
On the roadmap Mac Catalyst was postponed for later so I am afraid we are not going to see support anytime soon
For my project I am considering using Compose UI instead which is JVM (so not Kotlin/Native)
#compose-desktop
t
That does look pretty cool. Have to get into it. I might look into doing a macOS SwiftUI version of our app, then at least I can use the shared code compiled as a pure macOS framework.
@Thomas Well done on the PR. Approved and Merged! Anxious to get Ktor 1.6.1 now. 🙂