Include not found compile error in Xcode 4.2

前端 未结 4 956
深忆病人
深忆病人 2020-12-16 13:38

I\'m getting include not found compile error in XCode. I have an iOS app project that i use Objective-c and c++ as mix.

Initially, i created one .h file and one .c

相关标签:
4条回答
  • 2020-12-16 14:09

    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.

    0 讨论(0)
  • 2020-12-16 14:12

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

    In Compile Sources As change to Objective-C++

    0 讨论(0)
  • 2020-12-16 14:19

    So I was having this issue with the Cocoapods library Bypass and none of these solutions did anything. The problem was with a file which Cocoapods creates called an umbrella header. This is located in <POD_NAME>/Support Files/<POD_NAME>-umbrella.h. Delete it, and it should build just fine.

    Now for the explanation of why this is necessary: the umbrella header is mixing both C++ and Objective-C code directly in a header which is a big no-no apparently and ends up completely breaking the C++ imports. By removing it (which seems to have no effect?) this conflicting import which Cocoapods unknowingly created will go away.

    0 讨论(0)
  • 2020-12-16 14:23

    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>
    
    0 讨论(0)
提交回复
热议问题