Hi, curious if SwiftUI previews still work for eve...
# multiplatform
a
Hi, curious if SwiftUI previews still work for everyone with Kotlin 1.4.21 and Xcode 12.3 - tried both with my project and with @John O'Reilly’s PeopleInSpace, but getting the same crash during preview:
Copy code
Application Specific Information:
abort() called
CoreSimulator 732.18.6 - Device: iPod touch (7th generation) (DE2D8C92-2BA3-4592-8CF0-D838EA741FBC) - Runtime: iOS 14.3 (18C61) - DeviceType: iPod touch (7th generation)

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	0x00007fff60c58462 __pthread_kill + 10
1   libsystem_pthread.dylib       	0x00007fff60c91610 pthread_kill + 263
2   libsystem_c.dylib             	0x00007fff200fab94 abort + 120
3   MorphologyWordView.2.preview-thunk.dylib	0x000000010f035b19 konan::abort() + 9
4   MorphologyWordView.2.preview-thunk.dylib	0x000000010f03598c RuntimeAssertFailed(char const*, char const*) + 156
5   MorphologyWordView.2.preview-thunk.dylib	0x000000010f04fa8f __Kotlin_ObjCExport_initialize_block_invoke + 1055
6   libdispatch.dylib             	0x00007fff20106508 _dispatch_client_callout + 8
7   libdispatch.dylib             	0x00007fff2010775d _dispatch_once_callout + 20
8   MorphologyWordView.2.preview-thunk.dylib	0x000000010f04f664 Kotlin_ObjCExport_initialize + 36
9   MorphologyWordView.2.preview-thunk.dylib	0x000000010eb1bab7 +[KotlinBase initialize] + 55
10  libobjc.A.dylib               	0x00007fff20178453 CALLING_SOME_+initialize_METHOD + 17
11  libobjc.A.dylib               	0x00007fff20179326 initializeNonMetaClass + 717
12  libobjc.A.dylib               	0x00007fff201790b0 initializeNonMetaClass + 87
13  libobjc.A.dylib               	0x00007fff2017a3ad initializeAndMaybeRelock(objc_class*, objc_object*, mutex_tt<false>&, bool) + 173
14  libobjc.A.dylib               	0x00007fff20185b8f lookUpImpOrForward + 668
15  libobjc.A.dylib               	0x00007fff2017421b _objc_msgSend_uncached + 75
16  MorphologyWordView.2.preview-thunk.dylib	0x000000010f39a73e type metadata accessor for SharedCodeWordMorphology + 30
17  net.cafesalam.QuranSearch     	0x000000010c147d33 static MorphologyWordView_Previews.previews.getter + 115 (MorphologyWordView.swift:37)
18  net.cafesalam.QuranSearch     	0x000000010c148489 protocol witness for static PreviewProvider.previews.getter in conformance MorphologyWordView_Previews + 9
actual app works fine on both Android and iOS - and in my case at least this is just a
data class
that i am using in the preview / swift ui code that causes this crash. i saw a similar part of the crash reason in the case of PeopleInSpace also:
Copy code
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	0x00007fff60c58462 __pthread_kill + 10
1   libsystem_pthread.dylib       	0x00007fff60c91610 pthread_kill + 263
2   libsystem_c.dylib             	0x00007fff200fab94 abort + 120
3   ContentView.2.preview-thunk.dylib	0x000000010451b0d9 konan::abort() + 9
4   ContentView.2.preview-thunk.dylib	0x000000010451af4c RuntimeAssertFailed(char const*, char const*) + 156
5   ContentView.2.preview-thunk.dylib	0x000000010453504f __Kotlin_ObjCExport_initialize_block_invoke + 1055
6   libdispatch.dylib             	0x00007fff20106508 _dispatch_client_callout + 8
7   libdispatch.dylib             	0x00007fff2010775d _dispatch_once_callout + 20
8   ContentView.2.preview-thunk.dylib	0x0000000104534c24 Kotlin_ObjCExport_initialize + 36
9   ContentView.2.preview-thunk.dylib	0x0000000104532a02 (anonymous namespace)::initRuntime() + 194
10  ContentView.2.preview-thunk.dylib	0x00000001045325af Kotlin_initRuntimeIfNeeded + 31
11  ContentView.2.preview-thunk.dylib	0x0000000104003dbe -[NSArray(NSArrayToKotlin) toKotlin:] + 30
12  com.surrus.PeopleInSpaceSwiftUI	0x000000010108fc61 Kotlin_Interop_refFromObjC + 65
13  com.surrus.PeopleInSpaceSwiftUI	0x00000001011b0006 kfun:co.touchlab.sqliter.DatabaseFileContext#iosDirPath(kotlin.String){}kotlin.String + 566
anyone have any luck working around this or any ideas of what to look at?
tried to repro this in some sample projects but can’t find a reliable enough repro to open a ticket with (though can see it in other projects like PeopleInSpace as mentioned above) - the odd thing is there is no business logic in these classes, they’re just pure
data
classes with vanilla field types - also this was working at some point in the past. a not-so-ideal workaround is to avoid using the KMP model classes directly in SwiftUI code and have a mapping layer instead.