My app is a SwiftUI document based app using DocumentGroupLaunchScene. In iOS(iPadOS) 18.4, when it launches, it has duplicate toolbar items, and when I close the current document and open other documents, it adds more duplicates. It also shows a wrong document name, which shows the first opened document name. This issue can be reproduced in the sample code (Building a document-based app with SwiftUI).
I have submitted Feedback (FB17025216), but not sure if this is a known bug or if I'm missing anything.
How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here
Duplicate toolbar item and wrong document name in SwiftUI document based app
There is something a little more serious seemingly going on and it seems to relate to DocumentGroup regardless of DocumentGroupLaunchScene being used or not.
It seems that when you open a document it is being loaded twice; making the all views for the document editor twice and adding them to the view hierarchy, one on top of the other. When you go back to the document picker and open another document (or even the same one) another view is created and stacked on top of the existing views.
This happens in iPadOS 18.4 but not 18.3.1
Indeed, on iPadOS 18.4, .onAppear is called twice (on 18.3.1 and before, it's called only once). Sometimes, the navigation bar flicks and shows the newly opened document title instead of the previously opened document title, and duplicated toolbar items disappear. Still, the duplication comes back sooner or later. This issue is also impacting document saving. When re-opened, the document modification is lost (the modification wasn't saved). There must be some changes in DocumentGroup on iOS 18.4 and iPadOS 18.4.
This has been broken in various ways for several versions of iOS/iPadOS now. All trivially reproducible in the sample app. I've filed several feedbacks.
Because of the breakage, I've created an alternative file browser in SwiftUI: https://github.com/audulus/FileBrowser. I hope that helps others.
I also encounter this issue since iOS 18.4 and submitted a feedback: FB17112128 : DocumentGroup API on iOS 18.4 causes duplicated toolbar items, wrong document name, …
Just adding my voice to this. As of iPadOS 18.4:
The .onAppear and .task modifiers are called twice at startup. The second call to .task really threw me off because I thought it was guaranteed to only ever be called once in this sort of circumstance.
The toolbar shows the previously opened document title.
Showing a navigation title using .inline makes the title appear as if it's the document name.
Showing a navigation title using .large makes the document name disappear, but you can still click that invisible are and the rename menu appears.
In the document browser itself, the search feature often errors-out a few times before accepting input. Though admittedly, this may have existed prior to iPadOS 18.4. Anyone else seeing this last one?
There is also an issue on iOS 18.3: whenever I change the name of the file, the toolbar items disappear.
FB17112128 has been fixed in iOS 18.5