12
votes

Now, I have a workspace which have two project inside, one is call "ProjectOne" and the other is "ProjectTwo" as follow:

image

They have a storyboard respectively and now I want to connect two storyboard by pressing the "To Project Two" as follow:

image

but when I click the button, it show

"Terminating app due to uncaught exception 'NSInvalidArgumentException', >reason: 'Could not find a storyboard named 'two' in bundle NSBundle 8C6A5FDC9E06/ProjectOne.app> (loaded)'"

Is it possible to do that? I seeking the method for a few days but also no idea...

4
A coworker of mine ran into the same issue today. It seems as though the Bundle identifier in the storyboard is ignored. This can be verified by creating an NSBundle instance for ProjectTwo and logging its description. The description then clearly would indicate ProjectTwo and not ProjectOne. Have you managed to find a solution?Bart van Nierop

4 Answers

10
votes

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.

enter image description here

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

enter image description here

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.

enter image description here

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.

enter image description here

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

enter image description here

2
votes

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

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.

0
votes

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!)!
    }
0
votes

If Bundle you are referencing in Storyboard was never loaded before invoking Segue, system will use main app bundle. Bug or overlook on apple side?

To fix issue you have to load bundle.

let bundle = ... {your bundle here} 
if !bundle.isLoaded() {
    bundle.load()
}

Execute it at start of the app, or just make sure it runs before you attempt to perform segue.

I was bumping into this issue several times over the years, but couldn't figure out what was causing it. At one moment segue called from same ViewController in different places once worked and other did not. I was going crazy! Then I found, that the working call was preceded by manual loading some custom popup controller from this storyboard from code. It was causing load of Bundle and "magically" resolving problem for the duration of the session.