> Running on macOS 10.12.6, Xcode 8.3.2, I get to the copyItem call, which 
> shows an error on the console:
> 
> 2017-11-11 11:18:25.931446+1000 MyApp[32662:2408351] open on /path/to/file: 
> Permission denied
> 
> But it doesn't go to either of my catch blocks, but goes to the following 
> line, where the completion handler is to be run. What is going on?

Known (by Apple) bug.  My report was closed as a duplicate of 30350792.

My workaround is to do this in my do block after attempting to copy a file to 
saveFileUrl:

    try fileManager.copyItem(at: url, to: saveFileUrl)
    /// DANGER WILL ROBINSON -- the above call can fail to return an
    /// error when the file is not copied.  radar filed and
    /// closed as a DUPLICATE OF 30350792 which is still open.
    /// As a result I must verify that the copied file exists
    if !fileManager.fileExists(atPath: (saveFileUrl.path)) {
        unexpected(error: nil,
                   "Cannot copy \(url.path) to \(saveFileUrl.path)")
        return false
    }

which duplicates what the catch block would do.

Marc
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to