When I started coding swift, I was very impressed of the Xcode storyboard mode. With storyboards you really get fast results. For small projects with no complex UI and for prototyping storyboards are the correct tools. But storyboards also have some disadvantages. If you work in teams, my experience is, that storyboards are not really good. A .storyboard-file is a huge xml, which contains all the viewcontroller information. Parallel modifications of the storyboard can lead to a merging hell.
Indicators for a non storyboard Xcode project:
- Complex UI
- Working in teams
- Reuse of view controller code
Create a clean Xcode project without storyboard
- Create a “Single View App” Xcode project
- In the General tab remove what’s in the selection input box “Main Interface”
- Remove the Main.storyboard file (pop-up: “Move to Trash”).
- Programmatically initialize the root viewcontroller in the AppDelegate.
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
window = window ?? UIWindow(frame: UIScreen.main.bounds)
window?.rootViewController = ViewController()
window?.makeKeyAndVisible()
return true
}
}
The complete Swift 4 Xcode project is here on github.com/elmolm