Give your simulator superpowers

RocketSim: An Essential Developer Tool
as recommended by Apple

Xcode Bookmarks: Save code landmarks & organize tasks

Xcode Bookmarks were introduced during WWDC 2023 as part of the significant Xcode 15 release. They are a new feature that allows you to save quick links to code you want to revisit. Doing so allows you to save code landmarks and organize tasks you have to fulfill.

You can add new bookmarks from several places, and there are multiple scenarios to create bookmarks for. I’ll take you through this feature and explain how you can benefit from making personal references.

Exploring the bookmark navigator

The Xcode Bookmark Navigator is on the left-hand side inside the inspector tab view. It will be empty at first, but you can add bookmarks for search queries, files, and lines of code:

The Xcode Bookmark navigator allows you to create code landmarks.
The Xcode Bookmark navigator allows you to create code landmarks.

You can add, delete, copy, and duplicate bookmarks from within this list. I recommend exploring all options by right-clicking one of your landmarks, but I’ll at least highlight a few practical actions.

Creating a custom landmark description

A new purple line highlighter appears at the code line for a bookmark which you can click to enter a custom description for the line of code:

You can add a custom description to a bookmark that references a line of code.
You can add a custom description to a bookmark that references a line of code.

You could do the same from within the bookmark navigator list of items.

Interested to learn more about these Macros? Check out Swift Macros: Extend Swift with New Kinds of Expressions.

Grouping landmarks together

If you work on larger projects, it can be helpful to group bookmarks together. In this case, I decided to create a new group for all Macro related bookmarks:

Create groups of bookmarks in case you'll have many different ones.
Create groups of bookmarks in case you’ll have many different ones.

Stay updated with the latest in Swift & SwiftUI

Join 20,020 Swift developers in our exclusive newsletter for the latest insights, tips, and updates. Don't miss out – join today!

You can always unsubscribe, no hard feelings.

Ways of adding new bookmarks

After exploring the navigator, it’s time for us to explore the different ways of adding new landmarks. You’ll find the “add new bookmark” action in all cases by right-clicking a target. For example, here I’m right-clicking the struct definition:

The right-click context menu allows you to create new bookmarks.
The right-click context menu allows you to create new bookmarks.

In the above example, we can add a landmark for the specific line and the entire file. Depending on what you need, you can pick the one that fits best.

You can also use Quick Actions to add a new bookmark. Start by tapping Shift ⇧ + Command ⌘ + A and type “Bookmark”:

Using Quick Actions, you can add references using your keyboard.
Using Quick Actions, you can add references using your keyboard.

Quick actions are powerful and enable you to increase your productivity.

Bookmarking search queries

Apart from code and file references, you can also save search queries. Doing so can be helpful for search queries you often perform or when you’re refactoring code. I’ve used search queries to list all my todos and types conforming to Macro. The first is a regular search query, but the latter uses the “Conforming Types” category.

After performing your search, you can right-click one of the results to store the query as an Xcode bookmark:

You can bookmark search queries for later reuse.
You can bookmark search queries for later reuse.

Refreshing stored search queries

It’s important to understand bookmarks for search queries don’t automatically refresh. To get the latest results for a query, you’ll have to tap the refresh button:

Bookmarks for search queries have to be refreshed manually.
Bookmarks for search queries have to be refreshed manually.

Using Xcode bookmarks as a todo list

Another great way of using Xcode bookmarks is to manage your list of todos. In my case, I defined a list of tests I still have to write:

You can use code references to manage a list of todos.
You can use code references to manage a list of todos.

As you can see, I’ve already marked one of the files as done, and I only have to write tests for the AddCompletionHandlerMacro. When hovering over the specific list item, a checkbox appears in front of any of the files and code referencing bookmarks.

Conclusion

Xcode Bookmarks are a powerful new feature that allows you to create quick access to essential code references or search queries. You can group landmarks, update descriptions, or use them as to-do lists. By using Quick Actions, you can add new bookmarks by only using your keyboard.

If you like to improve your Xcode knowledge, even more, check out the Xcode category page. Feel free to contact me or tweet me on Twitter if you have any additional tips or feedback.

Thanks!

 
Antoine van der Lee

Written by

Antoine van der Lee

iOS Developer since 2010, former Staff iOS Engineer at WeTransfer and currently full-time Indie Developer & Founder at SwiftLee. Writing a new blog post every week related to Swift, iOS and Xcode. Regular speaker and workshop host.

Are you ready to

Turn your side projects into independence?

Learn my proven steps to transform your passion into profit.