Making com.apple.CoreData.ConcurrencyDebug 1 work

I am trying to port some code to use NSManagedObjectContext with NSPrivateQueueConcurrencyType .

Sometimes I get very strange errors after saving the context to its parent and then saving the parent. I am wondering if they should not use the NSPrivateQueueConcurrencyType context NSPrivateQueueConcurrencyType .

I have included -com.apple.CoreData.ConcurrencyDebug 1 to try to debug this. I am sure this does not work. If I perform operations in the context of a managed object or modify its objects without using performBlock: I do not get an error or throw.

This is how I set the arguments of the schema: Schema edit . I also tried it without a presenter.

Any idea what I'm doing wrong?

+5
source share
2 answers

The -com.apple.CoreData.ConcurrencyDebug argument is available from iOS> 8 and OSX> 10.10: make sure you are aiming for the right platform.

The console should register this if the flag is enabled:

CoreData: annotation: Core Data multi-threading assertions enabled.

Source: Concurrency Master Data Debugging from Ole Begemann

+5
source

Working with Xcode 8.x and iOS 10.x, I would like to provide an ordered answer for those who want to implement this now.

First you need to change the schema for your application:

enter image description here

As soon as you select โ€œSchemeโ€, select โ€œEdit Schemeโ€, which should appear at the bottom of the list: enter image description here

When opening, make sure you select Run and select Arguments. You will want to copy the following values โ€‹โ€‹to:

  • -com.apple.CoreData.ConcurrencyDebug 1
  • -com.apple.CoreData.Logging.stderr 1

Your screen should look like this: enter image description here

After starting the application, you will see that it is displayed in the console now that these options are enabled:

CoreData: annotation: Core Data multithreading statements included.

And when you come across this exception thrown, you will most likely see this:

CoreData` + [NSManagedObjectContext Multithreading_Violation_AllThatIsLeftToUsIsHonor ]

You can return to the schematic editor and disable this logging if necessary to prevent future exceptions.

+2
source

All Articles