I have tested creating a new App in XCode 11 with IOS13 target.
I noticed the new SceneDelegate.swift and all the changes that occured in appDelegate.
So far so good.
But now, what should I change in an existing app to make it support scenes ?
I have tried modiying the AppDelegate and creating an UISceneDelegate to mimic what is in this small demo app.
It compiles, but I just get the launchscreen and then a black screen. Clearly, I am not connected to the right view.
What am I missing ?
OK, just got it !
In infos.plist, need to add Application Scene Manifest section.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
<key>UISceneStoryboardFile</key>
<string>Main</string>
</dict>
</array>
</dict>
</dict>
</plist>
And everything works.
I just have a few open points :
- When I introduce a print in any of the sceneDelegate, does not get printed ; seems that API not called ?
@available(iOS 13.0, *)
func sceneWillResignActive(_ scene: UIScene) {
// Called when the scene will move from an active state to an inactive state.
// This may occur due to temporary interruptions (ex. an incoming phone call).
print("resign Scene")
}
Unless I specify IOS 13 as target.
- I have removed manually the unneeded API from AppDelegate ; but they will be needed to run < IOS12.
Do I need to remove (seems to work OK if I leave it) to avoid interference with sceneDelegate ?
If needed, how can I do it with an @available statement (to test unavailable for IOS < 13) ?
I could not find the @available syntax for that.