Using a storyboard reference to a storyboard in a different project/bundle appears broken

北战南征 提交于 2019-11-29 06:35:39

You need to use the complete names of the storyboard you are including if your storyboard is in another project/module - this means including the bundle name. Please see the image below for how you would set this up in your storyboard. I have created an example setup with ProjectOne and ProjectTwo the same as your project setup.

The key is the information you put in the Storyboard reference. You need to include the bundle name as well! Just for reference I have included a link to Adding a Storyboard Reference

EDIT

While this works it leads to issues later on as you start to build your storyboard out with various scenes which are backed by view controllers, which now have to be linked to both project targets. More importantly this relationship is hidden in the project's configuration details. A better way for this to work would be to take advantage of the workspace and add a shared folder for the resources that are used by both projects.

Next add the shared folder to the workspace at the same level as ProjectOne and ProjectTwo. Now add a reference to the shared folder to each project by dragging it on to the project files(xcodeproj). This will add the folder to the projects target for you.

Now each project contains a reference to the shared folder, the sharing relationship is now explicitly shown within the project navigator.

1.You can add both storyboard's Target Membership like this:

2.Change the name of your source files in Project two to avoid collision, check their Target Membership to Project one,configure these changes to storyboard two.

3.The AppDelegate file of Project two should be leave unchanged.

This was a solution I found for referencing a pod from a project - you can expose the bundle from the pod(or other project in your case), and then access it when you need to. It may also be worth mentioning that methods you want to access should be public.

    static var bundle:NSBundle {
    let podBundle = NSBundle(forClass: thisViewController.self)

    let bundleURL = podBundle.URLForResource("myPod", withExtension: "bundle")
    return NSBundle(URL: bundleURL!)!
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!