Checklists: App Delegate SIGABRT Error

I’m nearly at the end of the Checklists Tutorial at page 252 (version 5), just finished adding the Date Picker and I’m getting a crash when I click on the Date Picker in the Simulator.

At first I thought there was some “Thread 1 Breakpoint” error so I thought it was an accidental breakpoint. I clicked on a button that said disable breakpoints, but then I consistently get a crash with the error on the App Delegate swift up the top with the class line highlighted saying “Thread 1: signal SIGABRT”.

My debug console text has this in it:
"2018-06-27 21:33:10.693447+1000 Checklists[5131:141931] [LayoutConstraints] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don’t want.
Try this:
(1) look at each constraint and try to figure out which you don’t expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
“<NSLayoutConstraint:0x600000288610 UILabel:0x7fa899f266e0.height == 21 (active)>”,
“<NSLayoutConstraint:0x600000288750 V:[UILabel:0x7fa899f266e0]-(11.5)-| (active, names: ‘|’:UITableViewCellContentView:0x7fa899c0c480 )>”,
“<NSLayoutConstraint:0x6000002887f0 V:|-(11)-[UILabel:0x7fa899f266e0] (active, names: ‘|’:UITableViewCellContentView:0x7fa899c0c480 )>”,
“<NSLayoutConstraint:0x600000288c00 ‘UIView-Encapsulated-Layout-Height’ UITableViewCellContentView:0x7fa899c0c480.height == 43.6667 (active)>”
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600000288610 UILabel:0x7fa899f266e0.height == 21 (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2018-06-27 21:33:10.705097+1000 Checklists[5131:141931] [LayoutConstraints] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don’t want.
Try this:
(1) look at each constraint and try to figure out which you don’t expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
“<NSLayoutConstraint:0x604000282940 UILabel:0x7fa899c0d630.height == 21 (active)>”,
“<NSLayoutConstraint:0x6040002828f0 V:[UILabel:0x7fa899c0d630]-(11.5)-| (active, names: ‘|’:UITableViewCellContentView:0x7fa899c0d150 )>”,
“<NSLayoutConstraint:0x604000282b70 V:|-(11)-[UILabel:0x7fa899c0d630] (active, names: ‘|’:UITableViewCellContentView:0x7fa899c0d150 )>”,
“<NSLayoutConstraint:0x604000282ee0 ‘UIView-Encapsulated-Layout-Height’ UITableViewCellContentView:0x7fa899c0d150.height == 43.6667 (active)>”
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x604000282940 UILabel:0x7fa899c0d630.height == 21 (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2018-06-27 21:33:15.632108+1000 Checklists[5131:141931] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /Users/tongrd/Library/Developer/CoreSimulator/Devices/D9691320-1157-4E7A-89B5-B7A2E1E1A48A/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2018-06-27 21:33:15.633365+1000 Checklists[5131:141931] [MC] Reading from private effective user settings.
2018-06-27 21:33:16.194031+1000 Checklists[5131:141931] [Warning] Warning once only: Detected a case where constraints ambiguously suggest a height of zero for a tableview cell’s content view. We’re considering the collapse unintentional and using standard height instead.
2018-06-27 21:33:16.225631+1000 Checklists[5131:141931] [Common] _BSMachError: port 7603; (os/kern) invalid capability (0x14) “Unable to insert COPY_SEND”
2018-06-27 21:33:18.793543+1000 Checklists[5131:141931] *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3698.54.4/UITableView.m:1771
2018-06-27 21:33:18.798700+1000 Checklists[5131:141931] *** Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘attempt to insert row 2 into section 1, but there are only 2 rows in section 1 after the update’
*** First throw call stack:
(
0 CoreFoundation 0x00000001107c51e6 __exceptionPreprocess + 294
1 libobjc.A.dylib 0x000000010fe5a031 objc_exception_throw + 48
2 CoreFoundation 0x00000001107ca472 +[NSException raise:format:arguments:] + 98
3 Foundation 0x000000010f8fd652 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
4 UIKit 0x0000000110d617d4 -[UITableView _endCellAnimationsWithContext:] + 9360
5 UIKit 0x0000000110d7ed33 -[UITableView _updateRowsAtIndexPaths:withUpdateAction:rowAnimation:usingPresentationValues:] + 1383
6 UIKit 0x0000000110d7ee06 -[UITableView insertRowsAtIndexPaths:withRowAnimation:] + 118
7 Checklists 0x000000010f51891d _T010Checklists24ItemDetailViewControllerC14showDatePickeryyF + 525
8 Checklists 0x000000010f5170dc _T010Checklists24ItemDetailViewControllerC05tableD0ySo07UITableD0C_10Foundation9IndexPathV14didSelectRowAttF + 604
9 Checklists 0x000000010f51716c _T010Checklists24ItemDetailViewControllerC05tableD0ySo07UITableD0C_10Foundation9IndexPathV14didSelectRowAttFTo + 92
10 UIKit 0x0000000110d80e89 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1813
11 UIKit 0x0000000110d810a4 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 344
12 UIKit 0x0000000110c4d4b3 _runAfterCACommitDeferredBlocks + 318
13 UIKit 0x0000000110c3c71e _cleanUpAfterCAFlushAndRunDeferredBlocks + 388
14 UIKit 0x0000000110c6aea5 _afterCACommitHandler + 137
15 CoreFoundation 0x0000000110767607 CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 23
16 CoreFoundation 0x000000011076755e __CFRunLoopDoObservers + 430
17 CoreFoundation 0x000000011074bb81 __CFRunLoopRun + 1537
18 CoreFoundation 0x000000011074b30b CFRunLoopRunSpecific + 635
19 GraphicsServices 0x000000011634ba73 GSEventRunModal + 62
20 UIKit 0x0000000110c42057 UIApplicationMain + 159
21 Checklists 0x000000010f525ea7 main + 55
22 libdyld.dylib 0x0000000114c91955 start + 1
23 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) "

Help! I’m so close to finishing this tutorial!!

I don’t have version 5 of this book, but I know a little bit about LLDeBugger output - For the time being I’ll do my best to help with what I can.

You have conflicting Layout Constraints

Specifically a UILabel object in the heap who’s height == 21
The UILabel’s nstance is 0x7fa899c0d630, and it’s constraint object instance is 0x604000282940

You can try setting it’s constraint priority value to 999 (it’s at 1000 right now).
To do this: Select the constraint, and in the Size Inspector set it’s priority to 999.
If that doesn’t work, try deleting the constraint.

You’re probably going to want to create a break point on or near the code that is controlling the height of the tableViewCell, if you don’t know how to utilize breakpoints, you can also use print statements describing the code around it, and see where exceptions are thrown in respect to your print outs.

Example:

viewDidLoad {
print("viewDidLoad successful")  // add this
}

See if it prints. If not, viewDidLoad() failed.

Specifically look at this area. This is the reason why your app crashed.

Xcode seems to have remedied your zero height collapse, and has broken other parts in your code as a result, so it might be a good idea to make these printouts in your TableView datasource & delegate methods that have to do with that IndexPath.

I don’t know if it will help, but here are some screenshots & my code for anything that had to do with IndexPath(row: 2, section: 1)

Screen Shots

My Document Outline

My Code

UITableView Data Source

/// Asks the data source for a cell to insert in a particular location of the table view.
override func tableView(_ tableView: UITableView,
             cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  if indexPath == IndexPath(row: 2, section: 1) {
    return datePickerCell
  } else {
    return super.tableView(tableView, cellForRowAt: indexPath)
  }
}

UITableView Delegates

/// Asks the delegate for the height to use for a row in a specified location.
override func tableView(_ tableView: UITableView,
           heightForRowAt indexPath: IndexPath) -> CGFloat {
  if indexPath == IndexPath(row: 2, section: 1) {
    return 217
  } else {
    return super.tableView(tableView, heightForRowAt: indexPath)
  }
}

/// Tells the delegate that the specified row is now selected.
override func tableView(_ tableView: UITableView,
           didSelectRowAt indexPath: IndexPath) {
  tableView.deselectRow(at: indexPath, animated: true)
  textField.resignFirstResponder()
  
  if indexPath == IndexPath(row: 1, section: 1) {
    datePickerVisible ? hideDatePicker() : showDatePicker()
  }
}

/// Asks the delegate to return the level of indentation for a row in a given section.
override func tableView(_ tableView: UITableView,
                        indentationLevelForRowAt indexPath: IndexPath) -> Int {
  var newIndexPath = indexPath
  if indexPath == IndexPath(row: 2, section: 1) {
    newIndexPath = IndexPath(row: 0, section: indexPath.section)
  }
  return super.tableView(tableView, indentationLevelForRowAt: newIndexPath)
}

The author of the book is a pro and will better be able to assist you :+1:

Good luck
Rebecca

Thanks for the help Rebecca. Went through all the instructions again and I had actually missed adding a numberOfRowsInSection override function!! No wonder there was an error, Xcode had no idea how many number of rows there were!

This topic was automatically closed after 166 days. New replies are no longer allowed.