I\'m trying to create a Pod using CocoaPods and I want to bundle a \"Demo\" Storyboard that I can reference to from the Main Storyboard from my example application. The problem
Files included in a Dynamic Framework are embedded in a different NSBundle
in the application. To make it easier to obtain the storyboard, you can create a helper class inside your library:
public class StoryboardHelper: NSObject {
public static let helper = StoryboardHelper()
public lazy var storyboard: UIStoryboard! = UIStoryboard(name: "Main", bundle: NSBundle(forClass: StoryboardHelper.self))
public func rootController() -> UIViewController! {
return storyboard.instantiateInitialViewController()
}
}
NSBundle(forClass: StoryboardHelper.self)
will obtain the bundle of StoryboardHelper
.
This way, your user only needs to do the following to show your root view controller of the embedded storyboard:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
window?.rootViewController = StoryboardHelper.helper.rootController()
window?.makeKeyAndVisible()
return true
}