Supercharging Your Xcode Efficiency
Boost your XCode efficiency and learn how to become a coding ninja by following this tutorial. By Jack Wu.
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Contents
Supercharging Your Xcode Efficiency
35 mins
Some Behavior Recommendations
There are two different sets of actions I recommend for the Generates output event, depending on your development environment. If you have a dual-screen environment, try the first one. If you work on a single screen, try jumping ahead to the second method below.
There are two different sets of actions I recommend for the Generates output event, depending on your development environment. If you have a dual-screen environment, try the first one. If you work on a single screen, try jumping ahead to the second method below.
If you work on two or more screens, wouldn’t it be handy to have the debug console in its own window on your second screen? Well, you can set up the actions so it looks like this:
Now build and run, and you’ll see a separate window appear. Position it on your secondary display, and just like that, you have yourself an efficient debugging setup!
If you have a single screen environment, maximize the effective area for the console by hiding the utilities pane and setting the console to take up the entire debug area. To do this, set up the actions like so:
Now run the app, and watch as Xcode automatically follows your commands!
You’ll also want to change the behavior to account for when the project pauses. Go to Pauses
event under Running, and change the settings like this:
Now whenever you hit a breakpoint, you’ll get a new tab named Fix that will display the variables and console views, and automatically navigate to the first issue. You should really think about demonstrating this next time you host a party, because it’s that cool.
Well, maybe not…unless your guests are burgeoning coders.
The last behavior you’ll create for now is the one of my personal favorites. This is a custom behavior that you can assign to a hotkey. When triggered, it transforms Xcode into what I refer to as Dev Mode, which is an optimized layout for developing your next masterpiece.
To do this, create a new event by pressing the + button near the bottom left of the behavior preferences window. Name this behavior Dev Mode.
Double-click the Command symbol (⌘) to the right of the event name, and then type Command . to define a hotkey.
Next, configure the behavior with the following actions:
Now whenever you press Command .
you’ll be greeted with the same, clean development interface.
This is the perfect time to introduce you to Xcode tab names, which work beautifully with behaviors.
Xcode Tab Names: You can rename an Xcode tab simply by double-clicking on its title. This is rather a useless feature by itself, but becomes extremely powerful when you pair it with behaviors.
In the second example above, when modifying the Pauses behavior, you named the tab Fix. This means that when the behavior is triggered, Xcode will use the Fix tab if it exists, or create a new tab if it’s not already there.
Another example is the dual-screen Starts behavior. If a tab named Debug is open from a previous run, it’ll re-use it instead of creating a new one.
You can create some very interesting behaviors by utilizing tab names in this manner.
Xcode Tab Names: You can rename an Xcode tab simply by double-clicking on its title. This is rather a useless feature by itself, but becomes extremely powerful when you pair it with behaviors.
In the second example above, when modifying the Pauses behavior, you named the tab Fix. This means that when the behavior is triggered, Xcode will use the Fix tab if it exists, or create a new tab if it’s not already there.
Another example is the dual-screen Starts behavior. If a tab named Debug is open from a previous run, it’ll re-use it instead of creating a new one.
You can create some very interesting behaviors by utilizing tab names in this manner.
Okay, take a few minutes to play around with behaviors. Don’t worry, this tutorial will wait for you. :]
Wait, are you back already? Okay, then it’s time for some action!
Coolness points gained:
400
Total Coolness points:
500
Ninja points gained:
50
Total Ninja points:
150
Test Your Skills
In the following sections, you’ll learn to put these tricks to a test, and learn some new ones while working on CardTilt.
Build and run CardTilt, and you should see a screen like this:
Not what you’re seeing? Looks like it’s time for some ninja-level bug squashing!
Locating the Bug
It appears as though the app is having trouble loading the data, and it’s your job to fix it. Open CTMainViewController.m and enter Dev Mode (Command .
).
Notice these first few lines in viewDidLoad
:
self.dataSource = [[CTTableViewDataSource alloc] init];
self.view.dataSource = self.dataSource;
self.view.delegate = self;
Looks like CTTableViewDataSource implements UITableViewDataSource
and provides the table with data. Time to use your Xcode skills to confirm this and get to the bottom of the issue.
Hold Command and click on CTTableViewDataSource to open CTTableViewDataSource.h
in your primary editor. CTTableViewDataSource.m
should’ve loaded in your assistant editor, as well. If that’s not the case, use the Jump Bar to change the assistant editor mode to counterparts like this:
Look around, and you’ll see members
holds the data, and loadData
loads it from the bundle. That looks like a great starting point for debugging. Switch CTTableViewDataSource.m
to the primary editor by right clicking anywhere inside the assistant editor, and then choosing Open in Primary Editor.
Below is an animation showing the steps you’ve taken thus far:
Ninja Dojo: For bonus ninja points, you can do all of the above without your mouse by following these steps:
Remember that being a ninja isn’t always the most efficient route, but you’ll always look cool.
Bonus Ninja Tip: Open Quickly (Command Shift O
) is one of the coolest Xcode ninja tools. Use it and love it.
- Press Command + Shift + O, typeCTMainViewController.m and then hit Enter to open the controller
- Enter Dev Mode (
Command .
). - Place your cursor on
CTTableViewDataSource
and press Command + Control + J to jump to the definition. - Change focus to the assistant editor by pressing Command + J, ->, then Enter.
- Bring down the jump bar tab by pressing Control + 4, then navigate to counterparts using arrows and Enter.
- Press Command + Alt , to open
CTTableViewDataSource.m
in the primary editor.
Remember that being a ninja isn’t always the most efficient route, but you’ll always look cool.
Bonus Ninja Tip: Open Quickly (Command Shift O
) is one of the coolest Xcode ninja tools. Use it and love it.
Ninja Dojo: For bonus ninja points, you can do all of the above without your mouse by following these steps:
- Press Command + Shift + O, typeCTMainViewController.m and then hit Enter to open the controller
- Enter Dev Mode (
Command .
). - Place your cursor on
CTTableViewDataSource
and press Command + Control + J to jump to the definition. - Change focus to the assistant editor by pressing Command + J, ->, then Enter.
- Bring down the jump bar tab by pressing Control + 4, then navigate to counterparts using arrows and Enter.
- Press Command + Alt , to open
CTTableViewDataSource.m
in the primary editor.
Remember that being a ninja isn’t always the most efficient route, but you’ll always look cool.
Bonus Ninja Tip: Open Quickly (Command Shift O
) is one of the coolest Xcode ninja tools. Use it and love it.
Coolness points gained:
100
Total Coolness points:
600
Ninja points gained:
100
Total Ninja points:
250