Getting started with multi-window on iPadOS

A short step-by-step guide on how to convert an existing single window iPad app into a multi-window app.

Getting started with multi-window on iPadOS

A short explanation of how to set up multi-window in an existing app

With iPadOS 13 your apps can work in multiple windows at once. This is a long-awaited feature for power users wanting to see things side by side. Not to mention it greatly improves the usability of your application if you decide to port it to macOS using Project Catalyst.

We decided to test this new functionality in the PostNL app, a popular parcel tracking app in the Netherlands, and managed to get it to work in our five year old Swift codebase on iOS 13 beta 1. This is a step-by-step guide on how to convert an existing single window app into a multi window app.

Converting from single to multi-window

Luckily, enabling multi-window support doesn’t require large code changes. All we need to do is move the code that creates a UIWindow from the UIAppDelegate to the newly introduced UIWindowSceneDelegate.

Your UIAppDelegate probably looks something like this:

Which we can convert to the new style with a UIWindowSceneDelegate:

Let Xcode know that your app supports multi window by checking the ‘Supports multiple windows’ box under Project > Select your target > General.

Now in order for iOS to find your Scene Delegate, add the following to your Info.plist.

That’s all, now we can open extra windows for our app by using the following code:

Multi-window proof of concept in the existing PostNL app

From here on out

Congratulations, Now your app has rudimentary support for multiple windows! If you want to get the most out of this feature you’ll probably want to restructure your app to utilise NSUserActivity more, and you will need to think about when you want to open or close windows for your users. We’re going to play around with this a lot during the betas to discover what works best. For now, we hope we’ve made it a bit easier for you to start playing around with this great new feature!

UIApplication.requestSceneSessionActivation in action

Check out our other WWDC19 blog posts on https://engineering.q42.nl/tag/wwdc.