2

Since upgraded to macOS Mojave, I find there are permission restrictions to user from accessing ~/Library/Safari/Bookmarks.plist. So is there an alternative way to do it programmatically? Is there a SafariKit or something I can use to import bookmarks to my own program? I tried to search online, but no one mentions anything about it. If you guys know, please help me. Thank you

WatashiJ
  • 722
  • 6
  • 19
  • Also: https://stackoverflow.com/a/11974097/2227743 – Eric Aya Oct 05 '18 at 10:02
  • I don't think this would work. First of all, the project I'm writing is not sandboxed. Second, I can't even try to read it in terminal through vim or cat. I'm trying to find a more"official" way of doing it – WatashiJ Oct 05 '18 at 15:10
  • If not sandboxed, then you just have to add the app to System Preferences > Security > Confidentiality > Disk access. And if you add Terminal.app there you will be able to access ~/Library/Safari/Bookmarks.plist again with cat/vim/... – Eric Aya Oct 05 '18 at 18:11
  • Thank you for your help. I'll give it a try – WatashiJ Oct 06 '18 at 12:22
  • 1
    @Moritz Hello, I have tried the way you described, it works perfectly. Thank you. Maybe you can properly answer this question, then I will set it to the correct answer. It may be helpful for others too – WatashiJ Oct 07 '18 at 18:15

1 Answers1

4

You cannot access ~/Library/Safari/Bookmarks.plist anymore because of the stricter security rules in Mojave.

I don't think there's an API to do this specific action yet, so the solution for now is to add the application yourself to System Preferences > Security > Confidentiality > Disk access.

For example if you add Terminal.app to this Confidentiality subgroup, this will grant access to the whole disk to all commands executed in Terminal, inluding using cat/vim/... to access ~/Library/Safari/Bookmarks.plist.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253