Here is my code for displaying an image picker:

        let pickerController = UIImagePickerController()
        pickerController.delegate = self
        pickerController.allowsEditing = false
        pickerController.mediaTypes = [kUTTypeMovie as String]
        pickerController.sourceType = .photoLibrary

In the delegate I have:

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
    guard let videoURL = info[.mediaURL] as? URL
        else { return }
    do {
        let newFileLocation = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString + ".mov")
        FileManager.default.moveItem(at: videoURL, to: newFileLocation)
    } catch {
        // “trim.92501481-FA5B-490C-8F55-575DE076C8A1.MOV” couldn’t be moved because you don’t have permission to access “tmp”
    }
}

I went back and tried this on iOS 13.5 and it works fine, but in iOS 13.7 I am getting this strange error.

2

There are 2 best solutions below

3
joel.d On

Ah simple fix, change:

FileManager.default.moveItem(at: videoURL, to: newFileLocation)

to

FileManager.default.copyItem(at: videoURL, to: newFileLocation)
0
Christopher Schardt On

I just discovered the same problem and solution. The funny thing is that if you're doing this for the camera, moving the file works. But if you're doing this for the Camera Roll, it doesn't. Worse of course is that Apple changed this behavior without documenting it anywhere. I too have been using "move" for years for obvious efficiency reasons.

Also, the error says that the app doesn't have permission for the destination folder, when in fact the permission is lacking for the source folder. So no help from iOS here.