I have an Xcode project for my Cocoa application. It's all Objective-C so far.
Problems started after I added a new .c File from the menu (Add C file and header): test.c and header test.h.
When I try to compile the project now there are thousands of errors. All of them are complaints about syntax errors. For example:
NSObjCRuntime.h: Expected identifier or '(' before '@' token
Both new files, test.c
and test.h
, do not contain any code, only the default header comments. Something must be really broken with my project configuration. When I remove these two files the project compiles just fine.
The project language is set to C99. Is there anything else I could check?
Thanks, Mark
if the files you compile include nothing, then your problem is likely in the prefix header (extension: pch)
so you just wrap your library includes based on the language (in the pch):
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#endif
Check your .pch
file. It's importing some Objective-C header without the appropriate preprocessor guard.
You must make sure any Objective-C header or framework imported in your precompiled header looks something like this:
#if defined(__OBJC__)
#import <Cocoa/Cocoa.h>
#import <CoreData/CoreData.h>
#import "MyConstants.h"
...
#endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With