SIGABRT in Chapter 4, p. 71

Just after adding the UIHostingController(coder: coder… code to the @IBSegueAction, I run and get SIGABRT. Not sure why. I’ve compared to final code and cannot find differences. I’m running XCode 11.2.1 on Catalina 10.15.1. Debug below. FYI, the text sometimes directs us to certain files, but it is not always clear which ones. The fact that we are using the BullsEye and RGBullsEye over many chapters can be confusing. Please reference with keen specificity. For instance, p. 68 mentions RGBullsEye from Chpt 2 and Chpt 3 in folder. I only see one RGBullsEye. Then on the next page, we are dragging from the finder. I’m hoping the one I got was correct, but how would I know?

2019-12-09 11:28:16.325246-0500 BullsEye[19120:12275448] -[UIButton _initializeClassSwapperWithCurrentDecodingViewControllerIfNeeded:]: unrecognized selector sent to instance 0x7f934a0263f0
2019-12-09 11:28:16.333360-0500 BullsEye[19120:12275448] *** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[UIButton _initializeClassSwapperWithCurrentDecodingViewControllerIfNeeded:]: unrecognized selector sent to instance 0x7f934a0263f0’
*** First throw call stack:
(
0 CoreFoundation 0x000000011187302e __exceptionPreprocess + 350
1 libobjc.A.dylib 0x000000010e1a9b20 objc_exception_throw + 48
2 CoreFoundation 0x0000000111893f94 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 UIKitCore 0x000000011ba72f39 -[UIResponder doesNotRecognizeSelector:] + 302
4 CoreFoundation 0x0000000111877dac forwarding + 1436
5 CoreFoundation 0x0000000111879f38 _CF_forwarding_prep_0 + 120
6 UIKitCore 0x000000011b3c1d78 -[UIViewController initWithCoder:] + 130
7 SwiftUI 0x000000010e8ed96f $s7SwiftUI19UIHostingControllerC5coder8rootViewACyxGSgSo7NSCoderC_xtcfc + 127
8 SwiftUI 0x000000010e8ed8e5 $s7SwiftUI19UIHostingControllerC5coder8rootViewACyxGSgSo7NSCoderC_xtcfC + 53
9 BullsEye 0x000000010d859e26 $s8BullsEye14ViewControllerC011openRGBullsB0ySo06UIViewD0CSgSo7NSCoderCF + 294
10 BullsEye 0x000000010d859f95 $s8BullsEye14ViewControllerC011openRGBullsB0ySo06UIViewD0CSgSo7NSCoderCFTo + 69
11 UIKitCore 0x000000011ba45dfa -[UIApplication sendAction:to:from:forEvent:] + 83
12 UIKitCore 0x000000011b41fc22 -[UIControl sendAction:to:forEvent:] + 223
13 UIKitCore 0x000000011b41ff6c -[UIControl _sendActionsForEvents:withEvent:] + 398
14 UIKitCore 0x000000011b41eecb -[UIControl touchesEnded:withEvent:] + 481
15 UIKitCore 0x000000011ba80c1d -[UIWindow _sendTouchesForEvent:] + 2604
16 UIKitCore 0x000000011ba82524 -[UIWindow sendEvent:] + 4596
17 UIKitCore 0x000000011ba5d427 -[UIApplication sendEvent:] + 356
18 UIKitCore 0x000000011bade87e __dispatchPreprocessedEventFromEventQueue + 6847
19 UIKitCore 0x000000011bae1344 __handleEventQueueInternal + 5980
20 CoreFoundation 0x00000001117d6221 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
21 CoreFoundation 0x00000001117d614c __CFRunLoopDoSource0 + 76
22 CoreFoundation 0x00000001117d5924 __CFRunLoopDoSources0 + 180
23 CoreFoundation 0x00000001117d062f __CFRunLoopRun + 1263
24 CoreFoundation 0x00000001117cfe16 CFRunLoopRunSpecific + 438
25 GraphicsServices 0x00000001133f0bb0 GSEventRunModal + 65
26 UIKitCore 0x000000011ba44b48 UIApplicationMain + 1621
27 BullsEye 0x000000010d85bb7b main + 75
28 libdyld.dylib 0x0000000112730c25 start + 1
29 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

hi! there’s only one RGBullsEye project in the starter folder: I’ll edit the text to say “modified with a few of the improvements from Chapter 3”. Sorry for the confusion.

the screenshot shows the RGBullsEye project open in Finder, with ContentView.swift selected, and an arrow indicating where to drag it. Hopefully, if it’s clear there’s only one RGBullsEye project, then It will be clear which file to drag.

However, I’ve noticed that sometimes the “Copy items if needed” doesn’t work. Check the File Inspector for ContentView.swift in your BullsEye project, to make sure it really is in BullsEye/BullsEye.

I can’t reproduce your SIGABRT, even if I change a letter in openRGBullsEye, the console shows a message, but the app only hangs, with no SIGABRT or call stack.

At what point do you get the SIGABRT? when you tap Play RGBullsEye?

Does the final project run OK?

Thanks for responding. The problem was happening when I pressed the Play RGBullsEye button. However, it is no longer happening. I disconnected everything and reworked steps 3 and 4. Now it works. Yesterday, I scrutinized the code carefully, but perhaps I made some erroneous connection; or, maybe was just a fluke. Who knows? Either way it is working now.

I appreciate how much work you and your team put into these books, and it feels comforting to know that the authors take pride in their work and want to make a great product. Thanks!

thanks for the update! catalina and Xcode are still a little flaky, even the non-beta versions, but their phantom problems are usually less specific than what you got. glad it’s working now :slight_smile: