xcode 错误 - 架构 arm64 的 2 个重复符号?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25945270/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error - 2 duplicate symbols for architecture arm64?
提问by Michael
I have a BConstants.h
file where I put all the constants for my project. The file is the following:
我有一个BConstants.h
文件,我在其中放置了项目的所有常量。该文件如下:
#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 #import
ed to another .m
file
当我将以下三行添加到此文件时,将文件#import
编辑到另一个.m
文件时收到后续错误
...
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?
我查看了已经发布在 SO 上的问题,说明我compile sources
的应用程序中可能有重复的文件target
,但我检查了并没有发现重复的文件。这个问题还来自哪里,是不是文件中包含了这 2 个 NSString 常量BConstants.h
?
回答by
There are 2 other possibilities for this error besides duplicate files
除了重复文件之外,此错误还有其他 2 种可能性
- You may importing .m file instead of .h by mistake
- 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.
- 您可能会错误地导入 .m 文件而不是 .h
- 常量 kHero 和 kCount 已经在其他一些文件中定义。当您在常量文件中定义这些常量时,只需将该文件导入 Prefix.pch 文件并从其他任何地方删除。