Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error - 2 duplicate symbols for architecture arm64? [duplicate]

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?

like image 296
Michael Avatar asked Jan 18 '26 14:01

Michael


1 Answers

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.

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!