Hidden Features of Xcode 4
Solution 1
If you like your code to look as good as it runs, you've undoubtedly used #pragma mark -
and #pragma mark <name>
to provide a nice visual grouping in the Xcode class dropdown list. Xcode 4 now combines these into a single #pragma mark - <name>
.
Solution 2
shift-cmd-opt click on a symbol lets you tell Xcode exactly where in the UI you want the navigated-to file to open.
cmd-ret makes the version editor / assistant (the right hand pane) go away
shift-cmd-Y to hide the debugger
cmd-0 to hide the navigator (left pane)
cmd-[1..n] switch between navigators on left
cmd-opt-[1..n] switch between utilities (thing generally on right)
ctrl-[1..n] switch between various related files in the editor
Overall, Xcode 4 tries to keep things consistent w/the hot keys. Cmd is for mainline commands. Adding modifiers is for analogous commands focused on one particular sub-feature.
(These are just the four that come to mind as the my most pounded upon shortcuts that I'm using constantly! I'm sure it'll change over time as my workflow is refactored into the new hotness.)
Solution 3
Xcode 4 adds a new "Code Snippets" feature, accessible via View > Utilities > Code Snippet Library. To add a new code snippet, select some text in the editor view and drag it into the snippet library. You can either drag a snippet out and drop it in your code to use it, or, much more conveniently, assign a completion shortcut to it.
When you type in that series of letters, it will automatically show up in the code completion pop-up menu as you type your code. For example, among many others, I have a snippet set up so that typing "svk" will expand to setValue:<#value#> forKey:<#key#>
. This can save a lot of typing and/or fishing around in the autocompletion menu for the methods and other code expressions you use the most. Xcode ships with a bunch of built-in snippets that come in very handy as well.
Solution 4
New shortcut I use most often: triple-finger swipe (up or down) to swap counterparts (between the interface and implementation files). No more hand acrobatics!
Thanks to https://twitter.com/xctotd/status/48148271759241216
Solution 5
Tabs in Xcode 4 are awesome. Each one maintains its own separate layout, so you can have multiple tabs with different things in them and have each one lain out appropriately.
I've been setting up my projects with three layouts—one for the project object, one for each nib (showing the owner's class's sources), and one for each class.
There is one bug here: As of 4.0, Xcode will reset the state (turning off any Assistants) of the active tab when you reopen the project. The workaround is to switch to a tab with no Assistants for Xcode to close before you close the project. I have filed this as Radar number 9178441.
Related videos on Youtube
Comments
-
schwa almost 2 years
Now that Xcode 4 is officially released it's time for a follow up to my previous question: Hidden Features of Xcode
So what are they? What are those hidden little Xcode 4 hints & tips that you can't live without?
Please limit your tips to those that are new and specific to Xcode 4!
-
Brad Larson about 13 yearsAlso, that you can assign custom names to the tabs, which was something I didn't know until Scott Stevenson mentioned it: twitter.com/scottstevenson/status/50270610038865921
-
cocoapriest about 13 yearsYep, You can double-click tabs in Xcode 4 to rename them, then use named tabs in Prefs > Behaviors (via @scottstevenson)
-
Danilo Campos about 13 yearsOh, this is very handy. So I can set up a debugger/console tab showing only those, then have that show up during a run. This is much nicer than having it popping up and down all the time.
-
Nikolai Ruhe about 13 yearsWhat's new here? You could always link groups to directories (Xcode 3: Command-I on the group)
-
Dan Rosenstark about 13 years@Dave DeLong, how can you do this on the keyboard? I was doing option-command-up to get from interface to implementation in XCode 3. This no longer works in 4. What's the new way?
-
Dave DeLong about 13 years@yar control-cmd-up/down arrow
-
Dan Rosenstark about 13 yearsThanks as always, @Dave DeLong.
-
Sagar Kothari almost 13 yearsDELETE is Horrible. I can't get it back from TRASH :(
-
Todd Hopkinson almost 13 yearsthese are not hidden features
-
Sagar Kothari almost 13 years@icnivad - many hidden features are accessible using shortcuts, like jumping files, tab switching etc.
-
DonnaLea over 12 yearsIs this still the case in Lion? Cos in lion a 3 finger vertical swipe on the trackpad activates Mission Control. I'm assuming we're talking about trackpad swiping and not the magic mouse.
-
wdn over 12 yearsDoesn't seem like there's a simple solution currently, even if you switch Mission Control to a 4-finger swipe. See this thread: stackoverflow.com/questions/6771057/…
-
mxcl over 12 years@wdn It’s four fingers in Lion.
-
Imron about 12 yearsBrilliant! This has been bugging me for ages.