Stack Overflow Asked by Sanjay Mishra on December 7, 2021
Hi I have to access storyboard from custom framework (LoginUIModule, LoginUIModule have storyboard LoginScreen.storyboard) in app delegate.
I removed Main storyboard from Main Interface and also removed name from Main storyboard file base name as well from .plist, but I getting an error
reason: ‘Could not find a storyboard named ‘LoginScreen’ in bundle NSBundle
Note:- LoginUIModule is separate Module and I need to access it in my main (OneAppllbs) project which is a again separate module
The Code which I used in app delegate
import LoginUIModule
self.window = UIWindow(frame: UIScreen.main.bounds)
let storyboard = UIStoryboard(name: "LoginScreen", bundle: nil)
let initialViewController = storyboard.instantiateViewController(withIdentifier: "LoginUIModuleViewController") as? LoginUIModuleViewController
self.window?.rootViewController = initialViewController
self.window?.makeKeyAndVisible()
Get storyboard from a framework
Set Storyboard ID
for .storyboard
. For example frameworkStoryboardId
let frameworkStoryboard = UIStoryboard(name: "SomeViewController", bundle: frameworkBundle)
let frameworkViewController = frameworkStoryboard.instantiateViewController(withIdentifier: "frameworkStoryboardId") as? SomeViewController
Answered by yoAlex5 on December 7, 2021
You need set Bundle
to access Storyboard.
First create storyboardBundle with Bundle Identifier for framework;
let storyboardName = "LoginScreen"
let storyboardBundle = Bundle(for: LoginUIModuleViewController.self)
or referencing a class in framework:
let storyboardBundle = Bundle(identifier: "com.yourframework.id")
Then create storyboard with this bundle:
let storyboard = UIStoryboard(name: storyboardName, bundle: storyboardBundle)
Answered by Ömer Faruk Öztürk on December 7, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP