Xcode 8 not printing exception reason

Something is wrong with my project. It doesn't print assertion messages when debugging application and the app crashes. Normally it should display something like this:


2017-02-05 20:13:54.687 MyPlayground[29372:221950] *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3600.6.21/UITableView.m:1610 
2017-02-05 20:13:54.690 MyPlayground[29372:221950] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (10) must be equal to the number of rows contained in that section before the update (10), plus or minus the number of rows inserted or deleted from that section (1 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'


But all I get is first message. I only know that assertion failed and I get no explanation why. This makes debugging a lot more difficult than it should be because of not knowing what is the cause of the crash.


2017-02-05 20:07:00.958 myProject[28876:215448] *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3600.6.21/UITableView.m:1315


I looked around and someone suggested that this might be because optimizations are turned on, but that's not the case. Both my project and target have optimization for debug set to None and I'm sure I'm running my project with debug configuration. I tried everything I could and nothing helped so far, I'm running out of ideas what this might be.


I'm using Xcode 8, project is mixed Swift 3.0 + Objective-C. I used to have cocoapods, but I switched to Carthage (I hoped that this might help, but that wasn't it).

Replies

You're not alone. It's happening to me too, and I'm disappointed nobody has responded to this.


I guessed that it was because I was frankensteining my Xcode 8 app to add the SDK from Xcode 7, but I've since (finally) made to upgrade to Swift 3 / iOS10 SDK and have reinstalled Xcode.app from scratch. And today I found that the missing reason log is still happening.


I've resorted to opening the system log in the Devices window, wading through the spam to find the crash report which does include the explanation. (which intersects another long-standing "bug", the number of lines logged to that window from an ios device makes it rather unusable).

(which intersects another long-standing "bug", the number of lines logged to that window from an ios device makes it rather unusable)

Console app has really good filtering support. If there’s some specific log entry you want to look for, I recommend that you set up and save a filter for that so you can quickly go back to it in the future. For examples of this, watch the demo in WWDC 2016 Session 721 Unified Logging and Activity Tracing.

Notwithstanding the above, it is weird that your Xcode isn’t displaying uncaught exceptions. My recommendation is that you create a new test project, configure it to force an exception, and see if that reproduces the problem. I did this (my table view controller code is pasted in below) and I definitely see the expected exception backtrace.

If you continue to see the problem in your main app but don’t see it in your test app then you know that it’s something to do with how your main app is set up. The first thing I’d look at there is third-party crash reporters. If you’re using one, you should temporarily remove it to see if that changes things.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

WWDC runs Mon, 5 Jun through to Fri, 9 Jun. During that time all of DTS will be at the conference, helping folks out face-to-face. http://developer.apple.com/wwdc/

import UIKit

class MainViewController : UITableViewController {

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 5
    }

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        return tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
    }

    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView.insertRows(at: [IndexPath(row: 0, section: 0)], with: .none)
        tableView.deselectRow(at: indexPath, animated: true)
    }
}

I just had this problem with XCode 9.


Becase I was getting way too many console messages, I set the scheme environment variable OS_ACTIVITY_MODE to "disable". Removing this variable, I was able to get the exception stacktrace to print again. (Among all the other ******* the OS was spewing out.)


Thought I'd reply to this, even though the original posting was a couple years ago, since there weren't any other solutions posted.