Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Classes imported in .pch file in xcode not working, why?

I have a concern with my .pch file in Xcode 5.

I have following code in my .pch file--

#ifdef __OBJC__

#import <Example/Example.h>

#endif

But when i use Example.h class in my code it is not working. When i use code like-

[Example sharedInstance];

xcode shows error "Use od undeclared identifier Example". What is the problem?

like image 518
Hashim Khan Avatar asked Nov 22 '13 09:11

Hashim Khan


2 Answers

This Screen Shot from XCode 6.1 shows how I got this to work - and therefore may prove helpful.

Look at the bold text, mid-way down, in the "Apple LLVM 6.0 - Language" TARGETS / Build Settings area.

Notice how the bold text "Precompile Prefix Header" has been set to YES, and the path to the pch file in "Prefix Header" is set with ProjectName/YourPCHFile-Prefix.pch

Screen Shot from XCode 6.1 showing how to include .pch file

like image 170
OverToasty Avatar answered Sep 22 '22 20:09

OverToasty


You will need to include the path to the headers in the "Header Search Path" build settings so that the preprocessor/compiler can find the headers.

like image 26
Jasarien Avatar answered Sep 23 '22 20:09

Jasarien