CoreData:warning:无法加载实体'Readings'命名为'WEEReadings'的类。找不到类,而是使用默认的NSManagedObject [英] CoreData: warning: Unable to load class named 'WEEReadings' for entity 'Readings'. Class not found, using default NSManagedObject instead

查看:317
本文介绍了CoreData:warning:无法加载实体'Readings'命名为'WEEReadings'的类。找不到类,而是使用默认的NSManagedObject的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个静态库,并使用这个真棒脚本我生成了包括通用静态库的静态框架,我还创建了一个包括ReadingsCoreDataModel.momd的包,其中包括ReadingsCoreDataModel.mom 。所有好的,我提供这些到我的客户端iOS应用程序,所有构建正确,启动应用程序扭结到我的框架和使用捆绑,我有一个单身WEEDataStore类在我的静态库使用另一个类名为Worker,checked,NSManagedObjectModel不是nil并且看起来正确加载,NSPersistentStoreCoordinator不是nil,NSManagedObjectContext不是nil。



在WEEDataStore中,我有一个保存方法,我从Worker类调用静态库。



在我的ReadingsCoreDataModel.momd中,我创建了一个名为Readings和类WEEReading的实体。



我在Worker类中执行以下操作

  WEEReadings * readersEntity = [NSEntityDescription insertNewObjectForEntityForName:@ReadingsinManagedObjectContext:[[WEEDataStore sharedInstance ] managedContext]]; 
[readersEntity appendWithReadingsModel:self.readingsModel];
[[WEEDataStore sharedInstance] save];

结果是得到以下错误

  CoreData:warning:无法加载实体'Readings'命名为'WEEReadings'的类。找不到类,而是使用默认的NSManagedObject。 
2014-12-13 20:11:30.080 TestClient [6854:2487108] - [NSManagedObject appendWithReadingsModel:]:无法识别的选择器发送到实例0x1700ccda0
2014-12-13 20:11:30.084 TestClient [6854 :2487108] ***由于未捕获异常NSInvalidArgumentException终止应用程序,原因:' - [NSManagedObject appendWithReadingsModel:]:无法识别的选择器发送到实例0x1700ccda0'

我几乎读过所有类似的错误,大多数疑难解答与Swift,或打字错误与模型,其他建议具有相同的型号名称作为应用程序名称,我不认为我可以做到这一点,或者它与错误相关。



我的静态库中的所有头都是Project,除了暴露给客户端的那些被添加为Public。



所有Core Data操作都是内部操作。



看起来Core Data模型被正确加载,但找不到我的类,它绝对包含在框架中包含的静态库中。



任何

解决方案

添加 -ObjC 链接器标记到您的项目,以强制链接器从您的库加载所有类。


OK, it's time for the community help after hours and hours of searching.

I have a static library and using this awesome script I generate my static framework which includes the universal static library, also I create a bundle including the ReadingsCoreDataModel.momd which includes the ReadingsCoreDataModel.mom. All good, I provide these to my client iOS application, all builds correctly and starting the app kinked to my framework and using the bundle, I have a singleton WEEDataStore class in my static library used by another class named Worker, checked, NSManagedObjectModel is not nil and looks to be loaded correctly, NSPersistentStoreCoordinator is not nil, NSManagedObjectContext is not nil.

In the WEEDataStore I have a save method which I call from the Worker class in my static library.

In my ReadingsCoreDataModel.momd I have created an Entity with Name Readings and class WEEReadings.

I do the following in the Worker class

WEEReadings* readingsEntity = [NSEntityDescription insertNewObjectForEntityForName:@"Readings" inManagedObjectContext:[[WEEDataStore sharedInstance] managedContext]];
[readingsEntity appendWithReadingsModel:self.readingsModel];
[[WEEDataStore sharedInstance] save];

The result is to get the following error

CoreData: warning: Unable to load class named 'WEEReadings' for entity 'Readings'.  Class not found, using default NSManagedObject instead.
2014-12-13 20:11:30.080 TestClient[6854:2487108] -[NSManagedObject appendWithReadingsModel:]: unrecognized selector sent to instance 0x1700ccda0
2014-12-13 20:11:30.084 TestClient[6854:2487108] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSManagedObject appendWithReadingsModel:]: unrecognized selector sent to instance 0x1700ccda0'

I have almost read all the similar errors, most troubleshooting with Swift, or typo errors with the model, other suggesting to have the same model name as the application name, I don't think I can do this or it is related to the error.

All my headers inside my static library are Project except the ones exposed to the client that are added as Public. Also tried to add them all as public but it didn't make any difference.

All Core Data operations are internal.

It seems like the Core Data model is loaded properly but cannot find my class which is definitely included in the static library that is included in the framework.

Any ideas before I register to the mad house?

解决方案

Add -ObjC linker flag to your project to force linker to load all classes from your library.

这篇关于CoreData:warning:无法加载实体'Readings'命名为'WEEReadings'的类。找不到类,而是使用默认的NSManagedObject的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆