At the begin of your header file state:
#if !defined APPDELEGATE_H
#define APPDELEGATE_H
and at the end state:
#endif
Most probably root cause of this error is that you included AppDelegate.h in some classes header file and .m file. While compiling the .m file the corresponding .h file is included (and probably some other .h files are included). In any of these .h files AppDelegate.h is included. Plus you include it in the .m file. That will cause a duplicate definition of the interface from the compiler's point of view.
The solution above is not really a solution. Strictly spoken it is a workaround. But it is quite standard and apple uses it in all of their templates. It's just a workaround because it does not solve the issue but deals with it.
Proper solutions would be:
In the .h file do not include other .h files if avoidable. Use @class
statemenst where ever appropriate.
Never repeat incuding of any .h file in a .m file when the .h file is already included in any of the other included .h files.
You may think "this is a pain in the a....". And you are right :) Therefore I suggest to use the common #if !defined XY_H / #define XY_H / #endif
pattern, although I believe that this is just a workaround.
#if !defined APPDELEGATE_H
#define APPDELEGATE_H
#import <UIKit/UIKit.h>
@class ViewController;
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) ViewController *viewController;
@end
#endif