Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 287
Alex I Avatar asked Nov 01 '13 08:11

Alex I


1 Answers

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

like image 196
Cy-4AH Avatar answered Sep 30 '22 22:09

Cy-4AH