Вопрос

My application has many constants (kvo keys, enums, etc.) that are used by almost every class. I have a constants.h file with all of them. I want include this file in the Prefix.pch file as follows:

#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "AppConstants.h"
#endif

However, when I include the file in this manner, Xcode 4's syntax highlighting and code completion stops working. If I manually include the constants file in the header file for every class that uses them, and remove the include from the pch file, syntax highlighting and code completion returns.

Is this expected behavior? How can I include a constants file in every file without using the pch file? Is the problem that the "AppConstants.h" file is being included in itself because of the pch file?

Это было полезно?

Решение

Have a look at this question. I was having the exact same issue as you. If the first answer doesn't fix it for you, further down the page they mention setting the Precompile Prefix Header option to NO, which is what fixed it for me.

Hope that helps.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top