My interop got broken when I upgraded to Kotlin 1....
# multiplatform
m
My interop got broken when I upgraded to Kotlin 1.9.22 from 1.9.10 First error was telling me to add
extraOpts += listOf("-compiler-option", "-fmodules")
After I fixed that the types from the interop are off. I have
Copy code
@objc public static let mapPitchAlignment: Any = CirclePitchAlignment.map
And the interop reports the return type as
Any?
Copy code
@objc public func snapshot() -> UIImage? {
        return try? mapView.snapshot()
    }
Is now reporting the return type as
objcnames.classes.UIImage?
instead of
platform.UIKit.UIImage
I could really use some help with this. I'm not sure if I'm doing something wrong or if this is a Kotlin bug that I should report. I was able to work around things by adding UIKit to my list of modules being imported, but that fixed the errors for me. Another dev is getting a different set of wrong types
objecnames.classes.UIColor
instead of
platform.UIKit.UIImage
. My
.def
file looks like
Copy code
language = Objective-C
modules = MapboxCoreMaps MapboxWrapper PangeaCache PangeaRenderer UIKit
compilerOpts = -fmodules
MapboxWrapper (Swift library) uses classes from MapboxCoreMaps (Objective-C library) and UIKit PangeaRenderer (Objective-C library) uses classes from MapboxCoreMaps, PangeaCache (Objective-C library), and UIKit I found that after adding UIKit to the modules, I got the correct mappings for all the classes except for one class in MapboxCoreMaps that was being returned by a class in MapboxWrapper, and I was just able to cast it to the right type. Is there a better way to interop with a lot of libraries that all depend on each other. I'm going to go and downgrade Kotlin, but that is not a long term solution.
So I figured out that this was my fault. The MapboxWrapper didn't include the header files for UIKit and MapboxCoreMaps, so the types just had prototypes in the headers. Not sure why it figured out the type correctly for some functions but not others. I'm also not sure why the nullability inference broke and some properties were imported as nullable.