Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access restricted file (/User/user/Library/Messages/xxx) in macOS?

I'm trying to figure out how I can access the ~/Library/Messages folder in my macOS app (swift). Specifically, I'm trying to access the chat.db file.

If I do the following (without sandbox), I get an open error.

let url = try? FileManager.default.url(for: .libraryDirectory, in: .userDomainMask, appropriateFor: nil, create: false)
url = url!.appendingPathComponent("Messages", isDirectory: true).appendingPathComponent("chat.db", isDirectory: false)

// Then open this file...

If I instead point the user to the folder using an Open Dialog, I get a forbidden sign on the folder icon.

What permission do I need to be able to access this file? I've tried Accessibility but that doesn't seem to be it (and also I didn't grant iTerm accessibility and I can still go to that folder). Any pointer is appreciated. Thanks!

(I only need access to this one single file. If there's a way to do it in sandbox, I'd love to go that route. If that's not possible, asking for whatever permission is fine.)

like image 462
danqing Avatar asked Oct 27 '25 06:10

danqing


1 Answers

You need to allow "Full Disk Access" for the applications that need to access that path:

enter image description here

This is part of the privacy changes in macOS Mojave.

like image 167
TheNextman Avatar answered Oct 28 '25 23:10

TheNextman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!