Xcode添加C语言代码出错

  项目中须要用C语言实现一部分功能,新建C语言文件报错,错误以下:框架

  检查C语言代码,并无什么写的不对的地方。查看错误信息列表,发现和本身代码相关的错误在.pch文件中。新建pch文件的时候,默认的是为整个项目代码引入UIkit、Foundation、CoreData框架,可是C语言文件中引入这些文件就会出错。因此这个时候,咱们把C语言文件隔离出来。ui

  旧代码:this

#ifndef iRun_Prefix_pch
#define iRun_Prefix_pch

// Include any system framework and library headers here that should be included in all compilation units.
// You will also need to set the Prefix Header build setting of one or more of your targets to reference this file.

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#import "Masonry.h"

#endif /* iRun_Prefix_pch */

  新代码:spa

#ifdef __OBJC__
#define iRun_Prefix_pch

// Include any system framework and library headers here that should be included in all compilation units.
// You will also need to set the Prefix Header build setting of one or more of your targets to reference this file.

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#import "Masonry.h"

#endif /* iRun_Prefix_pch */

  以上。code

相关文章
相关标签/搜索