Apple Mach-O链接器错误Xcode 6.2

时间:2022-09-03 20:22:03

I'm sorry if this question is a duplicate, but I only asked it because I didn't find a solution in other related questions.

如果这个问题重复,我很抱歉,但我只是问它,因为我没有找到其他相关问题的解决方案。

I started a new project in Xcode 6.2 and I imported AFNetworking using pods. I also imported SWRevealViewController by dragging the two files (.h and .m) into the project.

我在Xcode 6.2中开始了一个新项目,我使用pod导入了AFNetworking。我还通过将两个文件(.h和.m)拖到项目中来导入SWRevealViewController。

Everything looks fine but when I build the project to test it gives me the error below.

一切看起来都很好但是当我构建项目进行测试时,它给出了下面的错误。

Apple Mach-O链接器错误Xcode 6.2

Does anyone know how to deal with this?

有谁知道如何处理这个?

1 个解决方案

#1


You have the same symbols jsonContents, dictionary, etc in 2 object files (ArticlesViewController.o and MainViewController.o).

在2个目标文件(ArticlesViewController.o和MainViewController.o)中有相同的符号jsonContents,dictionary等。

This often happens when you import a header file that defines the symbols, for example:

导入定义符号的头文件时经常会发生这种情况,例如:

SomeHeader.h

NSMutableArray *jsonContents;
NSMutableDictionary *dictionary;

Rather than declaring them as extern:

而不是将它们声明为extern:

SomeHeader.h

extern NSMutableArray *jsonContents;
extern NSMutableDictionary *dictionary;

and define those variables in their own implementation file (SomeFile.m for example).

并在他们自己的实现文件中定义这些变量(例如SomeFile.m)。

#1


You have the same symbols jsonContents, dictionary, etc in 2 object files (ArticlesViewController.o and MainViewController.o).

在2个目标文件(ArticlesViewController.o和MainViewController.o)中有相同的符号jsonContents,dictionary等。

This often happens when you import a header file that defines the symbols, for example:

导入定义符号的头文件时经常会发生这种情况,例如:

SomeHeader.h

NSMutableArray *jsonContents;
NSMutableDictionary *dictionary;

Rather than declaring them as extern:

而不是将它们声明为extern:

SomeHeader.h

extern NSMutableArray *jsonContents;
extern NSMutableDictionary *dictionary;

and define those variables in their own implementation file (SomeFile.m for example).

并在他们自己的实现文件中定义这些变量(例如SomeFile.m)。