I've encountered an issue where I'm unable to buil...
# multiplatform
e
I've encountered an issue where I'm unable to build a library after adding in overrides on a class extending the MKMapViewDelegateProtocol. If I include the module in my existing app, the application builds fine, the build error is only encountered when performing a full build via ./gradlew clean build Error: Return type of 'mapView' is not a subtype of the return type of the overridden member 'public open expect fun mapView(mapView: MKMapView, didSelectAnnotation: MKAnnotationProtocol): Unit defined in platform.MapKit.MKMapViewDelegateProtocol' I've tried running the build using the opposing override return type of Unit, but then the error flips and I'm told to use the return type of MKAnnotationView? again. Is there some way of suppressing this error?
Copy code
class MapViewDelegate : MKMapViewDelegateProtocol, NSObject() {
    override fun mapView(mapView: MKMapView, viewForAnnotation: MKAnnotationProtocol): MKAnnotationView? { /*...more code...*/
c
Interesting. When I look at the stubs generated for me for
MKMapViewDelegateProtocol
, I don’t even have a stub that matches the one mentioned in the error:
public open expect fun mapView(mapView: MKMapView, didSelectAnnotation: MKAnnotationProtocol): Unit
I do have this stub, though:
public open fun mapView(mapView: platform.MapKit.MKMapView, didSelectAnnotationView: platform.MapKit.MKAnnotationView): kotlin.Unit
And this snippet builds for me:
Copy code
class MapViewDelegate : MKMapViewDelegateProtocol, NSObject() {
    override fun mapView(
        mapView: MKMapView,
        viewForAnnotation: MKAnnotationProtocol,
    ): MKAnnotationView? {
        return null
    }
}
I’m curious which version(s) of the Kotlin/Native and/or multiplatform toolchain(s) you’re using, and whether or not that is having an effect? While not explicit in the question, it looks like these overloads may be problematic in the expected way in the iOS/iPadOS/Mac Catalyst/visionOS stubs. I mainly work with macOS stubs at the moment.
e
I'm using Kotlin 1.9.23 and importing via
import platform.MapKit.MKMapViewDelegateProtocol
in the iosMain sourceset. It's strange that I am able to build fine when simply including the module, but cannot perform a full build as to be able to publish the library (if you're aware of some sort of config I can add that will ignore the error while building that would be grand)