NSItemProvider can't export file representations in iOS 17.4 beta

Originator:oberai.kabir
Number:rdar://FB13616781 Date Originated:Feb 13 2024
Status:Open Resolved:
Product:Foundation Product Version:
Classification: Reproducible:
 
On iOS 17.4 beta, registering an item to `NSItemProvider` via `registerFileRepresentation` causes the other end (the receiving share/activity extension) to be unable to open the file.

Repro steps:
1. Run the following code: https://gist.github.com/kabiroberai/8e9422a45053d798b36b79838504c50e
2. Tap Share
3. Tap Save to Files (or, for that matter, select any other share extension.)

Observe that the “Save to Files” sheet crashes.

When debugging a share extension that imports the file — such as via `NSItemProvider.loadDataRepresentation` or `NSItemProvider.loadFileRepresentation` — an error is presented along the following lines:

```
Upload preparation for claim 575BAF6D-30CF-45A6-B8DD-C0BC235DD848 completed with error: Error Domain=NSCocoaErrorDomain Code=260 "The file “file.txt” couldn’t be opened because there is no such file." UserInfo={NSURL=file:///Users/kabiroberai/Library/Developer/CoreSimulator/Devices/250AAF4D-7F3A-4F55-8200-9AC9F141B2B2/data/Containers/Data/Application/C6D38768-B853-4461-82FA-34B54DACBCE8/tmp/.com.apple.Foundation.NSItemProvider.qh74Fn/file.txt, NSFilePath=/Users/kabiroberai/Library/Developer/CoreSimulator/Devices/250AAF4D-7F3A-4F55-8200-9AC9F141B2B2/data/Containers/Data/Application/C6D38768-B853-4461-82FA-34B54DACBCE8/tmp/.com.apple.Foundation.NSItemProvider.qh74Fn/file.txt, NSUnderlyingError=0x600000c26820 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
```

Test environment:
- Reproduced iOS 17.4 beta 3 (simulator)
- Reproduced iOS 17.4 beta 2 (simulator and physical device)
- Unable to reproduce on iOS 17.3 (physical device)
- Unable to reproduce on iOS 17.2 (simulator and physical device)

Development environment:
- macOS 14.1 (23B2073)
- Xcode 15.3 beta 3 (15E5194e)
- Also tested a build on Xcode 15.2 (15C500b) using the 17.4 simulators.

Comments


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!