Did anyone manage to define AppDelegate class dire...
# ios
b
Did anyone manage to define AppDelegate class directly in iosMain kotlin source set? I tried a couple of different things and couldn’t make it work. My latest code is in the thread 🧵.
My custom AppDelegate class `InspektifyAppDelegate.kt`:
Copy code
class InspektifyAppDelegate: NSObject(), UIApplicationDelegateProtocol {
}
Usage of it in swift code `iOSApp.swift`:
Copy code
import SwiftUI
import ComposeApp

@main
struct iOSApp: App {
    @UIApplicationDelegateAdaptor(InspektifyAppDelegate.self) var appDelegate

    init() {
        KoinImplKt.doInitKoin()
	}

    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}
Error that I am getting when trying to run iOS app:
Copy code
error: generic struct 'UIApplicationDelegateAdaptor' requires that 'InspektifyAppDelegate' conform to 'UIApplicationDelegate'
    @UIApplicationDelegateAdaptor(InspektifyAppDelegate.self) var appDelegate
     ^

SwiftUI.UIApplicationDelegateAdaptor:4:43: note: where 'DelegateType' = 'InspektifyAppDelegate'
@MainActor @propertyWrapper public struct UIApplicationDelegateAdaptor<DelegateType> : DynamicProperty where DelegateType : NSObject, DelegateType : UIApplicationDelegate {
f
*__attribute__*((unavailable("Kotlin subclass of Objective-C class can't be imported")))
*__attribute__*((swift_name("InspektifyAppDelegate")))
*@interface* SharedInspektifyAppDelegate : NSObject
@end
this is not working
b
I found this answer on stackoverflow: https://stackoverflow.com/a/69281270 Will try to replicate it for that custom view and then used it with AppDelegate.
f
Good luck 🚀
🙌 1