https://kotlinlang.org logo
Title
s

Shivam Kanodia

05/03/2023, 9:46 AM
Hi Everyone, Can anyone please help me this error
Thread 1: EXC_BAD_ACCESS (code=1, address=0x0) when running KMM app in XCode
*import* UIKit
*import* kmm
@UIApplicationMain
*class* AppDelegate: UIResponder, UIApplicationDelegate {
*var* window: UIWindow?
*func* application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: *Any*]!) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
*let* mainViewController = Main_iosKt.MainViewController()
window?.rootViewController = mainViewController window?.makeKeyAndVisible()
return
true
}
}
som error in AppDelegate class
d

David Nedrow

05/03/2023, 1:04 PM
That's odd. What does the
kmm
import give you? Are you trying to use Compose? I've never seen this before:
Main_iosKt.MainViewController()
s

Shivam Kanodia

05/03/2023, 1:12 PM
yes i am trying to use compose view in ios
its supported now
d

David Nedrow

05/03/2023, 1:12 PM
Ah, then I can't help.
l

Landry Norris

05/03/2023, 2:07 PM
When you see the address is 0x0, that means it's a null pointer the Kotlin compiler didn't check for. This usually happens with weird constructor ordering, variable initializers that depend on each other through some odd method ordering (think
val x = y; val y get() = x
, or some other initialization weirdness.
s

Shivam Kanodia

05/04/2023, 8:13 AM
@Landry Norris Thanks