Cannot create a new document using UIDocumentBrowserViewController in iOS 13 Simulator

Originator:me
Number:rdar://7250982 Date Originated:2019-09-11
Status:Open Resolved:
Product:Xcode Simulator Product Version:11 GM
Classification:Bug Reproducible:Always
 
FB7250982

After tapping the plus icon in UIDocumentBrowserViewController in iOS 13 Simulator to create a document, 
both in the nav bar as well as in the main content (when Browse / On my iPad is selected), all that happens is that the following error message is printed in the Xcode console:

```
2019-09-11 15:58:59.443967+0200 UIDocumentBrowserViewControllerExample[31951:2001090] [DocumentManager] Cannot create urlWrapper for url file:///Users/tomkraina/Library/Developer/CoreSimulator/Devices/51581B3F-7561-4139-BF2F-23905344160F/data/Containers/Data/Application/0C49C058-2BCE-4EE0-AB28-1CDFFB8313F4/tmp/910EAC6A-F895-489A-A0D2-17A43C6D3CA0.txt. error Error Domain=NSPOSIXErrorDomain Code=22 "couldn't issue sandbox extension com.apple.app-sandbox.read-write for '/Users/tomkraina/Library/Developer/CoreSimulator/Devices/51581B3F-7561-4139-BF2F-23905344160F/data/Containers/Data/Application/0C49C058-2BCE-4EE0-AB28-1CDFFB8313F4/tmp/910EAC6A-F895-489A-A0D2-17A43C6D3CA0.txt': Invalid argument" UserInfo={NSDescription=couldn't issue sandbox extension com.apple.app-sandbox.read-write for '/Users/tomkraina/Library/Developer/CoreSimulator/Devices/51581B3F-7561-4139-BF2F-23905344160F/data/Containers/Data/Application/0C49C058-2BCE-4EE0-AB28-1CDFFB8313F4/tmp/910EAC6A-F895-489A-A0D2-17A43C6D3CA0.txt': Invalid argument}.
```

When the same app is run on a real device, everything works as expected.

Related question on Stack Overflow: https://stackoverflow.com/questions/57807670/uidocumentbrowserviewcontroller-error-cannot-create-urlwrapper-for-url-on-ios1?stw=2



Steps to reproduce:
1. Open the attached Xcode project and run in iOS 13 Simulator (e.g. iPad Pro 11")
2. Tap the "+" icon in the nav bar to create a new document

The attached project is basically just a "Document Based App" template with implemented documentBrowser(_ controller:didRequestDocumentCreationWithHandler:) method


Expected behaviour:
I expected a new document would be created and presented from the document browser.

Actual behaviour:
Nothing is presented from the document browser and the following message is printed in the Xcode console:

```
2019-09-11 15:58:59.443967+0200 UIDocumentBrowserViewControllerExample[31951:2001090] [DocumentManager] Cannot create urlWrapper for url file:///Users/tomkraina/Library/Developer/CoreSimulator/Devices/51581B3F-7561-4139-BF2F-23905344160F/data/Containers/Data/Application/0C49C058-2BCE-4EE0-AB28-1CDFFB8313F4/tmp/910EAC6A-F895-489A-A0D2-17A43C6D3CA0.txt. error Error Domain=NSPOSIXErrorDomain Code=22 "couldn't issue sandbox extension com.apple.app-sandbox.read-write for '/Users/tomkraina/Library/Developer/CoreSimulator/Devices/51581B3F-7561-4139-BF2F-23905344160F/data/Containers/Data/Application/0C49C058-2BCE-4EE0-AB28-1CDFFB8313F4/tmp/910EAC6A-F895-489A-A0D2-17A43C6D3CA0.txt': Invalid argument" UserInfo={NSDescription=couldn't issue sandbox extension com.apple.app-sandbox.read-write for '/Users/tomkraina/Library/Developer/CoreSimulator/Devices/51581B3F-7561-4139-BF2F-23905344160F/data/Containers/Data/Application/0C49C058-2BCE-4EE0-AB28-1CDFFB8313F4/tmp/910EAC6A-F895-489A-A0D2-17A43C6D3CA0.txt': Invalid argument}.
```

Comments

Demo app

https://github.com/tomaskraina/feedbackassistant.apple.com/tree/master/FB7250982-UIDocumentBrowserViewController-vs-iOS13Simulator


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!