"Recents" in document based app

I am working on a document based app in SwiftUI, using the approach outlined in wwdc20-10039.

I have a DocumentGroup and an editor. All works pretty well.

However, when I launch the app, sometimes it starts with 'Recents' selected and the code shows a spinner. This never completes.

Two questions:
  1. Is this a bug in beta1 to never complete the search in recents?

  2. What do I need to do to get something in the 'recents' folder (or is it all 'automatic'?)

  3. What controls if the app opens to this view or the normal file picker view?

Replies

The Recents item is just one of many items in the normal file picker, there's also iCloud Drive, On My iPad (or iPhone), Recently deleted etc. In order to get something in the Recents your app needs to have previously saved or read a document. If you run in the Simulator for the first time or erase the settings of the simulator device it would start with On My iPad (or iPhone) with a blank document icon which creates a new doc when the user taps on it. Concerning the spinning progress view, the system just tries to be smart by attempting to restore the previous state of the app by reopening the last viewed document, and if there aren't any, well it obviously can't. I haven't tried that on an actual connected device lately so I don't remember if it's just a Simulator oddity that the search never finishes.