我正在尝试在我的主项目中完成并使用故事板,该项目是在框架中创建的.这是为了在未来的众多不同项目中使用该框架.
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.
我已经使用捆绑包将故事板提供给主项目,并且在构建应用程序时可以看到它.然而,同样位于框架内的附加 ViewController 在运行时不会链接.框架中的所有类都被导入到主项目中.
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.
我尝试将视图控制器添加到包中,但它不喜欢这样,因为它不允许 .h 文件进入包中.我还尝试反转依赖关系,使框架成为捆绑包的依赖关系(认为它会导致其中的所有类,包括我的视图控制器,首先加载).
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!!
谢谢,克里斯
要让它找到关联的视图控制器,你只需要在你的应用程序中使用 -all_load -ObjC
Other Linker Flags in Build设置.
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.
由于应用程序代码实际上并未使用或引用 ViewController,链接器似乎遗漏了必要的文件,因此链接器只是将其遗漏了.这会强制它在现在链接时使用 ViewController.(看看 这个答案更详细)
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 以在主项目中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!