Setup UIKIT Without StoryBoard

luizrebelatto

Luiz Gabriel

Posted on September 1, 2024

Setup UIKIT Without StoryBoard
  • First you need create a new project

create new project

  • Delete the file main from your project

file main

  • after that we will have to clean some properties where it refers to file main
  • click on the symbol ➖ and delete the property Storyboard Name

property Storyboard Name

  • Access the main file, go to "build settings" and search about the reference "main"
  • delete the value's property

build settings

  • access the file scene delegate
  • inside function "scene", we will add this code above
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
  guard let windowScene = (scene as? UIWindowScene) else { return }
  let window = UIWindow(windowScene: windowScene)
  let vc = ViewController()
  window.rootViewController = vc
  window.makeKeyAndVisible()
  self.window = window
}
Enter fullscreen mode Exit fullscreen mode

To test if works it, access the viewController add this line inside the method viewDidLoad()

import UIKit

class ViewController: UIViewController {
  override func viewDidLoad() {
    super.viewDidLoad()
    view.backgroundColor = .yellow
  }
}
Enter fullscreen mode Exit fullscreen mode

Just execute and magic happens 🍏

💖 💪 🙅 🚩
luizrebelatto
Luiz Gabriel

Posted on September 1, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Setup UIKIT Without StoryBoard
ios Setup UIKIT Without StoryBoard

September 1, 2024