Thanks for the great article!

I fixed some bugs, and put the new version in this Gist.

Note: this version is only for picking files, not folders.

Fixed bugs:

  • inside switch sourceType case .files, you want to use folderURL instead of pickedURL to make the document. According to the documentation, “Always use the URL passed into the block instead of the value in the url parameter.”
  • inside documentFromURL(pickedURL:), missing } underneath pickedURL.stopAccessingSecurityScopedResource().

WWDC21 Scholar. I like to read manga and write about Swift. Check out my app, Find — look for text in real life, with outrageous speed.