Thank you.

The code below will display the first view controller from a storyboard 
embedded in a custom framework when called from an app that links to the 
framework.

Yes, the final goal is to call this method from within a method in a class in 
the framework, but, this is really helpful in getting up and running from an 
app that links to a custom framework.

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // Within the viewDidLoad of the target app that is linking to the 
framework that has a storyboard, 
    // this will allow you to display the first view controller of the 
storyboard within the framework.

    NSString *myFrameworkIdentifier = @"com.myCompany.testFramework";    
    NSString *myStoryboardName = @"Insert your storyboard's name here without 
the extension";
    
    NSBundle *myBundle = [NSBundle bundleWithIdentifier:myFrameworkIdentifier];
    
    UIStoryboard *storyboardInstance = [UIStoryboard 
storyboardWithName:myStoryboardName bundle:myBundle];
    
    UIViewController *initialViewControllerInstance =  [storyboardInstance 
instantiateInitialViewController];
    
    [self presentViewController:initialViewControllerInstance animated:NO 
completion:NULL];

}


Even if the storyboard files aren't data files. I do need to treat them 
somewhat as data files since they are not automatically added to the framework 
and they must be referenced via the bundle.

Even though the storyboard files are renamed to storyboardc, loading them in 
the manner above works as expected.

And if you're considering making a project with a framework target, make sure 
that there are no spaces at all in the path to any part of your project or your 
framework search paths get all screwed up by Xcode.  This means that if you do, 
the framework will build, but none of the headers will be able to be found in 
the target application that links to the framework.  

Thanks Jens and Q for pushing me in the right direction.

- Alex Zavatone


On Mar 1, 2016, at 2:38 PM, Alex Zavatone wrote:

> So, they aren't data files then.
> 
> Should I expect to present an initial view controller in a storyboard without 
> needing to reference a bundle or include the storyboard in a bundle?  
> 
> 
> 
> On Mar 1, 2016, at 1:24 PM, Jens Alfke wrote:
> 
>> 
>>> On Mar 1, 2016, at 6:57 AM, Alex Zavatone <z...@mac.com> wrote:
>>> 
>>> Well, in the resources bundle, it's no longer a .storyboard file, but a 
>>> .storyboardc file.
>>> What a surprise.
>> 
>> Storyboards are source files. They get compiled into a binary form 
>> (basically an NSArchive, IIRC) that has a different suffix.
>> 
>> (The same thing happens with .xibs. If you look inside your app bundle, 
>> they’ve been compiled into binary .nib files.)
>> 
>> —Jens
> 
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list      (Xcode-users@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/xcode-users/zav%40mac.com
> 
> This email sent to z...@mac.com

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (Xcode-users@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/xcode-users/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to