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

    /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到其他链接器标志。在删除这个值之后,我可以成功地构建我的项目,但我不知道为什么。有人能解释一下吗?


当前回答

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

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

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

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

其他回答

今天,我得到了同样的错误。错误的关键字是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

这个答案适用于Xcode 12.5.1,在2021年为我工作

关闭Xcode项目。 进入您的项目目录,如果您使用flutter,不要忘记在项目文件夹中获取“ios”文件。 删除[Pods, Podfile, Podfile.lock]。 运行终端。 转到项目目录。

如果你使用的是swift,你就完成了,跳转到xcode并运行应用程序,如果你使用的是flutter,则继续

把颤振清理干净 跑扑酒吧得到。 跑,扑,跑。在使用颤振运行命令之前,不要忘记运行模拟器。

祝贺一切顺利!

如果你来这里是为了一个React Native项目,那么请点击下面的链接,

Targets -> <Your-App> -> Build Settings -> Dead Code Stripping

调试时从No更改为Yes。

附注:这种方法适用于React Native项目,不确定它是否也适用于本地项目。

我试着遵循这些步骤,现在对我有用了。

打开Xcode > Pods >目标支持文件> Pods-{TARGET-NAME} 找到“OTHER_LDFLAGS”,只删除这两个文件中的“-ObjC”: 豆荚-{目标名}.release。xcconfig & Pods-{TARGET-NAME}.debug.xcconfig 转到项目主目标>构建设置>其他链接器标志: 确保值中没有“-ObjC” 我删除了ios中的build/ build文件夹,并再次运行ios。现在起作用了。

寻找目标 选择生成设置 搜索“No Common Blocks”,选择为“No”。

这对我很有效