Thanks again @Artyom.Degtyarev
I did updated the compiler to 1.3.50
and I finally can compile the project but now I see a runtime error when I try to assign the delegate locationManager.setDelegate(derived)
.
The actual error showing in my xcode on runtime is:
/Users/teamcity/buildAgent/work/4d622a065c544371/runtime/src/main/cpp/ObjCInterop.cpp:125: runtime assert: Unable to add method to Objective-C class
Where teamcity is not even a user from my machine.
I show to you the code like actually I’m working:
actual fun Location.getLocation(onGetLocation: (location: GeoPoint) -> Unit) {
val delegate = CLLocationManagerDelegateImpl()
val derived = CLLocationManagerDelegate(delegate)
locationManager.setDelegate(derived)
locationManager.requestWhenInUseAuthorization()
}
class CLLocationManagerDelegateImpl: CLLocationManagerDelegateProtocol, NSObject() {
override fun locationManager(manager: CLLocationManager, didUpdateLocations: List<*>) {
didUpdateLocations.last { lastLocation ->
val location = lastLocation as CLLocation
location.coordinate.let { print("DelegateImpl found user's latitude: ${it}") }
return
}
}
}
@Suppress("CONFLICTING_OVERLOADS")
class CLLocationManagerDelegate(delegate: CLLocationManagerDelegateProtocol) : CLLocationManagerDelegateProtocol by delegate, NSObject() {
override fun locationManager(manager: CLLocationManager, didStartMonitoringForRegion: CLRegion) {}
override fun locationManager(manager: CLLocationManager, didEnterRegion: CLRegion) {}
override fun locationManager(manager: CLLocationManager, didExitRegion: CLRegion) {}
}
By last, I allredy cleaned deriveddata
and gradle caches