CopyFileTo fails without error (2018r3/Mojave)

Hi all. I am trying to copy a file from within the Photos Library to another folder in my user’s directory using CopyFileTo.

At first I got error -54 (permission error while reading), even though I can copy that file within the Finder, then the error disappeared. I do no longer get an error, but the file is never copied.

Have you ever encountered such a problem?

Does your app have (or maybe need?) a Photos entitlement? How exactly are you getting at this file? The Photos library would probably respond better to being used through an API than directly accessing the files.

@Tim Parnell — That is an interesting point, thank you. I just moved to Mojave (and against my will) from Sierra and I am absolutely not accustomed to this new level of paranoia (or should I say security?).

But how can I add entitlements to a Xojo project in debug mode?

You are running into the protection of Full Disk Access. And yes, it’s paranoia.

You need to sign the app. I did some experimentation a couple of weeks ago. And forgot to note down the exact steps. You need to have a signed version, allow full disk access, then you can start the signed debug version or something similar.

If you want to pick a Photo from the Photos Library using an OpenDialog, you need to add a NSPhotoLibraryUsageDescription. The linked Forum Post explains how that needs to be done.

However, if you just try to access files in the Photos Library without the user having explicitly selected something using an OpenDialog… then yes: your application might even need Full Disk Access.
I’m quite sure there is a Forum Thread about this - I just can’t find it right now…

Are you using App Wrapper? If so check the help on Xojo integration.

You can also use the NSMediaLibraryBrowser (, when using this on Mojave, I never once got asked if I wanted to allow my application to access the Photos library.

Thank you Jürg, Sam, Beatrix and Tim.Your answers made me learn a lot.

I was focused on accessing my photos library and the macOS dialog to allow such access actually uses both the term “photos” and the Photos app’s icon, with added to my confusion. In fact, it was all about granting access to the Pictures folder instead of the photos library itself.