Xcode 6 - Unknown type name 'NSString' / E

2019-04-06 07:46发布

问题:

When I am running my project in Xcode 6, I am having many weird errors.

Parse Issue - Unknown type name 'NSString'
Format argument not an NSString
Could not build module Foundation
Could not build module QuartzCore

All of these errors occur in Apple's header files such as: CAMediaTiming.h, NSObjCRuntime.h,NSZone.h,NSObject.h, CALayer.h, etc.

Unfortunately, the answers in here: ios - Parse Issues in NSObjCRuntime, NSZone, and NSObject did not work for me.

How do you recommend I fix these errors?

回答1:

The problem was that I had some .c files in my project, apparently Xcode 6 doesn't like .c files.

I changed the extension of the .c files to .m and Xcode 6 is happy again!



回答2:

You can get this error if you have a PrefixHeader file that imports Objective-C code and also some plain C files in your project, because the C files try to import the Objective-C.

To fix, wrap your objective-c imports like this :

#ifdef __OBJC__
#import <OOObjectiveCClass.h>
#endif


回答3:

See if the Prefix Header file path is correctly placed under Build Settings tab. See the complete answer at the following link.

Check this post



回答4:

I use Xcode 8.3.3,I also encounter this problem,and I solve this issue by selecting the file and in the right panel in Xcode in the Identity and Type part choose Type to Objective-C++.



回答5:

You can also try deleting the Samples folder in the FacebookSDK folder (and then deleting the reference to it in Xcode.