我现在也有同样的问题,但还没有找到正确的答案。我得到了错误:

    /Users/nle/Library/Developer/Xcode/DerivedData/TestMoboSDK-Client-cgodalyxmwqzynaxfbbewrooymnq/Build/Intermediates/TestMoboSDK-Client.build/Debug-iphonesimulator/TestMoboSDK-Client.build/Objects-normal/x86_64/MoboSDK.o
    /Users/nle/Library/Developer/Xcode/DerivedData/TestMoboSDK-Client-cgodalyxmwqzynaxfbbewrooymnq/Build/Products/Debug-iphonesimulator/libMoboSDK.a(MoboSDK.o)
duplicate symbol _OBJC_METACLASS_$_MoboSDK in:
    /Users/nle/Library/Developer/Xcode/DerivedData/TestMoboSDK-Client-cgodalyxmwqzynaxfbbewrooymnq/Build/Intermediates/TestMoboSDK-Client.build/Debug-iphonesimulator/TestMoboSDK-Client.build/Objects-normal/x86_64/MoboSDK.o
    /Users/nle/Library/Developer/Xcode/DerivedData/TestMoboSDK-Client-cgodalyxmwqzynaxfbbewrooymnq/Build/Products/Debug-iphonesimulator/libMoboSDK.a(MoboSDK.o)
ld: 75 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

任何帮助都是感激的。

最后,我找到了这个错误的原因,因为我添加了-ObjC到其他链接器标志。在删除这个值之后,我可以成功地构建我的项目,但我不知道为什么。有人能解释一下吗?


当前回答

我在安装Cocoapods后遇到了这个问题。现在每次我更新一些豆荚。我找到了解决办法:

进入终端:

1) pod deintegrate
2) pod install

同时,在构建设置中选中“Always Embed Swift Libraries”。它应该是“褪色的”,表明它正在使用默认配置。如果设置为手动YES,点击删除将其恢复为默认配置。这制止了这种行为。

其他回答

当我在两年前用Objective-C开发的项目中接受“推荐设置”弹出时,我就遇到了这种情况。

问题是当你接受“推荐设置”更新时,Xcode会自动更改或添加一些构建设置,包括GCC_NO_COMMON_BLOCKS = YES;。

这使得构建失败与重复的符号错误在我更新的项目。所以我在我的构建设置中将No Common Block更改为No,错误就消失了。

在我的案例中,我在项目中定义了两个main()方法,删除其中一个就解决了这个问题。

今天,我得到了同样的错误。错误的关键字是duplicate。我通过:

1. Remove the duplicate file at Build Phases-->Compile Sources
2. If you can not remove it at Build Phases, you need find the file at your project and remove the reference by DELETE :

3. Add the file to your project again
4. Add the file's .m to your Build Phases-->Compile Sources again
5. Build your project, the error will disappear

在我的例子中,我只是创建了一个头文件来定义像这样的常量字符串:

NSString *const AppDescriptionString = @"Healthy is the best way to keep fit";

我通过使用静态来解决这个问题:

static NSString *const AppDescriptionString = @"Healthy is the best way to keep fit";

对我来说,当我错误地为我的APP定义了两个入口点时,就发生了这种情况

@main struct AppName: App { //注释- @main

Or

@UIApplicationMain class AppDelegate //如何- @UIApplicationMain