I want to be able to edit my Kotlin Multiplatform Mobile app's swift code in VS Code and/or vim. XCode is too limited and buggy, with error highlighting not really working at all at the moment, which is fairly dire.
I've created a dummy
Package.swift to try to make this possible. VS Code/sourcekit_lsp needs a successful build before completion etc will work, and I've run into a couple of problems with it.
One problem is this:
error: the library 'GCios' requires macos 10.13, but depends on the product 'GoogleSignIn' which requires macos 10.15; consider changing the library 'GCios' to require macos 10.15 or later, or the product 'GoogleSignIn' to require macos 10.13 or earlier.
It's no good adding
.macOS("10_15") to my
platforms argument, because that makes it try to generate macos versions of all my code, which obviously won't work because it contains iOS specifics. There doesn't seem to be any way to disable the macos support in the Google package other than forking it; and I'm worried that even then, merely removing the macos platform from its
package.swift will not work, and I'll have to laboriously remove all the macos stuff from multiple source files.
The second problem is with the compiled Kotlin, which is output as a framework. I've tried adding its path to the swift command line:
GC_FW_PATH="$SRCROOT/GCshared/build/xcode-frameworks/Debug/iphoneos16.4/" GC_SHARED="$GC_FW_PATH/GCshared.framework" swift build --arch arm64 -Xswiftc -sdk \ -Xswiftc "`xcrun --sdk iphonesimulator --show-sdk-path`" \ -Xswiftc "-target" -Xswiftc "arm64-apple-ios15.5-simulator" \ -Xswiftc "-I" -Xswiftc "$GC_SHARED/Headers" \ -Xswiftc "-L" -Xswiftc "$GC_SHARED" \ -Xswiftc "-l" -Xswiftc "GCshared"
but I still get a volley of errors (from my import statements) saying the module can't be found. I also tried adding it as a binary target in
.binaryTarget( name: "GCshared", path: "../GCshared/build/xcode-frameworks/Debug/iphoneos16.4/GCshared.framework" )
but that causes another error:
error: 'gcios': unsupported extension for binary target 'GCshared'; valid extensions are: 'zip', 'xcframework', 'artifactbundle'
There might be a possible solution in the form of a gradle plugin that makes Kotlin Multiplatform Mobile generate a swift package instead of a framework, but I'd like to see if there's a quick fix for the current system first.