Has anyone got openWindow to work on iPadOS from the Command menu? Console throws "Use of OpenWindowAction requires the SwiftUI App Lifecycle" (the whole app is). Button works fine when inside a View (and works on Mac)

@phill wow that’s weird.

What I think is happening is that two different instances of OpenWindowAction are being passed: one to the app and the other to the command group by the system. I remember running across similar issues with system-provided environment values in the past.

One (hacky) solution is to pass the known-good openWindow instance to your command group from your app. I just put up a gist that explains this approach. gist.github.com/jaywardell/

Follow

@jaywardell thanks for the suggestion and taking the time to write a gist! It does indeed appear the Command environment is quite different (uhh…broken). Passing an action from the App/Scene as you suggested works. It also appears to work as a focused scene value, which has the benefit of not passing it around.

Sign in to participate in the conversation
The Not So Big Company

The home of The Not So Big Company on Mastodon.