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

相關文章
相關標籤/搜索