xcode Interface Builder 文件中的未知类

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

Unknown class in Interface Builder file

iphonexcodeinterface-builderclass-reference

提问by tg2

I created a fairly simple iPhone app. Then figured I'd create an iPad version (Universal) of the app. Tried using the 'upgrade' option and that didn't work-out. So I created a separate universal app and copied the xib files into my project. That didn't work out either, so I deleted the xib files (and their associated .m & .h files.

我创建了一个相当简单的 iPhone 应用程序。然后想我会创建该应用程序的 iPad 版本(通用)。尝试使用“升级”选项,但没有奏效。所以我创建了一个单独的通用应用程序并将 xib 文件复制到我的项目中。那也没有用,所以我删除了 xib 文件(以及它们相关的 .m 和 .h 文件。

Now, when I run the iPhone version it gives me the Unknown class iPadSample1AppDelegate in Interface Builder file. error and UISplitViewController is only supported when running under UIUserInterfaceIdiomPad and then it exits. So, I restored to the snap-shot I took before embarking on the iPad adventure... I get the same error. I've tried the XCode search and Spotlight search. There is no reference to that class or the UISplitViewController anywhere in my project, but for some reason XCode thinks that there is.

现在,当我运行 iPhone 版本时,它在 Interface Builder 文件中为我提供了未知类 iPadSample1AppDelegate。error 和 UISplitViewController 仅在 UIUserInterfaceIdiomPad 下运行时才支持,然后退出。所以,我恢复了我在开始 iPad 冒险之前拍摄的快照......我得到了同样的错误。我试过 XCode 搜索和 Spotlight 搜索。在我的项目中的任何地方都没有对该类或 UISplitViewController 的引用,但出于某种原因,XCode 认为存在。

Is there some way to remove a reference that doesn't exist? LOL

有没有办法删除不存在的引用?哈哈

Update:

更新:

It may have something to do with my XCode environment being Hymaned. After finding a few other posts on here, I tried a Clean All / Build / Touch and when I did the touch, I got the following error in XCode:

这可能与我的 XCode 环境被劫持有关。在这里找到其他一些帖子后,我尝试了 Clean All / Build / Touch,当我触摸时,我在 XCode 中收到以下错误:

Uncaught Exception:

-[XCBuildLogWarningMessage setFileLocations:]: unrecognized selector sent to instance 0x2014dd0a0

未捕获的异常:

-[XCBuildLogWarningMessage setFileLocations:]: 无法识别的选择器发送到实例 0x2014dd0a0

Anyway to reinstall XCode without messing up everything else?

无论如何要重新安装 XCode 而不会弄乱其他一切?

回答by tg2

It turns out the bits on the iPhone simulator were out of sync with XCode. I did a 'Reset Content and Settings' and everything works :) Who knew?

事实证明,iPhone 模拟器上的位与 XCode 不同步。我做了一个“重置内容和设置”,一切正常:) 谁知道?

回答by embinder

If you go to Build Phases within your targets you will see Compile Sources. Make sure each of the m files you need are listed. If not, just add it here and the warning should go away.

如果您转到目标中的构建阶段,您将看到编译源。确保列出了您需要的每个文件。如果没有,只需在此处添加它,警告就会消失。

回答by harryngh

I did some researchand found out that

我做了一些研究,发现

for my case

for my case

I just need to right click to complaining file in the Project Navigator.

我只需要右键单击项目导航器中的抱怨文件。

Choose View/Utilities/Show File Inspector.And for some reason the Target Membershipwas not selected.

选择View/Utilities/Show File Inspector.并且由于某种原因Target Membership未被选中。

That's why the linker says that it doesn't know the existence of the class.

这就是为什么链接器说它不知道类的存在。

I just ticked to choose it and everything works like a charm.

我只是勾选了选择它,一切都像魅力一样。

回答by user1685442

Right click on Storyboard --> Open As --> Source Code

右键单击 Storyboard --> Open As --> Source Code

Find your unknown class name in the storyboard source file. It may be because you have accidentally assigned a custom class name for one of your UIView subclass'.

在故事板源文件中找到您未知的类名。这可能是因为您不小心为您的 UIView 子类之一分配了自定义类名。

回答by Slaine

what fixed it for me was t smply "delete" the ap in the simulator, and rebuild again.

对我来说修复它的是简单地“删除”模拟器中的ap,然后再次重建。

Probably this class was still rerenced in local settings in the iphone simulator.

可能这个类仍然在 iphone 模拟器的本地设置中重新出现。

回答by Swindler

I had this same problem but it was not solved by the solution above. I ended up getting it working by removing the "Main storyboard file base name (iPad)" entry from my info.plist file.

我有同样的问题,但上面的解决方案没有解决。我最终通过从我的 info.plist 文件中删除“主故事板文件基本名称(iPad)”条目来使其工作。

回答by fir

In my case this error appeared after refactoring class name. Somehow the classname not changed in the .xib file. I opened this xib-file in Textedit and replace all OldClassVC to NewClassVC. Then I saved xib-file and Cleaned project before new build. Project runs well.

在我的例子中,这个错误出现在重构类名之后。不知何故,.xib 文件中的类名没有改变。我在 Textedit 中打开了这个 xib 文件,并将所有 OldClassVC 替换为 NewClassVC。然后我在新构建之前保存了 xib-file 和 Cleaned 项目。项目运行良好。

回答by Rajat Talwar

In case you are using Cocoa pods, drag the .framework/.a files to your projects' "link binary with libraries" section.

如果您使用 Cocoa pod,请将 .framework/.a 文件拖到项目的“链接二进制文件”部分。