Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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...

like image 802
Ivan Ngan Avatar asked Apr 22 '16 01:04

Ivan Ngan


1 Answers

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.

like image 99
Silvertaurus Avatar answered Sep 21 '22 19:09

Silvertaurus