Create the XCode project, set-up whatever app name and organization name you want.
Delete main.storyboard
. Then go into info.plist
and delete the key-value, Main storyboard file base name
.
// set up the window size
window = UIWindow(frame: UIScreen.main.bounds)
guard let window = self.window else { fatalError("no window") }
// set the view controller
window.rootViewController = ViewController()
window.makeKeyAndVisible()
This will, by default set the initial ViewController as the default screen.
Because we are not using ViewControllers anymore, we need to set-up some things. Here is how a ViewController might look.
import UIKit
class ViewController: UIViewController {
convenience init() {
self.init(nibName: nil, bundle: nil)
// set up some stuff here
}
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
super.init(nibName: nil, bundle: nil)
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
prepareView()
}
fileprivate func prepareView() {
}
}
By default, you will need to load the aDecoder
initializer, and the nibName must be set as null as they are only used from storyboards.
the prepareView()
is an example of how you would use it. Right now, the screen would appear as black. To see something show, set your view controller's view background colour to white.
have fun