Alex I
Alex I

Reputation: 20307

Adding C file causes pch error

I have an XCode project with objective-C files. If I add a new (empty) C file and try to build, I get a large number of errors right away while building a precompiled header, in ProcessPCH step. The errors are "fatal error: Could not build module 'Foundation'", and things in Foundation.h not being found. Remove the C file and it builds again. What is going on, and how to fix it?

(XCode 5.0, OSX 10.8.4)

EDIT I have tried Clean and Clean build folder, no effect.

EDIT Setting Precompile prefix header = No results in a bunch of syntax errors instead, in stuff like NSObject.h (and other Foundation framework header).

EDIT User Cy-4AH figured it out: there needs to be #ifdef __OBJC__ around the whole pch file.

Upvotes: 6

Views: 10813

Answers (1)

Cy-4AH
Cy-4AH

Reputation: 4585

Surround #import's with preprocessor directive #ifdef __OBJC__ #endif

Upvotes: 18

Related Questions