导入PCH文件之后报错unknown type name 'NSString'

导入PCH文件之后报错,找不到NSString,UIKit,Foundation等,报错:

error: expected identifier or '('

@class NSString, Protocol;

^

/Applications/XCode8.1/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:494:9: error: unknown type name 'NSString'

typedef NSString * NSExceptionName NS_EXTENSIBLE_STRING_ENUM;

^

/Applications/XCode8.1/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:495:9: error: unknown type name 'NSString'

typedef NSString * NSRunLoopMode NS_EXTENSIBLE_STRING_ENUM;

^

/Applications/XCode8.1/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:497:19: error: unknown type name 'NSString'

FOUNDATION_EXPORT NSString *NSStringFromSelector(SEL aSelector);

^

/Applications/XCode8.1/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:498:44: error: unknown type name 'NSString'

FOUNDATION_EXPORT SEL NSSelectorFromString(NSString *aSelectorName);

^

/Applications/XCode8.1/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:500:19: error: unknown type name 'NSString'

FOUNDATION_EXPORT NSString *NSStringFromClass(Class aClass);

^

/Applications/XCode8.1/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:501:53: error: unknown type name 'NSString'

FOUNDATION_EXPORT Class _Nullable NSClassFromString(NSString *aClassName);

^

/Applications/XCode8.1/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:503:19: error: unknown type name 'NSString'

FOUNDATION_EXPORT NSString *NSStringFromProtocol(Protocol *proto) NS_AVAILABLE(10_5, 2_0);

^

/Applications/XCode8.1/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:503:50: error: declaration of 'Protocol' must be imported from module 'ObjectiveC.runtime' before it is required

FOUNDATION_EXPORT NSString *NSStringFromProtocol(Protocol *proto) NS_AVAILABLE(10_5, 2_0);

^

In module 'ObjectiveC' imported from /Applications/XCode8.1/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:9:

/Applications/XCode8.1/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.1.sdk/usr/include/objc/runtime.h:78:28: note: previous declaration is here

typedef struct objc_object Protocol;

^

While building module 'UIKit' imported from /Users/cbwl/Library/Developer/Xcode/DerivedData/BBJD-dimoovxwuxypokadrohgluegljkb/Build/Products/Debug-iphonesimulator/SDAutoLayout/SDAutoLayout.framework/Headers/UIView+SDAutoLayout.h:55:

While building module 'Foundation' imported from /Applications/XCode8.1/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:8:

In file included from :1:

In file included from /Applications/XCode8.1/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:8:

/Applications/XCode8.1/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:504:61: error: unknown type name 'NSString'

FOUNDATION_EXPORT Protocol * _Nullable NSProtocolFromString(NSString *namestr) NS_AVAILABLE(10_5, 2_0);

^

/Applications/XCode8.1/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:508:30: error: unknown type name 'NSString'

FOUNDATION_EXPORT void NSLog(NSString *format, ...) NS_FORMAT_FUNCTION(1,2) NS_NO_TAIL_CALL;

^

/Applications/XCode8.1/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:508:53: error: format argument not an NSString

FOUNDATION_EXPORT void NSLog(NSString *format, ...) NS_FORMAT_FUNCTION(1,2) NS_NO_TAIL_CALL;

~~~~~~~~~~~~~~~~^~

/Applications/XCode8.1/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:98:49: note: expanded from macro 'NS_FORMAT_FUNCTION'

#define NS_FORMAT_FUNCTION(F,A) __attribute__((format(__NSString__, F, A)))

^~

/Applications/XCode8.1/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:509:31: error: unknown type name 'NSString'

FOUNDATION_EXPORT void NSLogv(NSString *format, va_list args) NS_FORMAT_FUNCTION(1,0) NS_NO_TAIL_CALL;

^

/Applications/XCode8.1/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:509:63: error: format argument not an NSString

FOUNDATION_EXPORT void NSLogv(NSString *format, va_list args) NS_FORMAT_FUNCTION(1,0) NS_NO_TAIL_CALL;

~~~~~~~~~~~~~~~~^~

/Applications/XCode8.1/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:98:49: note: expanded from macro 'NS_FORMAT_FUNCTION'

#define NS_FORMAT_FUNCTION(F,A) __attribute__((format(__NSString__, F, A)))

^~

While building module 'UIKit' imported from /Users/cbwl/Library/Developer/Xcode/DerivedData/BBJD-dimoovxwuxypokadrohgluegljkb/Build/Products/Debug-iphonesimulator/SDAutoLayout/SDAutoLayout.framework/Headers/UIView+SDAutoLayout.h:55:

While building module 'Foundation' imported from /Applications/XCode8.1/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:8:

/Applications/XCode8.1/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.1.sdk/usr/include/objc/module.map:8:10: error: module 'ObjectiveC.NSObject' requires feature 'objc'

解决:

在PCH中添加#ifdef ObjectC,即可解决

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 197,099评论 5 462
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 82,846评论 2 374
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 144,146评论 0 325
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 52,789评论 1 267
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 61,656评论 5 358
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 46,467评论 1 276
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 36,870评论 3 389
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 35,500评论 0 254
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 39,790评论 1 293
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 34,828评论 2 314
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 36,628评论 1 328
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,449评论 3 316
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 37,881评论 3 300
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,077评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,376评论 1 255
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 41,879评论 2 343
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 41,089评论 2 338

推荐阅读更多精彩内容

  • 首先如果遇到应用卡顿或者因为内存占用过多时一般使用Instruments里的来进行检测。但对于复杂情况可能就需要用...
    攻克乃还_阅读 1,803评论 0 7
  • two Last login: Tue Aug 4 17:09:57 on ttys000 yushengyang...
    aofeilin阅读 1,022评论 1 9
  • 放一篇之前一直在私人笔记里的参考,也就是个参考手册,用到的时候回来看看。 ‘$’ 作为引用关键字 ex:$PROJ...
    SMThree阅读 3,786评论 0 13
  • 原文地址:http://www.cnblogs.com/oc-bowen/p/5916630.html 主要为了自...
    今天又要上班吗阅读 1,279评论 1 4
  • 今日经历:过往不恋 如果打开一个小口,那么就会想腐败一样,慢慢的侵蚀精神和灵魂,坚持原则! 今天的文章有129次阅...
    磐石yy阅读 194评论 0 0