nicklockwood / layout

A declarative UI framework for iOS
MIT License
2.23k stars 97 forks source link

SIGABRT when trying to instantiate a subclass of UITableView #158

Closed cadrega closed 5 years ago

cadrega commented 5 years ago

I created a subclass of UIButton in swift:

class MyView : UIButton {
}

and added it successfully to an XML:

<MyView backgroundColor="red" ...></MyView>

However, changing the swift file to:

class MyView : UITableView {
}

results in the sending of SIGABRT to thread 1, and

libc++abi.dylib: terminating with uncaught exception of type NSException

is printed in the Xcode output.

Xcode 9.3.1, trying to play with the Layout SampleApp, modifying the Table example.

TwunTee commented 5 years ago

Can you post the full stacktrace would be easier to know what is happening

cadrega commented 5 years ago

Stack trace is:

libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x0000000113acbb66 libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x0000000113b05080 libsystem_pthread.dylib`pthread_kill + 333
    frame #2: 0x000000010b5da5e5 libclang_rt.tsan_iossim_dynamic.dylib`wrap_pthread_kill + 325
    frame #3: 0x0000000113726c97 libsystem_c.dylib`abort + 127
    frame #4: 0x000000010b5d931c libclang_rt.tsan_iossim_dynamic.dylib`wrap_abort + 108
    frame #5: 0x00000001134bbe6f libc++abi.dylib`abort_message + 245
    frame #6: 0x00000001134bc00b libc++abi.dylib`default_terminate_handler() + 265
    frame #7: 0x000000010db3a2ae libobjc.A.dylib`_objc_terminate() + 97
    frame #8: 0x00000001134d90ae libc++abi.dylib`std::__terminate(void (*)()) + 8
    frame #9: 0x00000001134d9123 libc++abi.dylib`std::terminate() + 51
    frame #10: 0x000000010db3a233 libobjc.A.dylib`objc_terminate + 9
    frame #11: 0x00000001135de85c libdispatch.dylib`_dispatch_client_callout + 28
    frame #12: 0x00000001135e3e14 libdispatch.dylib`_dispatch_block_invoke_direct + 592
    frame #13: 0x000000011743e470 FrontBoardServices`__FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
    frame #14: 0x000000011743e12e FrontBoardServices`-[FBSSerialQueue _performNext] + 439
    frame #15: 0x000000011743e68e FrontBoardServices`-[FBSSerialQueue _performNextFromRunLoopSource] + 45
    frame #16: 0x0000000111315bb1 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    frame #17: 0x00000001112fa4af CoreFoundation`__CFRunLoopDoSources0 + 271
    frame #18: 0x00000001112f9a6f CoreFoundation`__CFRunLoopRun + 1263
    frame #19: 0x00000001112f930b CoreFoundation`CFRunLoopRunSpecific + 635
    frame #20: 0x0000000115ae5a73 GraphicsServices`GSEventRunModal + 62
    frame #21: 0x000000010eae30b7 UIKit`UIApplicationMain + 159
  * frame #22: 0x000000010b4f4e42 SampleApp`main at AppDelegate.swift:15
    frame #23: 0x000000011365b955 libdyld.dylib`start + 1
    frame #24: 0x000000011365b955 libdyld.dylib`start + 1
(lldb) 

Layout is version 0.6.32, the only modified/added files are attached here Archive.zip

cadrega commented 5 years ago

Since I needed to subclass UITableView for adding some custom code, but that lead to the above crash, I subclassed UIView and instead added a UITableView as a subview of my subclass. This is a workaround path that can be followed in the meantime, hoping that this can be sorted out soon!

nicklockwood commented 5 years ago

@cadrega this should be fixed in the latest release: 0.6.34. Let me know if not.

cadrega commented 4 years ago

Sorry for the late reply, but I can confirm the fix (although at this time, I skipped 0.6.34 and tested directly 0.6.38)