https://kotlinlang.org logo
#compose-ios
Title
# compose-ios
t

Trey

11/08/2023, 9:01 PM
I'm trying to define my AppDelegate instance in the iosMain section of my shared module so that I can create background tasks when authenticating using PKCE. I specify the instance from the shared module using "@UIApplicationDelegateAdaptor" in my SwiftUI main app. I'm getting this error when I compile. Anybody know how to work around this error? I only implemented the didFinishLaunchingWithOptions method.
Copy code
Task :shared:compileKotlinIosSimulatorArm64 FAILED
/Users/builder/Projects/TestApp/shared/src/iosMain/kotlin/com/testapp/app/AppDelegate.kt:13:22: error: Overload resolution ambiguity: 
public open fun application(application: UIApplication, didFinishLaunchingWithOptions: Map<Any?, *>?): Boolean defined in platform.UIKit.UIApplicationDelegateProtocol
public open fun application(application: UIApplication, willFinishLaunchingWithOptions: Map<Any?, *>?): Boolean defined in platform.UIKit.UIApplicationDelegateProtocol
error: Compilation finished with errors
l

Landry Norris

11/08/2023, 9:23 PM
When two Swift methods have the same 'name', you need to manually specify the parameter names in Kotlin when calling the methods.
t

Trey

11/08/2023, 9:24 PM
It's failing on my method where I just define the class. I'm not calling the method. On the "didFinishLaunchingWithOptions" line below.
Copy code
import platform.UIKit.UIApplication
import platform.UIKit.UIApplicationDelegateProtocol
import platform.darwin.NSObject

class AppDelegate : NSObject(), UIApplicationDelegateProtocol {

    override fun application(
        application: UIApplication,
        didFinishLaunchingWithOptions: Map<Any?, *>?
    ): Boolean {
        return true
    }

}
2 Views