Xcode - 替换类文件后链接错误 _OBJC_CLASS_$_"className"
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9863399/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode - linking error _OBJC_CLASS_$_"className" after replacing class files
提问by CodingBeagle
Introduction
介绍
In a current project I'm working on we're using the ChartBoost SDK for popop commercials. We've been using this SDK for a while now with no problem whatsoever. It is a very simple library that essentially only has 1 header file called "ChartBoost.h" as well as a "libChartBoost.a" file.
在我目前正在进行的一个项目中,我们将 ChartBoost SDK 用于流行广告。我们已经使用这个 SDK 一段时间了,没有任何问题。这是一个非常简单的库,基本上只有一个名为“ChartBoost.h”的头文件和一个“libChartBoost.a”文件。
Now we have just updated the SDK files with a new version. What I did here was simply removing the old SDK files from the project by "Move To Trash". What I did after was simply moving the new SDK files to the project, adding their references.
现在我们刚刚用新版本更新了 SDK 文件。我在这里所做的只是通过“移至垃圾箱”从项目中删除旧的 SDK 文件。我之后所做的只是将新的 SDK 文件移动到项目中,并添加它们的引用。
The problem
问题
Right after doing this and compiling the project, I suddenly get 2 linking errors. Here's a screenshot of it:
在执行此操作并编译项目后,我突然收到 2 个链接错误。这是它的屏幕截图:
I've tried pretty much everything I could think of to try and remove the error. I've cleaned the project and the project folder, and I've also tried to delete the derived data of the project through the organizer window.
我已经尝试了几乎所有我能想到的方法来尝试消除错误。我已经清理了项目和项目文件夹,我也尝试通过管理器窗口删除项目的派生数据。
I'm pretty certain this has something to do with the linker trying to use the references of the old files? But I'm not sure how I could go about getting it to remove those now-invalid references.
我很确定这与尝试使用旧文件引用的链接器有关?但我不确定如何才能删除那些现在无效的引用。
Is there anyone here who have any idea how this problem could be fixed?
这里有人知道如何解决这个问题吗?
[EDIT] Linking ChartBoost.a to the binary
[编辑] 将 ChartBoost.a 链接到二进制文件
So I tried linking the ChartBoost.a file to the binary through the "Build Phases" tab. This did get rid of the two original errors though revealed 8 new ones, shown in the screenshot below:
所以我尝试通过“构建阶段”选项卡将 ChartBoost.a 文件链接到二进制文件。这确实消除了两个原始错误,但显示了 8 个新错误,如下面的屏幕截图所示:
I'm not quite sure what these kind of linking errors are supposed to mean unfortunately :( Anyone got any ideas?
不幸的是,我不太确定这些类型的链接错误应该意味着什么:(有人有任何想法吗?
回答by Kurt Revis
In your app's target, look in "Build Phases", in the "Link Binary With Libraries" phase.
在您的应用程序的目标中,查看“构建阶段”,在“将二进制文件与库链接”阶段。
It should include libChartBoost.a
.
它应该包括libChartBoost.a
.
If it doesn't, press the + button and select libChartBoost.a
.
如果没有,请按 + 按钮并选择libChartBoost.a
。
I'm pretty certain this has something to do with the linker trying to use the references of the old files?
我很确定这与尝试使用旧文件引用的链接器有关?
No. You removed the old files from the project, and that included the reference in the "Link Binary With Libraries" build phase. When you added the new files to the project, you didn't add that reference back.
不。您从项目中删除了旧文件,其中包括“将二进制文件与库链接”构建阶段中的引用。当您将新文件添加到项目时,您并没有重新添加该引用。