Access to Safari bookmarks from another application
Asked Answered
P

1

14

I was wondering how we can access Safari bookmarks from another Cocoa application on Mac OS X, in a way that is safe and secure for the future.

As you may know, two mechanisms were common to retreive Safari bookmarks:

  • either read Safari's Bookmarks.plist file
  • or use the SyncServices API.

However, the first is forbidden by sandboxing (mandatory for a distribution through the App Store), and the second has been deprecated since Mac OS X 10.7 Lion.

I believe that Apple deprecated SyncServices in favour of iCloud synching, but I can't find any iCloud API that allow access to the bookmarks (1).

Any hint on where to look? Native Cocoa is preferred, but any non-deprecated, sandboxing-compatible solution is welcome.

Thanks.

(1) and, honestly, going through the internet (and thus requiring an internet connexion) to retrieve on a machine something on the same machine seems... awkward — but well, if it was the way to go at least that would be a possibility.

Paraldehyde answered 21/7, 2012 at 12:31 Comment(2)
What did you end up doing?Mailman
LOL! Probably what I'm gonna do too... :)Mailman
S
4

You can read out the bookmarks plist file even when running in a sandbox if you expressly ask the user for consent: Present an open panel pointing to the plist directory and store the security-scoped bookmark you receive from it. I did this and my app wasn't rejected for this (but for other things).

Scurvy answered 15/8, 2012 at 17:28 Comment(3)
Oh, that seems cool. So NSSearchPathForDirectoriesInDomains still works with sandboxing then?Paraldehyde
It will run, but return different paths if called from a sandboxed app. You'll have to manually separate the path components and put them together again to create the correct path if you want to access files outside the sandbox.Scurvy
Hmm, so it's still a kind of a hack that might be broken overnight by Apple. Better use deprecated APIs then, at least we get prior notice... Thanks for the input anyway.Paraldehyde

© 2022 - 2024 — McMap. All rights reserved.