iOS 14
- remove main story board from files
- from => info remove 'main storyboard file base name'
- then drill down in scene manifest to remove main item 0 main file name and remove
adjust code in sceneDelegate:
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = (scene as? UIWindowScene) else { return }
let window = UIWindow(windowScene: windowScene)
window.rootViewController = ViewController()
window.makeKeyAndVisible()
self.window = window
}
...
Project > Targets > Deployment Info
empty "Main Interface"
Remove Reference in Info.plist
Open your Info.plist
Click the arrow at the leftmost of Application Scene Manifest (UIApplicationSceneManifest) key to expand
Click the arrow at the leftmost of Scene Configuration (UISceneConfigurations) key to expand
Click the arrow at the leftmost of Application Session Role (UIWindowSceneSessionRoleApplication) key to expand
Click the arrow at the leftmost of First Item (Item 0) key to expand
Remove the key Storyboard Name (UISceneStoryboardFile)
From IOS 13
Not in appDelegate anymore...
in SceneDelegate:
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(windowScene: windowScene)
window?.rootViewController = MockupIntroVC()
window?.backgroundColor = .systemBackground // optional
window?.makeKeyAndVisible()
}
AppDelegate
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
window = UIWindow(frame: UIScreen.mainScreen().bounds)
if let window = window {
window.backgroundColor = UIColor.whiteColor()
window.rootViewController = ViewController()
window.makeKeyAndVisible()
}
return true
}
ViewController
class ViewController: UIViewController {
var button :UIButton!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
view.backgroundColor = .redColor()
setupLayout()
}
func setupLayout()
{
if button == nil
{
self.view.addSubview(createButton(self))
}
}
func buttonPressed(sender:UIButton)
{
showNewViewController(SecondViewController())
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
print("\(__FUNCTION__)")
}
deinit
{
print("\(__FUNCTION__) v1")
}
}
// General funcs for demo purposes
func createButton(vc:UIViewController)->UIButton
{
let button:UIButton
button = UIButton(frame: CGRectMake(0,0,123,123))
button.backgroundColor = .yellowColor()
button.addTarget(vc, action: "buttonPressed:", forControlEvents: .TouchUpInside)
button.setTitle("Button", forState: .Normal)
return button
}
func showNewViewController(vc:UIViewController)
{
UIApplication.sharedApplication().keyWindow!.rootViewController = vc.self
}
SecondViewController
class SecondViewController: UIViewController {
var button :UIButton!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
view.backgroundColor = .blueColor()
setupLayout()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func setupLayout()
{
if button == nil
{
self.view.addSubview(createButton(self))
}
}
func buttonPressed(sender:UIButton)
{
showNewViewController(ViewController())
}
deinit
{
print("\(__FUNCTION__) v2")
}
}