Xcode Bookmarks

Xcode 15 added a new way to bookmark source code annotations and search queries.

Bookmarking Code

Xcode has long had support for TODO and other annotations in source code:

// TODO: Migrate to Observable
public final class Store: ObservableObject {
  // MARK: Published properties
  @Published public var items: [Int] = []

Xcode shows these annotations in the selection toolbar but I think I gave up using them when I stopped writing Objective-C.

Source editor selection jumpbar with TODO and Mark

Xcode 15 introduced a new way to bookmark and annotate source code. With a line of source code selected, the context menu (control-click or right-click in the source editor) has options to bookmark the line or the whole file:

Context menu with bookmark store.swift line 33 selected

Xcode shows the bookmarks in the third tab of the navigators sidebar. This replaces the old symbol navigator whose functionality Xcode now supports directly in the Find navigator. Clicking the bookmark takes you to the line of code in the source editor:

Bookmarks navigator showing bookmark for store line 33

The Xcode source editor adds a bookmark icon, clicking it lets you to add a description:

Adding a description to a bookmark

Xcode shows the description in the bookmark navigator:

Bookmark navigator showing updated bookmark description

Right-clicking on the bookmark in the navigator gives you options to edit, copy, and delete bookmarks.

Grouping Bookmarks

The Xcode bookmark navigator allows you to create groups to organise your bookmarks. For example, I’ve created a group for my TODO bookmarks:

Two bookmarks in TODO group

Note: Right-clicking on the group gives you options to sort the contents of the group by name, type, or completion status.

Marking Complete

You can mark any bookmark as complete. The bookmark navigator shows completed bookmarks with a tick:

Second bookmark with blue tickmark

Bookmarking Search Queries

Xcode also lets you bookmark search queries. For example, here’s a query to find all the places where I’ve added TODO annotations directly to the source code:

Search query for TODO

Right-clicking anywhere in the search results, I can bookmark the search. Xcode then shows that saved search in the bookmarks navigator where I can move it to my TODO group:

Find TODO search in bookmark navigator

I’m not sure why, but Xcode includes a couple of example queries for SwiftUI views and SwiftData models in the navigator menu buried down next to the filter:

Navigator menu

Note: The menu shows those two searches regardless of whether the project uses SwiftUI or SwiftData.

Clicking either option from the menu adds a saved search to the bookmark navigator to find any SwiftUI views or SwiftData models:

Bookmark navigator with SwiftData Model and SwiftUI Views searches

I’m finding bookmarks to be an improvement over directly annotation source code. Let me know how you’re using them.

Learn More