错误 - 架构 arm64 的 2 个重复符号? [英] Error - 2 duplicate symbols for architecture arm64?

查看:79
本文介绍了错误 - 架构 arm64 的 2 个重复符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 BConstants.h 文件,我在其中放置了项目的所有常量.文件如下:

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

当我向这个文件添加以下三行时,当文件被#imported到另一个.m文件时,我收到了后续的错误

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

错误:

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

我查看了已经发布在 SO 上的问题,指出我的 compile 源 应用程序 target 中可能有重复的文件,但我检查了,没有发现重复文件.这个问题还可能来自哪里,是否是 BConstants.h 文件中包含这两个 NSString 常量?

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?

推荐答案

这个错误除了重复文件还有 2 种可能

There are 2 other possibilities for this error besides duplicate files

  1. 您可能错误地导入了 .m 文件而不是 .h
  2. 常量 kHero 和 kCount 已经在其他一些文件中定义.作为您在常量文件中定义这些常量然后只需导入Prefix.pch 文件中的该文件并从其他任何地方删除.

这篇关于错误 - 架构 arm64 的 2 个重复符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆