即使接口生成器是一个MyClass,我得到一个错误时启动应用程序。

当MyClass是库的一部分时,就会发生这种情况,如果直接在应用程序目标中编译该类则不会发生这种情况。


当前回答

In my case I got this error because I'd tried to save some work by creating a new project and then deleting several of the source files and copying over the source files of the same name from the working project. I also copied my MainStoryBoard file which was looking for my RootViewController. However, when I had deleted the original RootViewController and then added in the RootViewController from the previous product, evidently the Add Files operation failed to "check" the target box as suggested above. By merely visting all of the newley imported ".m" files and making sure that the target membership box was checked, all was well. I think what was happening was that the storyboard file was looking for a class that had been "excluded" from the link because the target membership was unchecked. Making sure the required files for the target are so designated in the target membership in the file inspector did the trick. Thanks Pat! (see above)

其他回答

我有“未知类RateView在接口生成器”,其中RateView是UIView的子类。我已经在Storyboard场景中放置了一个UIView,并将自定义类字段更改为RateView。尽管如此,这个错误还是出现了。

为了调试,我将我的类的名称改为RateView2,并将所有引用更改为匹配,除了UIView的自定义类字段。错误消息仍然像以前一样出现,RateView是缺失的类。这确认了错误消息与Custom类字段的值相关。我将这个值更改为RateView2,错误消息更改为“未知类RateView2在接口生成器”。某种程度上的进步。

最后,我在文件检查器中检查源代码文件本身。在那里,我发现源代码文件(我从教程中复制的)与我的Target没有关联。换句话说,它没有目标会员。我选中了使类的源代码文件成为目标应用程序成员的复选框,错误消息消失了。

当我制作了一个同名的新项目并在模拟器中运行它们时,我就遇到了这个问题。我重命名了其中一个项目,在模拟器中删除了应用程序,然后重新运行并重新构建。

我在更改类名时看到了这个错误,尽管更新了所有相关的.h和.m。结果,我错过了更新.storyboard文件中的“customClass”值。这样问题就解决了。

只需在appdelegate applicatoindidfinishlanching方法的开头添加以下代码,就可以正常工作了

(myclass类);

在我的例子中是一个拼写错误的“自定义类”名称。确保您检查了您所定义的自定义类的故事板。