美文网首页
导入PCH文件之后报错unknown type name 'NS

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

作者: 涛涛灬灬 | 来源:发表于2017-02-21 15:23 被阅读0次

    导入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,即可解决

    相关文章

      网友评论

          本文标题:导入PCH文件之后报错unknown type name 'NS

          本文链接:https://www.haomeiwen.com/subject/dwauuttx.html