Debugging Core Data In Xcode 8.1 Not Working?

I was working on a new project this weekend and I came across an issue using Xcode 8.1 that I’d not seen in 8.0 – The debug info from Core Data wasn’t being pushed to the console in Xcode.

Now if you’ve not worked with Core Data before, or never had to look hard under the hood at what it’s doing when to add items to it you may never have come across -com.apple.CoreData.SQLDebug before. This is a runtime argument that is passed in to your app at launch that (depending on the logging level – 1 through 3) spews out in-depth info on what is being inserted etc in to your Core Data store.

I tend to use:

-com.apple.CoreData.SQLDebug 3

As I said this worked fine in Xcode 8, but stopped working in Xcode 8.1. Unsurprisingly it was because there had been a change to how logging in general is handled in Core Data with macOS 12.0 and iOS 10.0 onwards. Now you need to add an additional argument to the run arguments:

-com.apple.CoreData.Logging.stderr 1

You can see both entries in the screenshot of my scheme entry below (click to open a larger version).

Core Data debugging in Xcode 8.1

Obviously if I had read the update notes for Core Data in Xcode 8.1, I would have seen this tucked away near the bottom – but I’m a typical bloke and therefore I read no instructions whatsoever and all of my Ikea furniture is wonky because of it :p.

Hopefully you’re not like me and you’ve had time to read this instead, and your flat-packed furniture is well made?

Mike Jones