rickclephas / KMP-ObservableViewModel

Library to use AndroidX/Kotlin ViewModels with SwiftUI
MIT License
583 stars 27 forks source link

Xcode preview not working #27

Closed kansson closed 1 year ago

kansson commented 1 year ago

Hello, awesome project!

I'm using this package together with NativeCoroutines and everything works great on both platforms but not in the Xcode preview. The preview will not load at all and crashes with this error log.

Error Log ------------------------------------- Translated Report (Full Report Below) ------------------------------------- Incident Identifier: 7471A224-E102-4E3A-8665-6BC7B1FD3D4A CrashReporter Key: 8B36B5A8-1965-D9C2-C099-610507FD1EF2 Hardware Model: MacBookAir10,1 Process: ios [2276] Path: /Users/USER/Library/Developer/Xcode/UserData/Previews/Simulator Devices/3D6F16D8-2B4B-47FC-A471-DED791F64349/data/Containers/Bundle/Application/8492D742-B9D7-4F60-AB2F-CD4098EE7443/ios.app/ios Identifier: duck.hansson.odd.ios Version: 1.0 (1) Code Type: ARM-64 (Native) Role: Foreground Parent Process: launchd_sim [72630] Coalition: com.apple.CoreSimulator.SimDevice.3D6F16D8-2B4B-47FC-A471-DED791F64349 [16757] Responsible Process: SimulatorTrampoline [64885] Date/Time: 2023-05-17 20:01:11.3450 +0200 Launch Time: 2023-05-17 20:01:11.1845 +0200 OS Version: macOS 13.3.1 (22E261) Release Type: User Report Version: 104 Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Triggered by Thread: 0 Kernel Triage: VM - (arg = 0x0) pmap_enter retried due to resource shortage VM - (arg = 0x0) pmap_enter retried due to resource shortage VM - (arg = 0x0) pmap_enter retried due to resource shortage VM - (arg = 0x0) pmap_enter retried due to resource shortage VM - (arg = 0x0) pmap_enter retried due to resource shortage Thread 0 Crashed:: Dispatch queue: BSXPCCnx:com.apple.dt.xcode-previews.systemservices (BSCnx:client:com.apple.dt.uv.agent-preview-nonui-service) 0 libsystem_kernel.dylib 0x1b17e3fa8 __pthread_kill + 8 1 libsystem_pthread.dylib 0x1b183812c pthread_kill + 256 2 libsystem_c.dylib 0x18012873c abort + 124 3 Shared 0x103910cec konan::abort() + 12 4 Shared 0x10393ded8 (anonymous namespace)::terminateWithUnhandledException(ObjHeader*)::$_1::operator()() const + 16 5 Shared 0x10393dcf0 void (anonymous namespace)::$_0::operator()<(anonymous namespace)::terminateWithUnhandledException(ObjHeader*)::$_1>((anonymous namespace)::terminateWithUnhandledException(ObjHeader*)::$_1) + 80 6 Shared 0x10393da00 (anonymous namespace)::terminateWithUnhandledException(ObjHeader*) + 12 7 Shared 0x10393d9bc (anonymous namespace)::processUnhandledException(ObjHeader*) + 64 8 Shared 0x1039532b4 kotlin::ProcessUnhandledException(ObjHeader*) + 188 9 Shared 0x103955e2c Kotlin_ObjCExport_trapOnUndeclaredException + 36 10 Shared 0x1036e5b14 objc2kotlin_kfun:duck.hansson.odd.shared.module.SharedModule#(){}duck.hansson.odd.shared.viewmodel.HomeViewModel + 252 11 ios 0x102392240 ContentView.init() + 120 (ContentView.swift:13) 12 ContentView.1.preview-thunk.dylib 0x10369a09c static ContentView_Previews.__preview__previews.getter + 52 (ContentView.swift:28) 13 ios 0x10239270c protocol witness for static PreviewProvider.previews.getter in conformance ContentView_Previews + 12 14 SwiftUI 0x108fb9428 0x108610000 + 10130472 15 ios 0x102392750 protocol witness for static _PreviewProvider._previews.getter in conformance ContentView_Previews + 40 16 SwiftUI 0x108fb9cc0 0x108610000 + 10132672 17 PreviewsInjection 0x1024bf134 0x10248c000 + 209204 18 PreviewsInjection 0x1024bf098 0x10248c000 + 209048 19 PreviewsInjection 0x1024b5d08 0x10248c000 + 171272 20 PreviewsInjection 0x1024ae2d4 0x10248c000 + 139988 21 PreviewsInjection 0x1024add14 0x10248c000 + 138516 22 PreviewsInjection 0x1024adf2c 0x10248c000 + 139052 23 BoardServices 0x184a2116c +[BSXPCServiceConnectionProxy invokeMethod:onTarget:withMessage:forConnection:] + 1136 24 BoardServices 0x184a2ff48 __63-[BSXPCServiceConnectionEventHandler connection:handleMessage:]_block_invoke + 536 25 BoardServices 0x184a53fcc BSXPCServiceConnectionExecuteCallOut + 232 26 BoardServices 0x184a2fbe0 -[BSXPCServiceConnectionEventHandler connection:handleMessage:] + 148 27 BoardServices 0x184a53554 -[BSXPCServiceConnection _connection_handleMessage:fromPeer:withHandoff:] + 512 28 libdispatch.dylib 0x180132ee4 _dispatch_call_block_and_release + 24 29 libdispatch.dylib 0x180134708 _dispatch_client_callout + 16 30 libdispatch.dylib 0x18013c77c _dispatch_lane_serial_drain + 776 31 libdispatch.dylib 0x18013d414 _dispatch_lane_invoke + 448 32 libdispatch.dylib 0x180143e4c _dispatch_main_queue_drain + 824 33 libdispatch.dylib 0x180143b04 _dispatch_main_queue_callback_4CF + 40 34 CoreFoundation 0x18039a784 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12 35 CoreFoundation 0x180394de4 __CFRunLoopRun + 1912 36 CoreFoundation 0x180394254 CFRunLoopRunSpecific + 584 37 GraphicsServices 0x188eb7c9c GSEventRunModal + 160 38 UIKitCore 0x1050b2ff0 -[UIApplication _run] + 868 39 UIKitCore 0x1050b6f3c UIApplicationMain + 124 40 SwiftUI 0x10956734c 0x108610000 + 16085836 41 SwiftUI 0x1095671ec 0x108610000 + 16085484 42 SwiftUI 0x108d5f474 0x108610000 + 7664756 43 ios 0x1023936a4 static iosApp.$main() + 40 (iosApp.swift:11) 44 ios 0x10239374c main + 12 45 dyld_sim 0x10257d514 start_sim + 20 46 dyld 0x102671f28 start + 2236 Thread 1: 0 libsystem_pthread.dylib 0x1b1833634 start_wqthread + 0 Thread 2: 0 libsystem_pthread.dylib 0x1b1833634 start_wqthread + 0 Thread 3:: GC Timer thread 0 libsystem_kernel.dylib 0x1b17df694 __psynch_cvwait + 8 1 libsystem_pthread.dylib 0x1b18389e4 _pthread_cond_wait + 1220 2 libc++.1.dylib 0x180280a84 std::__1::condition_variable::__do_timed_wait(std::__1::unique_lock&, std::__1::chrono::time_point>>) + 96 3 Shared 0x10394bcbc void kotlin::RepeatedTimer::Run::GCSchedulerDataWithTimer(kotlin::gc::GCSchedulerConfig&, std::__1::function)::'lambda'()>(kotlin::gc::internal::GCSchedulerDataWithTimer::GCSchedulerDataWithTimer(kotlin::gc::GCSchedulerConfig&, std::__1::function)::'lambda'()&&) + 556 4 Shared 0x10394c4d4 void* std::__1::__thread_proxy>, void (*)(kotlin::ScopedThread::attributes, void (kotlin::RepeatedTimer::*&&)(kotlin::gc::internal::GCSchedulerDataWithTimer::GCSchedulerDataWithTimer(kotlin::gc::GCSchedulerConfig&, std::__1::function)::'lambda'()&&) noexcept, kotlin::RepeatedTimer*&&, kotlin::gc::internal::GCSchedulerDataWithTimer::GCSchedulerDataWithTimer(kotlin::gc::GCSchedulerConfig&, std::__1::function)::'lambda'()&&), kotlin::ScopedThread::attributes, void (kotlin::RepeatedTimer::*)(kotlin::gc::internal::GCSchedulerDataWithTimer::GCSchedulerDataWithTimer(kotlin::gc::GCSchedulerConfig&, std::__1::function)::'lambda'()&&) noexcept, kotlin::RepeatedTimer*, kotlin::gc::internal::GCSchedulerDataWithTimer::GCSchedulerDataWithTimer(kotlin::gc::GCSchedulerConfig&, std::__1::function)::'lambda'()>>(void*) + 260 5 libsystem_pthread.dylib 0x1b1838428 _pthread_start + 116 6 libsystem_pthread.dylib 0x1b1833648 thread_start + 8 Thread 4:: GC thread 0 libsystem_kernel.dylib 0x1b17df694 __psynch_cvwait + 8 1 libsystem_pthread.dylib 0x1b18389e4 _pthread_cond_wait + 1220 2 libc++.1.dylib 0x1802809f4 std::__1::condition_variable::wait(std::__1::unique_lock&) + 24 3 Shared 0x103944d8c std::__1::invoke_result&, kotlin::gc::GCScheduler&)::$_3>::type kotlin::ScopedThread::Run&, kotlin::gc::GCScheduler&)::$_3>(kotlin::ScopedThread::attributes, kotlin::gc::ConcurrentMarkAndSweep::ConcurrentMarkAndSweep(kotlin::mm::ObjectFactory&, kotlin::gc::GCScheduler&)::$_3&&) + 300 4 Shared 0x103944f08 void* std::__1::__thread_proxy>, void (*)(kotlin::ScopedThread::attributes, kotlin::gc::ConcurrentMarkAndSweep::ConcurrentMarkAndSweep(kotlin::mm::ObjectFactory&, kotlin::gc::GCScheduler&)::$_3&&), kotlin::ScopedThread::attributes, kotlin::gc::ConcurrentMarkAndSweep::ConcurrentMarkAndSweep(kotlin::mm::ObjectFactory&, kotlin::gc::GCScheduler&)::$_3>>(void*) + 232 5 libsystem_pthread.dylib 0x1b1838428 _pthread_start + 116 6 libsystem_pthread.dylib 0x1b1833648 thread_start + 8 Thread 5: 0 libsystem_pthread.dylib 0x1b1833634 start_wqthread + 0 Thread 6: 0 libsystem_pthread.dylib 0x1b1833634 start_wqthread + 0 Thread 7: 0 libsystem_pthread.dylib 0x1b1833634 start_wqthread + 0 Thread 8:: com.apple.uikit.eventfetch-thread 0 libsystem_kernel.dylib 0x1b17dc190 mach_msg2_trap + 8 1 libsystem_kernel.dylib 0x1b17ed258 mach_msg2_internal + 76 2 libsystem_kernel.dylib 0x1b17e4398 mach_msg_overwrite + 540 3 libsystem_kernel.dylib 0x1b17dc500 mach_msg + 20 4 CoreFoundation 0x18039a4a8 __CFRunLoopServiceMachPort + 156 5 CoreFoundation 0x180394ad4 __CFRunLoopRun + 1128 6 CoreFoundation 0x180394254 CFRunLoopRunSpecific + 584 7 Foundation 0x180b994bc -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 208 8 Foundation 0x180b996e0 -[NSRunLoop(NSRunLoop) runUntilDate:] + 60 9 UIKitCore 0x105152714 -[UIEventFetcher threadMain] + 404 10 Foundation 0x180bbede0 __NSThread__start__ + 704 11 libsystem_pthread.dylib 0x1b1838428 _pthread_start + 116 12 libsystem_pthread.dylib 0x1b1833648 thread_start + 8 Thread 0 crashed with ARM Thread State (64-bit): x0: 0x0000000000000000 x1: 0x0000000000000000 x2: 0x0000000000000000 x3: 0x0000000000000000 x4: 0x0000600002b16a00 x5: 0x0000000000000000 x6: 0x0000000000000000 x7: 0x0000000000000000 x8: 0x0000000102708240 x9: 0x4055bf549d901fe4 x10: 0x000000016da6ee58 x11: 0x0000000158104558 x12: 0x0000000000000000 x13: 0x00000000000007fd x14: 0x00000000a5428870 x15: 0x00000000a5228072 x16: 0x0000000000000148 x17: 0x0000600002c100f0 x18: 0x0000000000000000 x19: 0x0000000000000006 x20: 0x0000000102708240 x21: 0x0000000000000103 x22: 0x0000000102708320 x23: 0x0000000102392700 x24: 0x000000016da6fd10 x25: 0x00000001023a8738 x26: 0x00000001bc8f5978 x27: 0x4000600000108d20 x28: 0x00000001bc8f5918 fp: 0x000000016da6f870 lr: 0x00000001b183812c sp: 0x000000016da6f850 pc: 0x00000001b17e3fa8 cpsr: 0x40001000 far: 0x000004fdd18e4100 esr: 0x56000080 Address size fault Binary Images: 0x10266c000 - 0x1026fbfff dyld (*) /usr/lib/dyld 0x10257c000 - 0x1025cbfff dyld_sim (*) <4eba7f04-0a30-3166-8a68-9125b8a1d5f9> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/dyld_sim 0x10238c000 - 0x1023a7fff duck.hansson.odd.ios (1.0) <58777694-be21-3b1c-8b91-846ec6038bd7> /Users/USER/Library/Developer/Xcode/UserData/Previews/Simulator Devices/3D6F16D8-2B4B-47FC-A471-DED791F64349/data/Containers/Bundle/Application/8492D742-B9D7-4F60-AB2F-CD4098EE7443/ios.app/ios 0x10248c000 - 0x1024d3fff com.apple.dt.PreviewsInjection (14.3) <2b6de7fe-add3-34d3-beb7-5907656cc116> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/PreviewsInjection.framework/PreviewsInjection 0x1036b4000 - 0x103ccffff duck.hansson.odd.shared.Shared (1.0) /Users/USER/Library/Developer/Xcode/UserData/Previews/Simulator Devices/3D6F16D8-2B4B-47FC-A471-DED791F64349/data/Containers/Bundle/Application/8492D742-B9D7-4F60-AB2F-CD4098EE7443/ios.app/Frameworks/Shared.framework/Shared 0x108610000 - 0x109bd3fff com.apple.SwiftUI (4.4.36.1.102) /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/SwiftUI.framework/SwiftUI 0x102a10000 - 0x102a77fff libswiftUIKit.dylib (*) /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/libswiftUIKit.dylib 0x102534000 - 0x102537fff com.apple.UIKit (1.0) <7e2b5d6b-224b-39a1-af92-5f3909a01490> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/UIKit.framework/UIKit 0x1028b4000 - 0x1028fbfff com.apple.DocumentManager (1.0) /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/DocumentManager.framework/DocumentManager 0x104634000 - 0x105d17fff com.apple.UIKitCore (1.0) <6726ae46-2599-3f92-adca-c48a0512d4ea> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore 0x102fd0000 - 0x1030bffff com.apple.ShareSheet (1885) /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/ShareSheet.framework/ShareSheet 0x102764000 - 0x1027effff com.apple.PrintKitUI (1.0) <74ff1df9-3f27-335a-9673-8991789c7e21> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/PrintKitUI.framework/PrintKitUI 0x102b6c000 - 0x102d03fff com.apple.WebKitLegacy (8615) /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Cryptexes/OS/System/Library/PrivateFrameworks/WebKitLegacy.framework/WebKitLegacy 0x10de3c000 - 0x10f2f3fff com.apple.JavaScriptCore (8615) <6c92ecb5-f484-3925-b8ac-132e313d11cc> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Cryptexes/OS/System/Library/Frameworks/JavaScriptCore.framework/JavaScriptCore 0x117588000 - 0x119d5ffff com.apple.WebCore (8615) /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Cryptexes/OS/System/Library/PrivateFrameworks/WebCore.framework/WebCore 0x10a700000 - 0x10aa67fff libANGLE-shared.dylib (*) <094a5d7d-536f-3c65-bf0f-42037de47f30> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Cryptexes/OS/System/Library/PrivateFrameworks/WebCore.framework/Frameworks/libANGLE-shared.dylib 0x102964000 - 0x1029bbfff com.apple.WebGPU (8615) <84b58cce-be36-3c7e-8f54-801c8cb3c7fa> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Cryptexes/OS/System/Library/PrivateFrameworks/WebGPU.framework/WebGPU 0x1077cc000 - 0x10821ffff libwebrtc.dylib (*) /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Cryptexes/OS/System/Library/PrivateFrameworks/WebCore.framework/Frameworks/libwebrtc.dylib 0x102610000 - 0x102623fff com.apple.RecapPerformanceTesting (17) /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/RecapPerformanceTesting.framework/RecapPerformanceTesting 0x10ac74000 - 0x10addffff com.apple.chronokit (1.0) <646ed4dc-664b-37b1-99c5-350381e4621b> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/ChronoKit.framework/ChronoKit 0x10aeb8000 - 0x10afd7fff com.apple.widgetkit (1.0) /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/WidgetKit.framework/WidgetKit 0x102544000 - 0x10255bfff com.apple.dt.PreviewsOSSupportUI (14.3) <5bab1eb4-c81c-3e3a-8edc-b15bcacdb085> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/PreviewsOSSupportUI.framework/PreviewsOSSupportUI 0x102f68000 - 0x102f93fff com.apple.dt.PreviewsServicesUI (14.3) /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/PreviewsServicesUI.framework/PreviewsServicesUI 0x102ebc000 - 0x102ee3fff com.apple.BaseBoardUI (617.107) <173814de-7bee-3fd3-a6cc-3fd9f89a0bd1> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/BaseBoardUI.framework/BaseBoardUI 0x1032dc000 - 0x103303fff com.apple.chronouiservices (1.0) <0d419660-ac2f-30c9-8a2c-99f6052e7224> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/ChronoUIServices.framework/ChronoUIServices 0x103344000 - 0x10335ffff com.apple.MaterialKit (1.0) /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/MaterialKit.framework/MaterialKit 0x103214000 - 0x10326bfff com.apple.internal.ActivityUIServices (1.0) <4c169598-dc07-3244-8fd2-c66a18c93f5d> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/ActivityUIServices.framework/ActivityUIServices 0x1034d4000 - 0x103517fff com.apple.PlatterKit (1.0) /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/PlatterKit.framework/PlatterKit 0x103434000 - 0x10344bfff libswiftExtensionKit.dylib (*) <3b6af021-32be-3dfc-9feb-cca7b5deb936> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/libswiftExtensionKit.dylib 0x102f1c000 - 0x102f33fff com.apple.ExtensionKit (97) <7c6fe311-0f0c-32d2-b323-5f0e25540283> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/ExtensionKit.framework/ExtensionKit 0x10b588000 - 0x10b697fff com.apple.preferences-framework (1) <57984a86-c974-3534-8fa5-c3d2e29b4be7> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/Preferences.framework/Preferences 0x10b370000 - 0x10b40bfff com.apple.BacklightServicesHost (1.0) /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/BacklightServicesHost.framework/BacklightServicesHost 0x103484000 - 0x103497fff com.apple.settingsandcoreapps.SettingsFoundation (1.0) <6b8b3380-36ef-39a4-9171-22a55f2dc229> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/SettingsFoundation.framework/SettingsFoundation 0x103418000 - 0x103423fff libobjc-trampolines.dylib (*) <806ae646-0aee-359b-883f-e4018780ec94> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libobjc-trampolines.dylib 0x103698000 - 0x10369bfff ContentView.1.preview-thunk.dylib (*) /Users/USER/Library/Developer/Xcode/DerivedData/ios-gqblrasochcoajatuyocronxorua/Build/Intermediates.noindex/Previews/ios/Intermediates.noindex/ios.build/Debug-iphonesimulator/ios.build/Objects-normal/arm64/ContentView.1.preview-thunk.dylib 0x1b17db000 - 0x1b1812fe7 libsystem_kernel.dylib (*) /usr/lib/system/libsystem_kernel.dylib 0x1b1831000 - 0x1b183dff7 libsystem_pthread.dylib (*) <73f649ed-142d-3aad-b3af-3fe33548b725> /usr/lib/system/libsystem_pthread.dylib 0x1800b6000 - 0x180130ffb libsystem_c.dylib (*) <6b3ced39-3f0d-3bb2-a2b1-34062cf5c8eb> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libsystem_c.dylib 0x184a1c000 - 0x184a6efff com.apple.BoardServices (1.0) <170a1733-6f68-37eb-bc4b-1379497bffc0> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/BoardServices.framework/BoardServices 0x180131000 - 0x180177fff libdispatch.dylib (*) <392b7c55-8c38-3dea-b7af-c3d7f518e987> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libdispatch.dylib 0x180315000 - 0x1806c3fff com.apple.CoreFoundation (6.9) <132e87d0-14ac-310c-a5e9-3d9c921cc8ea> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation 0x188eb4000 - 0x188ebcfff com.apple.GraphicsServices (1.0) <8e24edb2-1c99-3652-9ef0-e66191675515> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices 0x18026e000 - 0x1802efff7 libc++.1.dylib (*) /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libc++.1.dylib 0x18073a000 - 0x180f8bfff com.apple.Foundation (6.9) /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/Foundation.framework/Foundation EOF

The code that crashed the preview is this view binding of a view model. If it's removed the preview works.

struct ContentView: View {
    @ObservedViewModel var viewModel = SharedModule().homeViewModel

    var body: some View {
        VStack {
            Image(systemName: "globe")
                .imageScale(.large)
                .foregroundColor(.accentColor)
            Text(viewModel.state.query)
        }
        .padding()
    }
}

I'm using Koin for dependency injection and I've confirmed it's not the issue as this code works in the preview.

struct ContentView: View {
    var body: some View {
        VStack {
            Image(systemName: "globe")
                .imageScale(.large)
                .foregroundColor(.accentColor)
            Text(SharedModule().homeViewModel.state.query)
        }
        .padding()
    }
}
kansson commented 1 year ago

Have been looking for similar problems and found this https://github.com/JetBrains/kotlin-native/issues/3059#issuecomment-501699248. Maybe this could help with solving this problem?

rickclephas commented 1 year ago

Hi! Thanks for reporting this. I just checked with the sample project which has working SwiftUI previews. Could you possibly share some more details about your project setup?

kansson commented 1 year ago

Sure here is a reproduction https://github.com/hanssonduck/XcodePreview. Now when I'm looking at it maybe this package isn't the problem.

What I did was delete the default Xcode project and created a new Xcode multiplatform project and then linking it with Kotlin following this https://kotlinlang.org/docs/multiplatform-mobile-integrate-in-existing-app.html#connect-the-framework-to-your-ios-project. Seems that maybe I did something wrong here. New to Xcode and Swift development so not sure, maybe you can see something. You can compare the two commits to see the working and broken states.

TLDR: Generated new multiplatform Xcode project that broke the preview.

kansson commented 1 year ago

Hi again, got it working with this solution https://stackoverflow.com/a/71214308/10055887. Not sure what the problem is but it works and I'm happy. If you do find something of interest feel free to mention it nonetheless.