ld: duplicate symbol - caused by const
In your header file you want:
extern NSString *const FPServerAPIErrorDomain;
and then in an implementation file (so probably you want a FPServerAPICoordinatorConstants.m
) you will want:
NSString *const FPServerAPIErrorDomain = @"FPServerAPIErrorDomain";
Then you can import the header into multiple file and not get duplicate symbol errors.
[By the way, you don't need the #ifndef
guards if you're using #import
.]
It is not possible to instantiate the same (global) variable twice in the same namespace (, without getting an error).
Each symbol should only be defined once; that is, it should only be defined in one m file. By putting the definition in a header file, it gets defined in each m file that includes that header.
Define it in one of your m files (whichever is most relevant), and change what you have in the header to a declaration (using the extern keyword).
The definition makes space for the data; the declaration simply tells the compiler that there is a definition somewhere else. So every m file that uses the constant needs to have a declaration, but only one m file should have the definition.