7

I've recently downloaded iOS 8 to make sure that my existing app works properly with it, but I'm getting a warning in the debugger on launch:

"CoreData: warning: Unable to load class named 'CDAccount' for entity 'CDAccount'.  
Class not found, using default NSManagedObject instead."

After some research, it seems like people have had similar issues when using Core Data in Swift, but all my code is in Objective-C (and the data model hasn't changed for at least 6 months).

Any advice is much appreciated, I'm really nervous that my app isn't going to function properly once people start upgrading to iOS 8!

Mason
  • 6,345
  • 15
  • 67
  • 113
  • Not sure about this but are you sure that your class is a member of the target you are building for? – fzaziz Sep 13 '14 at 04:34
  • Are you using the Social or Accounts frameworks in your application? The Accounts framework uses Core Data internally, and if memory serves CDAccount is the Core Data entity that backs the ACAccount object in the public interface. – quellish Sep 13 '14 at 06:42
  • Oh really? Can you link me to the documentation? I wasn't able to find it. – Mason Sep 15 '14 at 01:41
  • 1
    Check this post: http://stackoverflow.com/questions/25076276/unabled-to-find-specific-subclass-of-nsmanagedobject – Lucien Oct 18 '14 at 02:48
  • Same problem for a different reason. After creating my database, I renamed the class. It was Books and I renamed it to Book. Caused the warning but the app worked fine. – JScarry Oct 30 '14 at 20:46

5 Answers5

18

I had the exact same problem in Objective-C and Xcode 6. For some reason, Xcode had removed my 'CustomNSManagedObject'.m classes from my Compile Sources.

Go to your project target -> Build Phases -> Compile Sources and use the + button to add CDAccount.m

If you are using Mogenerator to create a _CDAccount.m file, add that to your Compile Sources as well.

Dylan Moore
  • 266
  • 2
  • 9
  • 8
    My object was already in compile sources and I'm still getting the error in Xcode 6 – PostCodeism Oct 17 '14 at 11:27
  • @PostCodeism, see the related answer posted by Lucien. It did the trick for me: http://stackoverflow.com/questions/25076276/unabled-to-find-specific-subclass-of-nsmanagedobject – infinite-loop Nov 10 '14 at 17:06
  • This fixed my problem. But, instead of using Build Phases to add the source code, I just clicked on the .m file which was already listed as a file in the project and then checked the Target Membership under the Utilities panel > File Inspector. Why XCode removed the .m file is totally weird. Maybe it was never added from the beginning. There isn't much in the .m file other than a few @dynamic statements. – Brainware Jan 18 '15 at 20:12
7

Remove the "dot" in Configurations "Default" on .xcdatamodeld:

enter image description here

to:
enter image description here
enter image description here
Rebuild the application.

Claudio Guirunas
  • 2,444
  • 1
  • 19
  • 20
  • 1
    Thanks for this. I tried all the other fixes (which are all easily found in many different yet similar questions on SO. This finally fixed my issue after hours of headache. – Amos Oct 05 '17 at 12:56
  • 1
    For me adding the dot helped. – Gamec Jan 23 '18 at 10:16
4

My issue was also similar, but the reason was that module of entity was not set.

module selection in Entity properties menu

Manfred Radlwimmer
  • 12,469
  • 13
  • 47
  • 56
gwyhyr
  • 51
  • 6
3

It seems to be an Xcode bug/issue. I'm using Xcode 6.3.1

  • click on your core data entity (xxx.xcdatamodeld), then select the entity, and in the attributes inspector you'll see that the entity's class name is set to: PRODUCT_MODULE_NAME.xxx, where 'xxx' is your entity's name.

solution : You have to replace PRODUCT_MODULE_NAME with your app's name.

If in doubt about your app's name, check under 'build settings', filter on 'product_module_name', and you'll find your app name under 'packaging'

  • in some cases (my case) the data model file (swift or objective-c) is also removed by Xcode from the project - it's still on in disk though, but you need to add it again. So in this case take the 'CDAccount.m' file & drop it in your project again (or use another of the several ways to do this)
Ronny Webers
  • 4,994
  • 4
  • 24
  • 23
1

My issue was similar, but the listed solutions didn't work because my CD Classes were stored in a framework. The solution was to change the Class Name Representation to "frameworkName.className". However, the xcdatamodeld didn't allow me to change it to that, so I had to "Show Contents" on the file, open the "contents" file in XCode, and make the changes myself.