Skip to content

Instantly share code, notes, and snippets.

@douglashill
Last active August 27, 2024 17:16
Show Gist options
  • Save douglashill/b8125f7e2336b6a47461df0d4898f64d to your computer and use it in GitHub Desktop.
Save douglashill/b8125f7e2336b6a47461df0d4898f64d to your computer and use it in GitHub Desktop.
A minimal iOS UIKit app set up entirely in code rather than using a storyboard and UIApplicationSceneManifest in the Info.plist.
// A minimal iOS UIKit app set up entirely in code rather than using a storyboard and UIApplicationSceneManifest in the Info.plist.
// Last updated for iOS 18.
import UIKit
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
private var _window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
let window = UIWindow(windowScene: scene as! UIWindowScene)
window.rootViewController = UIViewController()
window.makeKeyAndVisible()
_window = window
}
}
@main class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
let configuration = UISceneConfiguration(name: nil, sessionRole: connectingSceneSession.role)
configuration.delegateClass = SceneDelegate.self
return configuration
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment