Incompatible CoreData version crash

I’ve got a Mac application, which uses CoreData. The usage of the framework is rather moderate, nothing really fancy about it. The application is build with SDK 11 (1Big Sur), but the minimal deployment target is Sierra (10.12).

The last “successful” build was made using Xcode 12.4 (12D4e) and it used SDK version 11.1. After I updated Xcode to the latest version 12.5.1 (12E507) it apparently updated SDK version to 11.3 and I started getting problems dynamically linking to CoreData version on older versions of macOS. The application works okay on Mojave and later, but on High Sierra and earlier it crashes on launch with the following error:

Dyld Error Message: Library not loaded: /System/Library/Frameworks/CoreData.framework/CoreData Referenced from: /Applications/MyApp Reason: Incompatible library version: MyApp requires version 300.0.0 or later, but CoreData provides version 1.0.0

Now, the interesting thing is that I’ve got yet another macOS app, which also uses CoreData in a very similar fashion like the first one. It’s also built with Xcode 12.5.1 / SDK 11.3 and it runs fine on everything from Sierra to Monterey. The only difference related to CoreData usage is that the first one (the crashing one) uses options NSMigratePersistentStoresAutomaticallyOption: YES and NSInferMappingModelAutomaticallyOption: YES when creating persistent store, while the second application (the running one) doesn’t use any option. But I don’t think that actually matters in this case.

Can anybody advise me how to solve this problem? Thanks!

-- Dragan

Answered by Lumpy Gravy in 684677022

I had the same question which was obviously answered in direct mail to Dragan, but I found it hard to find the answer, so here again:

Explicitly add CoreData.framework in the "Link Binary With Libraries" section in the Build Phases tab of the target.

Accepted Answer

I had the same question which was obviously answered in direct mail to Dragan, but I found it hard to find the answer, so here again:

Explicitly add CoreData.framework in the "Link Binary With Libraries" section in the Build Phases tab of the target.

Incompatible CoreData version crash
 
 
Q