The `watchosArm64` target sets `typealias NSIntege...
# kotlin-native
r
The
watchosArm64
target sets
typealias NSInteger = Int
, similar to 32-bit targets, rather than
typealias NSInteger = Long
the way other 64-bit targets do. Is this deliberate or an oversight?
b
I think the full arch name is watchosarm64_32. It has 32bit integers
r
Weird. But ok good to know.
Was trying to read
konanTarget.architecture.bitness
to determine integer size but I guess I have to special case watchos
b
😬
o
This definition is based on Apple’s headers. Why do you need to know integer size?
r
This is for Multiplatform Settings, where I’m interacting with
platform.Foundation
APIs that are exposed as
NSInteger
. I’m trying to maintain a shared
appleMain
source-set that handles most of that logic, but there’s a couple spots where I need to `expect`/`actual` into 32-bit and 64-bit sources depending on whether
NSInteger
is a Kotlin
Int
or a
Long
. Currently I’m using
convert()
to handle that but I’ve realized it doesn’t actually work for my use-case the way I thought it did.
At the same time, since there’s so many Apple platforms now, I’m trying to automate that logic a little. So I initially tried to do this in my build script:
Copy code
targets
    .withType<KotlinNativeTarget>()
    .matching { it.konanTarget.family.isAppleFamily }
    .configureEach {
        if (konanTarget.architecture.bitness == 32) {
            compilations["main"].defaultSourceSet.dependsOn(apple32Main)
            compilations["test"].defaultSourceSet.dependsOn(apple32Test)
        } else {
            compilations["main"].defaultSourceSet.dependsOn(apple64Main)
            compilations["test"].defaultSourceSet.dependsOn(apple64Test)
        }
    }
But it’s not enough to just check
bitness
. I need to also send watchOS targets to the first branch.
It’s an easy adjustment. But the inconsistency surprised me so I figured I’d check in and make sure it’s expected.