Tung97 Hl
09/14/2023, 11:45 AMUncaught Kotlin exception: kotlin.IllegalStateException: KoinApplication has not been started
in iOS? I have initialized koin in init() block (with swiftui) and UIApplicationDelegate (with UIkit). But ios application keep crashed. Please help me!!arnaud.giuliani
09/14/2023, 12:08 PMfun initKoin(appDeclaration: KoinAppDeclaration = {}) =
startKoin {
modules(commonModule())
appDeclaration()
}
// called by iOS client
fun initKoin() = initKoin() {}
arnaud.giuliani
09/14/2023, 12:08 PMTung97 Hl
09/14/2023, 3:47 PMJeff Lockhart
09/14/2023, 3:50 PMinitKoin
code is called first before anything else.Tung97 Hl
09/14/2023, 3:59 PMTung97 Hl
09/15/2023, 3:43 AM@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
KoinHelperKt.doInitKoin()
window = UIWindow(frame: UIScreen.main.bounds)
window?.rootViewController = IOSMainViewKt.MainViewController()
window?.makeKeyAndVisible()
return true
}
}
doInitKoin is helper function to init koin application
fun doInitKoin() = startKoin {
modules(commonModule() + storeModule() + posSdkModule() + posTerminalSdkModule())
}
MainViewController is compose multiplatform function. I'm accessing koin dependencies inside it:
fun MainViewController(): UIViewController = ComposeUIViewController { MainScene() }
Tung97 Hl
09/15/2023, 4:19 AM[Koin]: loaded 34 definitions in 0.605958 ms
Uncaught Kotlin exception: kotlin.IllegalStateException: KoinApplication has not been started
Tung97 Hl
09/18/2023, 1:35 AMJeff Lockhart
09/18/2023, 1:51 AM