clang error: Linker command failed with exit code 1

clang error: Linker command failed with exit code 1

项目中遇到了这样的问题,google了一下,给出了这样几种解决方案:

第一种,只说了问题:m文件被重复编译。没有说解决方案。

第二种:给出了这样的解决方案:

Just go to the project settings (click on the File Structure icon and then the app name, and then the Tests target), click Build Settings and then scroll down until you see Test Host (or type ‘host’ in the search box).

Then clear the contents of both the Debug and Release hosts, circled below. The app should then compile without any issues.

第三种:这个解决方案和上一个类似:

In some case error log window displaying .xctest error, to fix it

-> Select your project

-> Beside this(just before General tab) select your projectTest file from dropdown

-> There is one option (like ProjNameTests)

-> In Host Application, select your project from dropdown only if it show custom

第四种:还有人直接问了apple的staff,人家是这么回答的:

In timerRunningViewController.m, you’re importing the the ViewController implementation (ViewController.m) rather than its header (ViewController.h).

然而最后呢,用上述方法都没有解决。

后来我发现我的问题是全局变量在不同的文件中被重复定义。换个名字就好啦。