【问题标题】:XCode 5 project with RestKit v0.21.0 won't compile带有 RestKit v0.21.0 的 XCode 5 项目无法编译
【发布时间】:2013-10-25 20:57:37
【问题描述】:

我尝试在我的应用程序中使用 RestKit v0.21.0。我按照说明 here 将 RestKit 安装为 Git 子模块。

项目编译没有错误。

然后我尝试访问 mainQueueManagedObjectContext:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.

NSManagedObjectContext *context = [RKManagedObjectStore defaultStore].mainQueueManagedObjectContext;

return YES;

}

并收到错误:

Receiver 'RKManagedObjectStore' for class message is a forward declaration

【问题讨论】:

    标签: ios core-data ios7 restkit xcode5


    【解决方案1】:

    在玩弄了提交历史之后,我意识到这个问题是在将#ifdef _COREDATADEFINES_H 添加到 RestKit 项目后出现的。

    然后我找到了解决方案here

    您应该将#import <CoreData/CoreData.h> 添加到您的 PCH 文件中:

    #ifdef __OBJC__
    
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>
    #import <SystemConfiguration/SystemConfiguration.h>
    #import <MobileCoreServices/MobileCoreServices.h>
    #import <CoreData/CoreData.h>
    #import <RestKit/RestKit.h>
    
    #endif
    

    【讨论】:

    • 这个库集成顺序非常重要,因为当我有不同的库时,它会显示错误。
    • 感谢您的评论。顺序很重要。确保 RestKit 位于末尾。
    • 你的回答对我没有帮助,但你的评论确实非常感谢你,我已经浪费了 2 个小时,时间是一个因素:3
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多