2

I have a BConstants.h file where I put all the constants for my project. The file is the following:

#ifndef asdf_BConstants_h
#define asdf_BConstants_h

typedef NS_ENUM(NSUInteger, BTheme) {
    kField
};

typedef NS_ENUM(NSUInteger, BItem) {
    kBox
};

typedef NS_ENUM(NSUInteger, BMovementState) {
    kTouchUp,
    kTouchDown
};

#endif

When I add the following three lines to this file, I receive the subsequent errors when the file is #imported to another .m file

...

NSString * const kHero = @"Hero";
NSString * const kCount = @"Count";

#endif

Errors:

duplicate symbol _kHero in:
...list of .o files
duplicate symbol kCount in:
...list of .o files
2 duplicate symbols for architecture arm64

I have looked at questions already post on SO that state I may have duplicate files in my compile sources of the application target, but I checked and I found no duplicate files. Where else can this problem stem from, is it the inclusion of those 2 NSString constants in the BConstants.h file?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Michael
  • 6,561
  • 5
  • 38
  • 55

1 Answers1

14

There are 2 other possibilities for this error besides duplicate files

  1. You may importing .m file instead of .h by mistake
  2. Constants kHero and kCount already defined in some other files. As you are defining those constants in constant file then just import that file in Prefix.pch file and remove from everywhere else.
  • Yes, I think that those `NSString`s need to be compiled first. I am just directly importing the `.h` into any `.m` file. Do I place `BPContants.h`between `#import ` and `#endif` in `Prefix.pch`? – Michael Sep 20 '14 at 04:46
  • 1
    This answer does not address the actual issue. – rmaddy Sep 20 '14 at 05:37