Include <string> not found compile error in Xcode 4.2 Include <string> not found compile error in Xcode 4.2 xcode xcode

Include <string> not found compile error in Xcode 4.2


select project -> build setting -> apple LLVM compiler 5.1 -> language

In Compile Sources As change to Objective-C++


There's a quirk in XCode. I noticed it in 7.3. Most projects recognize .mm files and the STL, while one project I had did not. The fix was that I had to click on the top-left project icon, then click Targets > Build Phases > Link Binary with Libraries > and add in AppKit.framework. Next, I had to click Targets > Build Settings > search on "Compile Sources", and set it to "Objective C++" on all possible columns. Then, do a Clean and then a Build from the Product menu. This compiled properly then. Then, go back to that Compile Sources again and set it back to "According to File Type" on all possible columns. Then, click Build from the Product menu again. At that point, it compiled properly and allowed me to utilize the "according to file type" option, which I like better.

Oh, and if doing Cocoa stuff, don't forget to add the following header in your files:

#import <Cocoa/Cocoa.h>

And if doing command line stuff, don't forget to add the following instead of the Cocoa header:

#import <Foundation/Foundation.h>


i believe you need to include the whole path to the library. similarly to say "foundation" & "uiview" frameworks.

#import <Foundation/Foundation.h>

or

#import <UIKit/UIKit.h>

and yes, make sure you add the library to your target.