Skip to content

Instantly share code, notes, and snippets.

@tomasharkema
Last active June 3, 2023 07:44
Show Gist options
  • Save tomasharkema/d60a607a9ea05c294fc65f5db1e8f5ab to your computer and use it in GitHub Desktop.
Save tomasharkema/d60a607a9ea05c294fc65f5db1e8f5ab to your computer and use it in GitHub Desktop.
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<true/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
</dict>
</array>
</dict>
</dict>
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
// Moved window creation to the SceneDelegate below
return true
}
// Added this method:
// Here we tell iOS what scene configuration to use
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
connectingSceneSession.userInfo?["activity"] = options.userActivities.first?.activityType
// Based on the name of the configuration iOS will initialize the correct SceneDelegate
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
}
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
// ...
window = UIWindow(bounds: UIScreen.main.bounds)
window.rootViewController = PostNLRootViewController()
window.makeKeyAndVisible()
// ...
return true
}
}
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 }
window = UIWindow(windowScene: windowScene)
window.rootViewController = PostNLRootViewController()
window.makeKeyAndVisible()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment