MacOS Sidebar is closed on default when app is run

Hi,

I'm creating a SwiftUI MacOS app with a NavigationSplitView consisting of a Sidebar and Detail. It works great; however, whenever I ran the app the sidebar is hidden. As a user I can easily click the button or menu option to bring it back BUT it's frustrating to do AND I need to test the app now.

Is there a way to have it open by default when running the app or, at least, programmatically so I can set it as a user default? And/Or a way to make it visible when running UITests?

Thanks

The only way I could make this work when running the application from within Xcode was to shut down the application using its own Quit menu while the sidebar was open. Just re-starting the app by hitting the "run" button would close the sidebar again.

When you Archive the app and run outside of Xcode, it seems to open with the sidebar visible no matter what state it was in when you closed it. At that point, saving the "closed" state via NavigationSplitView's visibility property is probably how you'd want to preserve sidebar open/close across restarts. Maybe that would work when running from Xcode, too?

Also, if you notice in the message output window, there's some warning about being able to read certain kinds of preferences, which is maybe an issue ONLY when run within Xcode.

MacOS Sidebar is closed on default when app is run
 
 
Q