iOS - 将框架故事板链接到ViewController以用于主项目 [英] iOS - Linking framework storyboard to ViewController for use in main project

查看:105
本文介绍了iOS - 将框架故事板链接到ViewController以用于主项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的主要项目中使用一个故事板,而这个故事板是在框架中创建的。这是为了在未来的众多不同项目中使用该框架。



我使用一个捆绑包管理故事板到主项目,我可以当我构建应用程序时看到它。然而,附加的ViewController,也坐在框架内,在运行时不会链接。该框架中的所有类都被导入到主项目中。



错误信息表明它找不到视图控制器。



我试图将视图控制器添加到包中,但它不喜欢这样,因为它不会允许.h文件进入包中。我也尝试了颠倒依赖关系,以便框架成为捆绑的依赖关系(认为它会导致其中的所有类,包括我的视图控制器,首先加载)。



<有没有人遇到过这个?我非常感谢你的建议!



谢谢,
Chris

解决方案为了让它找到相关的视图控制器,你需要在你的应用程序的其他链接器标志在生成设置中的 -all_load -ObjC



由于应用程序代码实际上并未使用或引用ViewController,因此链接器似乎遗漏了必需的文件,因此链接器将其遗漏。这迫使它在现在连接时使用ViewController。 (请参阅此答案更多细节)



我只是在我的框架旁边放置了我的框架故事板,然后我沿着本指南了解如何为框架制作包

I am attempting to pull through and use a storyboard in my main project which is being created in a framework. This is to use the framework in a multitude of different projects going forward.

I have managed, using a bundle, to feed the storyboard through to the main project and I can see it when I build the app. However the appending ViewController, also sitting within the framework, does not link during runtime. All the classes in the framework are being imported to the main project.

The error message says that it cannot find the view controller.

I have attempted adding the view controller to the bundle, however it does not like this as it will not allow the .h file into a bundle. I have also tried inverting the dependencies so the framework become a dependency of the bundle (thinking was that it would cause all the classes therein, inc my viewcontroller, to load first).

Has anyone encountered this before? I would much appreciate suggestions for a fix!!

Thanks, Chris

解决方案

To get it to find the view controller associated, all you need is -all_load -ObjC in your apps Other Linker Flags in Build Settings.

it seems the linker leaves out the files necessary due to the apps code not actually using or referencing the ViewController, so the linker just leaves it out. This forces it to use the ViewController when linking now. (have a look at this answer for more detail)

i did this with just having my frameworks storyboard in a bundle along side my framework, i followed this guide for finding out how to make the bundle for the framework

这篇关于iOS - 将框架故事板链接到ViewController以用于主项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆