WWDC22 SALE: Save 50% on all my Swift books and bundles! >>

??? would like to access files in your Documents folder.

Forums > macOS

I am working through the code in the book "Learning Core Audio" by Adamson and Avila. The code builds a series of command line apps to teach Core Audio programming.

One of the examples plays the audio in a file. The original design of the code had the audio file in the same directory as the program, but every time I do a Clean Build Folder option in XCode it erases the test audio file. I modified the program to look for the audio file in my Documents directory. Now the first time I run the program after it has been rebuilt, I get a popup window with the above message. Once I allow the app to access the files in my Documents folder, I can run it as much as I want without the popup, but as soon as I make a change to the source code so that it has to recompile, I get the message again. I assume that it is because MacOS doesn't know that the recompiled program is the same one that I gave permission to.

Is there a way to suppress this message? FWIW, I looked into running the app sandboxed, but it doesn't look like sandboxing doesn't work with command line apps.

   

I found a sortof solution. Instead of the Documents folder, I created a Data folder in the folder containg the application Build folder and placed the output file in there and referenced it as ../../../Data/filename

   

Hacking with Swift is sponsored by Emerge

SPONSORED Why are Swift reference types bad for app startup time, and what’s the performance cost of protocol conformances? That’s just a couple of the topics you can learn about on the Emerge blog — written by the app performance experts behind Emerge’s advanced app optimization and monitoring tools, based on their experience of working at companies like Apple, Airbnb, Snap, and Spotify.

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.