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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 05:37:59  来源:igfitidea点击:

Error - 2 duplicate symbols for architecture arm64?

objective-cxcode

提问by Michael

I have a BConstants.hfile 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 #imported to another .mfile

当我将以下三行添加到此文件时,将文件#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 sourcesof 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.hfile?

我查看了已经发布在 SO 上的问题,说明我compile sources的应用程序中可能有重复的文件target,但我检查了并没有发现重复的文件。这个问题还来自哪里,是不是文件中包含了这 2 个 NSString 常量BConstants.h

回答by

There are 2 other possibilities for this error besides duplicate files

除了重复文件之外,此错误还有其他 2 种可能性

  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.
  1. 您可能会错误地导入 .m 文件而不是 .h
  2. 常量 kHero 和 kCount 已经在其他一些文件中定义。当您在常量文件中定义这些常量时,只需将该文件导入 Prefix.pch 文件并从其他任何地方删除。