Mastering macOS Programming
上QQ阅读APP看书,第一时间看更新

Behaviors

There's one little corner of Xcode that has huge potential to make your work with it significantly faster, smoother, and presumably more satisfying: Xcode Behaviors.

To get there, complete the following steps:

  1. Open up Xcode's Preferences window with command + ,(that is to say, command + comma).
  2. Select the Behaviors tab.

This is where you get to tell Xcode how you want things to be when it builds, tests, runs, searches, or engages in several other activities.

As an example, we're going to get Xcode to use a separate window for debug logging (it will create one if it doesn't exist yet), which will keep the code editor window that we are working in free of debug-clutter. The following screenshot shows the settings needed to make our new, non-disruptive, debug window:


This is especially useful when you are working with more than one monitor, or if you have a crazy-big screen with a corner free for a console.

You're not limited to setting Xcode's behavior while running the processes listed; you can also add custom behaviors which are triggered by keyboard shortcuts.

Have you ever wanted a button that made everything except your code just go away? The navigators, debugger, Utilities panes, all of it? Well this is where you can do just that:

  1. Click on the little button to the right of your custom behavior name, and enter the key combination that will be the shortcut.
  2. Give the new behavior a name more descriptive than New Behavior. I used Big Reset, but whatever floats your boat is good. There is now a new Custom category in the behaviors list, with your new behavior in it.
  3. At the bottom of the behaviors list on the left of the Behaviors tab, click the + button.
You might find it quite difficult to find one that doesn't clash with something else I use command + Option + ' (single quote), since it was free and is easy to type with one hand.
  1. Set the following values:

Given that these behaviors can launch scripts, you might like to use this as a method of running scripts via keyboard shortcuts.