I’m updating an app from Kotlin 1.4.10 to 1.5.20, ...
# kotlin-native
r
I’m updating an app from Kotlin 1.4.10 to 1.5.20, and a lot of dependencies. It’s an app made with just the UI/View in Swift, Presenter/Model level stuff and above is all Kotlin, so it has a KMP project inside it named
Mpp
, which compiles into a Framework. I have this data class in the
Mpp
project:
Copy code
data class Event(
    // …
    val publicName: String?,
    // …
) {

    // …

    val hasPublicName: Boolean
        get() = !publicName.isNullOrBlank()

}
Somewhere in Swift, I have this:
Copy code
func configure(_ event: Event) {
        if event.hasPublicName {
            eventTypeLabel.isHidden = true
            locationView.isHidden = true
            publicNameLabel.isHidden = false
            publicNameLabel.text = event.publicName
    // …
I didn’t change any of these files, but I now get this error (worked in 1.4.10):
Copy code
2021-07-09 15:46:41.834833+0200 MyApp[25797:9497146] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MppEvent hasPublicName]: unrecognized selector sent to instance 0x600001ae5650'
Maybe I broke something in the way the project is built, but I don’t know what. I don’t know what could cause this. I also tried to replace
event.hasPublicName
in Swift with
event.publicName != nil
but then it crashes the same way but on
publicName
. I’m tweaking the XCode project a lot, and now I don’t know what could cause this?
XCode doesn’t see any problem, it’s only at runtime. I can see the definition of
hasPublicName
when browsing inside XCode:
Copy code
@property (readonly) BOOL hasPublicName __attribute__((swift_name("hasPublicName")));
I just cleaned everything & rebuilt a few times, and it finally worked… Without me changing anything else… Seems pretty random, I wonder why this occurs. I encountered some other random errors between different clean-build cycles, like some Pod dependencies suddenly not being found, or my entire Mpp framework itself, or multiple of those random errors all at once