Xcode Behaviours
Here is another blog post, I am re-publishing, originally written for my company blog on 3rd January 2018.
When I attended WWDC in 2012, I visited session 402 titled Working Efficiently with Xcode. In this session, the engineers explained about setting up behaviours in Xcode to optimise your workflow. I used what I learnt then to configure my Xcode environment for increased productivity, which I still use to this day!
Behaviours
My idea when setting this up is to have a tab for each of the tasks I find myself performing most frequently, namely:
- Editing code
- Running projects and looking for console output, called Console
- Debugging a problem, called Debug
- Searching the codebase
With that in mind, by the end of this article, you will have a separate tab named the same as each highlighted word above. Not only that, but Xcode will:
- Switch to Console tab, which is configured to maximise visibility for console output, when you run your project
- Switch to the Debug tab, which is configured for debugging if a breakpoint is reached
- At any point you can hit Option + Cmd + E to switch to the Editing tab to continue, well, editing your code
- When you need to perform a search hit Option + Cmd + S to switch to the Search tab to search the project. Alas, the cursor is not placed in the search text field! If you know a trick for this, please get in touch 🙃
- After you stop running the project, automatically switch to the Editing tab, so you can continue editing
Process
- Launch Xcode
- Open Preferences by navigating to
Xcode → Preferences
or hittingCmd + ,
- Navigate to the
Behaviors
section
Console
On the left-hand side choose Running → Starts
and:
- Enable
Show tab named
, enter “Console” then inactive window
- Enable
Hide
navigator - Enable
Show
debugger withConsole View
- Enable
Hide
utilities
When you have finished your behaviour should look like:
Debug
On the left-hand side choose Running → Pauses
and:
- Enable
Show tab named
, enter “Debug” then inactive window
- Enable
Show
navigator calledDebug navigator
- Enable
Show
debugger withVariables & Console View
- Enable
Hide
utilities
When you have finished your behaviour should look like:
Editing
This behaviour has two parts, firstly on the left-hand side chose Running → Completes
and:
- Enable
Show tab named
, enter “Editing” then inactive window
- Disable all other options
When you have finished your behaviour should look like:
Next up tap the +
button in the bottom right of the pane, and:
- Enter the name of “Editing”
- At the right-hand side, enter the shortcut
Opt + Cmd + E
- Configure the same behaviours as we did for
Running → Completes
, which will leave you with:
Searching
Tap the +
button in the bottom right of the pane, and:
- Enter the name of “Searching”
- At the right-hand side, enter the shortcut
Opt + Cmd + S
- In your new behaviour, you can now:
- Enable
Show tab named
, enter “Search” then inactive window
- Enable
Show
navigator calledFind navigator
- Enable
Hide
debugger - Enable
Hide
utilities
- Enable
When you have finished your behaviour should look like:
Misc
- Select
Build → Generates new issues
and disable all options. This will remove the checkmark to the left. - Navigate to both
Generates output
s and again disable all the options.
Other Personal Preferences
Each of these preferences can be found under the relevant pane with the given subheading.
General
- Enable
Continue building after errors
will mean Xcode shows more errors than the first it encounters. I have found this useful during Swift source migrations.
Fonts & Colours
- I find the
Dusk
theme to be the best balance between readability for long periods and usefulness.
Text Editing
- Enable
Line
numbers, no explanation needed and a no-brainer in my opinion!
Conclusion
I hope this leaves you with a better understanding of how my Xcode behaviours are configured and some ideas on how you may modify yours. I really wish that there was a supported method of exporting/importing. If I’ve missed it, please get in contact and let me know 😀