I think your best bet is going directly through Xcode via the
iosApp
. Write a test in the iOS application that exercises the shared library code, and launch via Xcode targeting a connected device.
The
shared
library only supports running iOS tests via
simctl
-
https://github.com/JetBrains/kotlin/blob/8c2b2eb27816dcae23f284c02bd446a139f06a2c/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/native/tasks/KotlinNativeTest.kt#L256 - which is not capable of launching on a connected device.
Conceptually, the
shared
tests are unit tests in a KMM project. Neither the Android nor iOS targets are configured to run on real devices. The Android tests run on the JVM, and the iOS tests run on the simulator. To run Android tests on a device, there is
androidAndroidTest
, but AFAIK there is no ready iOS equivalent. See
https://touchlab.co/understanding-and-configuring-your-kmm-test-suite/ for further details.
If you do manage to figure out how to run the shared test binary on a non-jailbroken device, I'd be curious what the command was. I've been toying locally, but can't get
xcodebuild
to create an archive of the test binary that I can sign/install on my device:
xcodebuild -exportArchive -archivePath ./shared/build/bin/iosArm64/debugTest -exportOptionsPlist ./shared/build/bin/iosArm64/debugTest/test.kexe.dSYM/Contents/Info.plist
error: archive at path '/Users/darron/Development/example-kmm/shared/build/bin/iosArm64/debugTest' is malformed