Bring multiple windows to your SwiftUI app

RSS for tag

Discuss the WWDC22 Session Bring multiple windows to your SwiftUI app

Posts under wwdc2022-10061 tag

9 Posts

Post

Replies

Boosts

Views

Activity

.commandsRemoved() does not work for the first scene.
.commandsRemoved() does not work for the Window and WindowGroup scenes if it’s the primary group (first one). Then I tried to add new menu using the code .commands {       CommandGroup(replacing: .newItem) {           Button("New Document") {               newDocument { TestDocument() }           }           .keyboardShortcut("n") } But app crashed with error " Expected subclass override" The test app is a document-based app, with a welcome window using the new Window scene.
1
0
1.1k
Jul ’25
Issues with ShareLink under macOS (with sample code updated on March 1, 2023)
struct ShareButton: View { ... let byLine = currentlyReading.book.byLine ShareLink( item: image, message: Text(byLine), preview: SharePreview(byLine, image: image)) When sharing a book, the following is logged in console and the message field is not filled by byline as expected: BookClub[14058:2642949] [NSExtension] Extension request contains input items but the extension point does not specify a set of allowed payload classes. The extension point's NSExtensionContext subclass must implement `+_allowedItemPayloadClasses`. This must return the set of allowed NSExtensionItem payload classes. In future, this request will fail with an error.
1
1
737
Apr ’23
Sample code doesn't compile as contextAction has been replaced
Sample code fails to compile with Xcode 14.1 beta 3 (14B5033e) as contextAction has been removed/replaced. // Compile error: Value of type 'some View' has no member 'contextAction' #if os(macOS) .contextAction(forSelectionType: Book.ID.self) { books in It looks like it has been replaced with contextMenu(forSelectionType:menu) with a slight difference.
2
1
1.5k
Apr ’23
Xcode Missing checkbox "Support Multiple Windows"
Trying to create a small iPad application that supports an external display. I understand I have to support multiple windows to do that but for some reason there is no check box next to that feature (see screenshot). Is there something I am missing? Might be a dumb question but cannot seem to figure it out as I am pretty new to Xcode and iOS development. Thanks in advance Xcode version 14.1
1
0
3.6k
Nov ’22
App Terminates when using Window and MenuBarExtra in SwiftUI
If you configure a Window and a MenuBarExtra in your app, try this: Open your app and press Command+H to hide it. Place an iPad or another Mac and connect two devices via Universal Control, and click on the other device to make your mac's menu bar inactive. Move your cursor back to your Mac(first device), and click on the whitespace of the Menu Bar. Your App is terminated unexpectedly. This behavior will only appear on those apps using Window, so to solve this issue, we may need to switch Window to WindowGroup which is not what we want. I reappear this issue on Apple's ScreenCaptureKit Sample Code. This is a SwiftUI Scene BUG, please fix this. @main struct CaptureSampleApp: App { var body: some Scene { Window("ID", id: "ID") { ContentView() .frame(minWidth: 960, minHeight: 724) .background(.black) } MenuBarExtra( "App Menu Bar Extra", systemImage: "star" ) { Text("Hello") } } } Filed a feedback: FB11447959.
0
0
1.4k
Sep ’22
Always re-create SwiftUI Window without previous data
Hey everyone! I'm taking a look at all the new APIs and I'd really love to implement some forms in my app in a new window instead of in a sheet as I'm currently making them. Basically I have a couple of forms that gather data from the user and add new stuff to the database. I initially did this by using the new Window API and dismissing it via the dismiss action in the environment once the user clicks "Add", but when I try to create a new Window it seems like the view keeps its state and doesn't really gets re-created, which means that all the forms contain the previous values that I don't need anymore. Is there any nice way to achieve this? I think that I can make this work by making it a WindowGroup and using the openWindow function that accepts a value and passing a new UUID every time, but I don't think this is a good idea since as mentioned on the talk these values get persisted.
2
0
840
Jun ’22
.commandsRemoved() does not work for the first scene.
.commandsRemoved() does not work for the Window and WindowGroup scenes if it’s the primary group (first one). Then I tried to add new menu using the code .commands {       CommandGroup(replacing: .newItem) {           Button("New Document") {               newDocument { TestDocument() }           }           .keyboardShortcut("n") } But app crashed with error " Expected subclass override" The test app is a document-based app, with a welcome window using the new Window scene.
Replies
1
Boosts
0
Views
1.1k
Activity
Jul ’25
Issues with ShareLink under macOS (with sample code updated on March 1, 2023)
struct ShareButton: View { ... let byLine = currentlyReading.book.byLine ShareLink( item: image, message: Text(byLine), preview: SharePreview(byLine, image: image)) When sharing a book, the following is logged in console and the message field is not filled by byline as expected: BookClub[14058:2642949] [NSExtension] Extension request contains input items but the extension point does not specify a set of allowed payload classes. The extension point's NSExtensionContext subclass must implement `+_allowedItemPayloadClasses`. This must return the set of allowed NSExtensionItem payload classes. In future, this request will fail with an error.
Replies
1
Boosts
1
Views
737
Activity
Apr ’23
Sample code doesn't compile as contextAction has been replaced
Sample code fails to compile with Xcode 14.1 beta 3 (14B5033e) as contextAction has been removed/replaced. // Compile error: Value of type 'some View' has no member 'contextAction' #if os(macOS) .contextAction(forSelectionType: Book.ID.self) { books in It looks like it has been replaced with contextMenu(forSelectionType:menu) with a slight difference.
Replies
2
Boosts
1
Views
1.5k
Activity
Apr ’23
Xcode Missing checkbox "Support Multiple Windows"
Trying to create a small iPad application that supports an external display. I understand I have to support multiple windows to do that but for some reason there is no check box next to that feature (see screenshot). Is there something I am missing? Might be a dumb question but cannot seem to figure it out as I am pretty new to Xcode and iOS development. Thanks in advance Xcode version 14.1
Replies
1
Boosts
0
Views
3.6k
Activity
Nov ’22
SwiftUI/PlatformDocument_Mac.swift:13: Fatal error: Expected subclass override
I'm trying to use the Environment newDocument function in the latest SwiftUI and getting this error when I attempt to create the document. Has anyone else seen this?
Replies
3
Boosts
0
Views
1.2k
Activity
Sep ’22
App Terminates when using Window and MenuBarExtra in SwiftUI
If you configure a Window and a MenuBarExtra in your app, try this: Open your app and press Command+H to hide it. Place an iPad or another Mac and connect two devices via Universal Control, and click on the other device to make your mac's menu bar inactive. Move your cursor back to your Mac(first device), and click on the whitespace of the Menu Bar. Your App is terminated unexpectedly. This behavior will only appear on those apps using Window, so to solve this issue, we may need to switch Window to WindowGroup which is not what we want. I reappear this issue on Apple's ScreenCaptureKit Sample Code. This is a SwiftUI Scene BUG, please fix this. @main struct CaptureSampleApp: App { var body: some Scene { Window("ID", id: "ID") { ContentView() .frame(minWidth: 960, minHeight: 724) .background(.black) } MenuBarExtra( "App Menu Bar Extra", systemImage: "star" ) { Text("Hello") } } } Filed a feedback: FB11447959.
Replies
0
Boosts
0
Views
1.4k
Activity
Sep ’22
Questions about iPadOS new feature "Stage Manager"
Can another app window opens in Stage Manager when another apps' "UIRequiresFullScreen = TRUE" ? It seems that there is a limitation in the beta released yesterday... Not sure it's a bug or sth... Open only 1 app in windowed-screen once seems stupid
Replies
2
Boosts
1
Views
2.4k
Activity
Sep ’22
Data-driven WindowGroup only available on macOS?
I'm seeing that the new type-based WindowGroup initializers (i.e. WindowGroup(for: MyType.self) { ... }) are available on macOS, but not iPadOS. The WWDC sessions seemed to imply that this API was available on iPadOS as well. Am I mistaken or is it expected to become available in a later beta?
Replies
1
Boosts
1
Views
1.7k
Activity
Jul ’22
Always re-create SwiftUI Window without previous data
Hey everyone! I'm taking a look at all the new APIs and I'd really love to implement some forms in my app in a new window instead of in a sheet as I'm currently making them. Basically I have a couple of forms that gather data from the user and add new stuff to the database. I initially did this by using the new Window API and dismissing it via the dismiss action in the environment once the user clicks "Add", but when I try to create a new Window it seems like the view keeps its state and doesn't really gets re-created, which means that all the forms contain the previous values that I don't need anymore. Is there any nice way to achieve this? I think that I can make this work by making it a WindowGroup and using the openWindow function that accepts a value and passing a new UUID every time, but I don't think this is a good idea since as mentioned on the talk these values get persisted.
Replies
2
Boosts
0
Views
840
Activity
Jun ’22