7

Where are Xcode bookmarks stored?

 1 year ago
source link: https://www.jessesquires.com/blog/2023/07/11/where-are-xcode-bookmarks-stored/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Where are Xcode bookmarks stored?

11 July 2023

Xcode 15 introduces a new “bookmarks” feature, which lets you bookmark lines or entire files. It is a welcome change that has sherlocked my hack for using breakpoints as bookmarks.

However, one advantage of breakpoints is that they can be shared. This is useful for symbolic breakpoints that can be shared across projects. But it could also be useful for teams to share breakpoints within a project. As I was updating my old post, I was wondering if the same was possible for bookmarks. The question then is, how and where does Xcode save them?

Bookmarks are stored in a plist at the following path:

PROJECT_NAME.xcodeproj/project.xcworkspace/xcuserdata/USER.xcuserdatad/Bookmarks/bookmarks.plist

where PROJECT_NAME is the name of your project and USER is the current user – that is, the output of $USER or whoami.

Typically, xcuserdata/ is added to .gitignore so you likely would not notice any changes to this directory. Importantly, bookmarks are user-specific and there is a unique .xcuserdatad/ directory for each user. So if multiple users create bookmarks, you would have something like the following:

MyApp.xcodeproj/project.xcworkspace/xcuserdata/jsq.xcuserdatad/Bookmarks/bookmarks.plist
MyApp.xcodeproj/project.xcworkspace/xcuserdata/gregheo.xcuserdatad/Bookmarks/bookmarks.plist

Furthermore, Xcode filters bookmarks in the UI based on the current $USER. This means if you do check-in xcuserdata/ and bookmarks.plist for each user, Xcode will only display your bookmarks in the Bookmarks Navigator panel.

I think this is a reasonable design choice. However, I can imagine scenarios where it would be useful to share bookmarks with your team, similar to breakpoints. For example, if you are trying to debug a problem with your remote team member and you’ve tracked down the issue to a few specific files and lines, you could bookmark those locations, push your branch, and have the other person checkout that branch. That’s a nicer, more precise experience than listing a bunch of filenames and line numbers in a Slack message that will eventually get lost. Another example would be for an interview exercise or a coding tutorial. You could prepare an Xcode project with bookmarks to guide someone through an exercise.

For now, this is not possible in Xcode’s UI, but you could easily write a script to move a pre-populated bookmarks.plist file to the correct location, based on the current $USER.

While I’m here, there is one other usability issue with bookmarks. You have to right-click in a file to bring up the contextual menu to create one. It’s a bit cumbersome. There are keyboard shortcuts, but it would also be nice if you could create bookmarks by clicking in the line number gutter — similar to how you create breakpoints.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK