diff --git a/samples/CommunityToolkit.Maui.Sample/App.xaml.cs b/samples/CommunityToolkit.Maui.Sample/App.xaml.cs index 9b356596e..ea121ffd4 100644 --- a/samples/CommunityToolkit.Maui.Sample/App.xaml.cs +++ b/samples/CommunityToolkit.Maui.Sample/App.xaml.cs @@ -7,7 +7,24 @@ public partial class App : Application public App() { InitializeComponent(); - MainPage = new AppShell(); } + +#if MACCATALYST + protected override Window CreateWindow(IActivationState? activationState) + { + Window window = base.CreateWindow(activationState); + window.Destroying += (object? sender, EventArgs args) => + { + if (Current?.Windows?.Count - 1 == 0) + { + // Exit the app when the last window closes + // This ensures app closes when last window closes on Mac + Environment.Exit(0); + } + }; + return window; + } + +#endif } \ No newline at end of file diff --git a/samples/CommunityToolkit.Maui.Sample/Platforms/MacCatalyst/Info.plist b/samples/CommunityToolkit.Maui.Sample/Platforms/MacCatalyst/Info.plist index c342a6fa0..4544a6c5c 100644 --- a/samples/CommunityToolkit.Maui.Sample/Platforms/MacCatalyst/Info.plist +++ b/samples/CommunityToolkit.Maui.Sample/Platforms/MacCatalyst/Info.plist @@ -24,6 +24,23 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + __MAUI_DEFAULT_SCENE_CONFIGURATION__ + UISceneDelegateClassName + SceneDelegate + + + + XSAppIconAssets Assets.xcassets/appicon.appiconset NSSpeechRecognitionUsageDescription diff --git a/samples/CommunityToolkit.Maui.Sample/Platforms/MacCatalyst/SceneDelegate.cs b/samples/CommunityToolkit.Maui.Sample/Platforms/MacCatalyst/SceneDelegate.cs new file mode 100644 index 000000000..051eaf832 --- /dev/null +++ b/samples/CommunityToolkit.Maui.Sample/Platforms/MacCatalyst/SceneDelegate.cs @@ -0,0 +1,12 @@ +using System; +using Foundation; +using Microsoft.Maui; +using ObjCRuntime; +using UIKit; + +namespace CommunityToolkit.Maui.Sample.Platforms.MacCatalyst; + +[Register("SceneDelegate")] +public class SceneDelegate : MauiUISceneDelegate +{ +}