5
votes

I'm writing a card game app for iPad and want to bring it to the Mac using Catalyst. The game is not one where supporting multiple windows makes a lot of sense. However, there is a statistics screen that I show in a modal form sheet on iPad, which I would rather open in a new window on Catalyst. That's the only scenario where I would want to add a new window.

Is there a way for me to support multi-window apps, but only on the Catalyst version of the app? If I check the "Supports multiple windows" checkbox in the app target settings in Xcode, then the user is suddenly granted the option to open more windows on the iPad app from App Expose, which isn't the functionality I'm looking for.

enter image description here

1
Did you ever figure out a solution to this? - Benr783
I didn’t, sadly. Ended up sticking to single window using modals on Mac, even though it’s a worse experience. Maybe Catalyst 2.0 will be better. - UberJason
I ended up finding a solution to this for me. Just posted it below. - Benr783

1 Answers

6
votes

You can do this by adding a second UIApplicationSceneManifest to your Info.plist, with -macos added to it, with different settings than for the iOS/iPadOS target. For example:

<key>UIApplicationSceneManifest</key>
<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>
            </dict>
        </array>
    </dict>
</dict>
<key>UIApplicationSceneManifest-macos</key>
<dict>
    <key>UIApplicationSupportsMultipleScenes</key>
    <true/>
    <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>
            </dict>
        </array>
    </dict>
</dict>

This plist will allow support for multiple scenes on macOS, but not iPadOS.

Additionally, you can prevent new windows from being created through the file menu by removing the new scene button. Add this code to your App Delegate.

- (void)buildMenuWithBuilder:(id<UIMenuBuilder>)builder {
    [builder removeMenuForIdentifier:UIMenuNewScene];
}

Using platform-specific keys is not documented anywhere, but @stroughtonsmith has made developers aware that it works.