Some useful URL schemes in Xcode 9

Not many people know that Apple introduced some interesting automation capabilities in Xcode 9 via URL schemes. I sometimes use them, and as I didn’t see them publicized anywhere, I decided to document them in this blog post.

Source Code Navigation

The new Xcode source editor, written in Swift, has a neat way to link between documentation and source code locations inside a project. First of all, you need to put this comment on top of the target location where you want to go, for example, on top of a method:

/// - Tag: MyAwesomeMethod
func myAwesomeMethod(...) {

After that, create a Markdown link in a file placed inside the project (the typical README file is a good candidate for this):

[View in Source](x-source-tag://MyAwesomeMethod)

Using this technique, a person who reads your README file and clicks on “View in Source” will navigate directly to the implementation of your awesome method. You can even open this tag URL in your browser and it will bring Xcode to the foreground and navigate to that symbol!

You can see that Apple has been silently using this feature in their recent sample code:


This is more or less a well-known feature of Xcode 9 (as it was announced in WWDC 2017): You can automatically clone repositories from GitHub by clicking on “Open in Xcode” in a repository that contains an Xcode project or workspace:


This feature is also supported by a URL scheme:


This will launch Xcode, clone the given repository, and open its main project or workspace, all in one step.

Hopefully, Apple will support git branches in this URL scheme in a future version of Xcode. The perfect use case is opening a code review in your IDE, directly from GitHub.

Devices and Simulators Management

I happen to open the Devices and Simulators pane in Xcode quite frequently (accessible from Window, Devices and Simulators), typically to open crash logs. This is the URL scheme that I use to automate this step and manage my devices more quickly:


This URL scheme also accepts a parameter to automatically enable a particular device for development:


Quick Access to Preferences

If I need to open quickly a particular tab in Xcode preferences (say Key Bindings or Components), I also use a URL scheme:

xcpref://GeneralPrefs (General tab)
xcpref://AccountsPrefs (Accounts tab)
xcpref://AlertPrefs (Behaviors tab)
xcpref://KeyBindingsPrefs (Key Bindings tab)
xcpref://FontAndColorPrefs (Font and Colors tab)
xcpref://NavigationPrefs (Navigation tab)
xcpref://LocationsPrefs (Location tab)

And that’s it, I hope you like these tips and hopefully streamline your Xcode workflow a little bit. Enjoy!

This entry was posted in Xcode and tagged , . Bookmark the permalink.

3 Responses to Some useful URL schemes in Xcode 9

  1. Edward says:

    Interesting. I created this tool. Very helpful when getting into a new project and wanna link-up the steps the code makes to do stuff.


  2. Pingback: Xcode9でのMarkdownファイル

  3. Uli Kusterer says:

    Interesting. Anyone know whether x-source-tag URLs can also be made to work with ObjC? In my tests it didn’t work with either identical syntax, or HeaderDoc-style /*! @tag: Foobar */ :’-(


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s