接口生成器文件中的 XCode 未知类 *****

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13730347/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 02:15:14  来源:igfitidea点击:

XCode Unknown class ***** in Interface Builder file

xcode

提问by Laure_f_o

In an app, suddenly it's giving me the error XCode Unknown class ***** in Interface Builder file. I reviewed everything, storyboard, classes, etc.

在应用程序中,它突然在 Interface Builder 文件中给我错误 XCode Unknown class *****。我了所有内容,故事板,课程等。

I try to rename the class but it is the same problem, even I created a new class and copy the code in. I think XCode is taken that from a kind of cache because even properties that I deleted like the icon in the tab bar item are still present in the app when I run it.

我尝试重命名该类,但它是同样的问题,即使我创建了一个新类并将代码复制进去。我认为 XCode 是从一种缓存中获取的,因为即使我删除的属性也像选项卡栏中的图标一样当我运行它时,它仍然存在于应用程序中。

What can be the problem?

可能是什么问题?

采纳答案by Laure_f_o

Sorry, after trying several post I found one solution, delete the folder of the simulator in /...Library/Application\ Support/iPhone\ Simulator/ and removing the class and re-adding it.

抱歉,在尝试了几篇帖子后,我找到了一个解决方案,删除 /...Library/Application\ Support/iPhone\ Simulator/ 中的模拟器文件夹并删除该类并重新添加它。

回答by Joe Collins

Also if using a static library, don't forget to add the -ObjC flag to Other Linker Flags in your projects Build Settings tab.

此外,如果使用静态库,请不要忘记将 -ObjC 标志添加到项目构建设置选项卡中的其他链接器标志。

If you have failed to do so, "Unknown class ... in Interface Builder file" will occur when trying to load a view controller from the static library in IB.

如果您没有这样做,当尝试从 IB 中的静态库加载视图控制器时,将出现“Unknown class ... in Interface Builder file”。

Just another case I experienced the error will show.

只是我遇到错误的另一种情况会显示。

回答by vvkuznetsov

I faced a problem when I created a project with the same name that already existed in my projects directory (though it was deleted some time ago). Xcode didn't understood that it's a new project and use build directory of old project as a build directory for a new one. I didn't knew how to completely rebuild project from scratch and I just removed a build directory. In my case I removed /Users/username/Library/Developer/Xcode/DerivedData/ProjectName-suffix. You can find it in Xcode in Project navigator on the left by selecting ProjectName->Products->ProjectName.app and File inspector on the right will show you a full path to file.

当我创建一个同名的项目时,我遇到了一个问题,该项目已经存在于我的项目目录中(尽管它在前一段时间被删除了)。Xcode 不明白这是一个新项目,并使用旧项目的构建目录作为新项目的构建目录。我不知道如何从头开始完全重建项目,我只是删除了一个构建目录。就我而言,我删除了 /Users/username/Library/Developer/Xcode/DerivedData/ProjectName-suffix。您可以在左侧的项目导航器中的 Xcode 中通过选择 ProjectName->Products->ProjectName.app 找到它,右侧的文件检查器将显示文件的完整路径。

回答by David Knight

You will need to add to your targets Other Linker Flags as well, just adding to the Project Build Settings does not seem to work.

您还需要向目标添加其他链接器标志,只是添加到项目构建设置似乎不起作用。