Open new document in SwiftUI on iOS

I have a SwiftUI document based app. The iOS version has a Scene Delegate:

class SceneDelegate: NSObject, UIWindowSceneDelegate 
{
	func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>)
  {
		for context in URLContexts
		{
			let url = context.url  // url.scheme = my custom scheme
      let text = ... extracted from url ...
      // I want to open a new untitled document with text
      // but 'newDocument' has been explicitly marked unavailable for iOS
    }
  }
}

In a SwiftUI View, you can create documents using
NewDocumentButton.

There isn't a SwiftUI equivalent for newDocument available on iOS. You could always file an enhancement request using Feedback Assistant If you'd like us to consider adding the necessary functionality.

Once you file the request, please post the FB number here. If you're not familiar with how to file enhancement requests, take a look at Bug Reporting: How and Why?

Open new document in SwiftUI on iOS
 
 
Q