在xcode中的.pch文件中导入的类不起作用,为什么?

Has*_*han 7 xcode objective-c ios

我对Xcode 5中的.pch文件感到担忧.

我的.pch文件中有以下代码 -

#ifdef __OBJC__

#import <Example/Example.h>

#endif
Run Code Online (Sandbox Code Playgroud)

但是当我在我的代码中使用Example.h类时,它无效.当我使用代码时 -

[Example sharedInstance];
Run Code Online (Sandbox Code Playgroud)

xcode显示错误"Use od undeclared identifier Example".问题是什么?

Ove*_*sty 16

这个来自XCode 6.1的屏幕截图显示了我如何使用它 - 因此可能会有所帮助.

在"Apple LLVM 6.0 - 语言" TARGETS/Build Settings区域中查看粗体文本.

请注意粗体文本"Precompile Prefix Header"是如何设置为YES的,并且"Prefix Header"中 pch文件的路径是使用ProjectName/YourPCHFile-Prefix.pch设置的

XCode 6.1的屏幕截图显示了如何包含.pch文件


Jas*_*ien 7

您需要在"标头搜索路径"构建设置中包含标头的路径,以便预处理器/编译器可以找到标头.