I’m trying to implement my Examples view in my DocumentGroup app on visionOS. I am stuck on what on the surface seems very basic: programmatically opening a document.
Is there an analog to NSDocumentController.shared.openUntitledDocumentAndDisplay
on visionOS?
Here’s what I’ve tried so far.
Ideally, this would a be collection of document templates in a DocumentGroupLaunchScene
. However, I’ve been unable to get DocumentGroupLaunchScene
to work on visionOS.
I’ve tried UIApplication.shared.open(url)
with a url to a document in my app bundle. UIApplication.shared.canOpenURL(url)
returns true, but open(url) has no effect.
In the macOS build, I use NSDocumentController.shared.openUntitledDocumentAndDisplay
, but do not see any iOS or visionOS analog.
@Environment(\.newDocument) private var newDocument
would be ideal, but that is not available on visionOS.
UIApplication.shared.activateSceneSession(for: .init())
brings up the document browser in a new window, at which point clicking the “+” button does what I want. Can I invoke that directly somehow?
It would be sufficient if I could programmatically open a new untitled document. On macOS, I do that and sneak the template contents to the Document constructor in a global variable.
I presume I am just overlooking something simple, but I’ve come up blank so far.
Hi @avitzur ,
Please see this thread: https://developer.apple.com/forums/thread/756948
It does not seem that a document can be programmatically opened on visionOS. I'd really appreciate it if you can submit a feedback report at https://feedbackassistant.apple.com and send the FB number here to request this functionality. The more requests from developers, the better!