With a huge influx of newbies to Xcode, I'm sure there are lots of Xcode tips and tricks to be shared.
What are yours?
338
1047
|
With a huge influx of newbies to Xcode, I'm sure there are lots of Xcode tips and tricks to be shared. What are yours? | |||
This question exists because it has historical significance, but it is not considered a good, on-topic question for this site, so please do not use it as evidence that you can ask similar questions here. This question and its answers are frozen and cannot be changed. More info: Help center.
343
|
Switch to Header/Source File
Switches between the
| ||||||||||||||||||||
|
158
|
⌘ Command + ⌥ Option + Favorites Bar:Favorites bar is just like you have in Safari for storing - well - favorites. I often use it as a place to store shortcuts (which you can do by drag-dropping) to files I am using right now. Generally this is more useful when I'm working with a large or unfamiliar project. To show the Favorites Bar, select the following menu option:
| ||||||||
|
127
|
Auto-completion Keyboard ShortcutsTab ⇥ OR Control ⌃ /: Select the next auto-completion argument. Shift ⇧ Tab ⇥ OR Shift ⇧ Control ⌃ /: Select the previous auto-completion argument. Escape ⎋: Shows the auto completion pop-up list. | ||||
|
119
|
Turn off the "undo past the last point" warningWhen you attempt to undo after saving, you will get the following prompt:
To get rid of this warning, enter the following into a terminal window:
Change the company name in template filesPaste this into the Terminal application:
Change "
|
|
Control-Command-double-click is just necessary because Xcode uses Command-double-click for something else other than a discontiguous word selection. In most Cocoa apps you can do discontiguous selection with the Command modifier alone. –
Nicholas Riley
Nov 1 '09 at 1:26
| ||
|
99
|
Open Quickly...
I'm a big fan of the Open Quickly feature, which is particularly good in Xcode 3.1 and later. When you want to open a file or a symbol definition that's in your project or in a framework, just hit the keyboard shortcut, type a bit of the file or symbol's name, use Up Arrow ↑ and Down Arrow ↓ to pick to the right result (if need be), and then hit Return ↩ to open the file or navigate to the symbol definition. On Xcode 4:
Open Quickly uses the current word as a search termAlso, something I didn't know about Xcode until two minutes ago (when schwa pointed it out in a comment) is that, if the editor's text caret is inside of a word when Open Quickly is invoked, that word will be used as the Open Quickly search term. | ||||||||||||||||
|
79
|
Use #pragma for organizationYou can use:
... as a way to organize methods in your source files. When browsing symbols via the pop up menu, whatever you place in To display a separator (i.e. horizontal line), use:
It's very useful, especially for grouping together delegate methods or other groups of methods. | ||||||||||||
|
77
|
1. Breakpoint on "objc_exception_throw" You should always have a breakpoint on 2. Debugging retain/release problems with "Zombie" variablesUse the following code:
... to debug retain and release problems. For more information, see the "Finding Memory Leaks" section of Apple's Debugging Applications document. 3. Jumping to a class in Xcode from Interface Builder Command ⌘ + 4. Reusing customized objects in Interface BuilderDrag a customized object back to Interface Builder's Library for later reuse. 5. Select overlapping items in Interface Builder Control ⌃ Shift ⇧ + 6. Interface Builder Gesture Guide | ||||
|
75
|
Ctrl + 2: Access the popup list of methods and symbols in the current file. This is super useful because with this shortcut you can navigate through a file entirely using the keyboard. When you get to the list, start typing characters and the list will type-select to the symbol you are looking for. | ||||||||||||||||||||
|
74
|
Zoom Editor InIf your window displays both the detail and editor view, you can zoom the editor in to expand the editor view to the full height of the window. (This is fairly easily found, but many seem to overlook it.) You can do this by using one of the following methods:
| ||||
|
67
|
Get Colin Wheeler's Complete Xcode Keyboard Shortcut List (available as PDF or PNG). Print it and keep it somewhere visible (I've got it on the wall next to my screen). edit: Updated versions for Xcode 3.2 edit 2: Updated versions for Xcode 4 | |||
52
|
Not much of a keyboard shortcut but the TODO comments in the source show up in the method/function dropdown at the top of the editor. So for example:
shows up in the drop down list of methods and functions so you can jump to it directly. Most Java IDEs show a marker for these task tags in the scrollbar, which is nicer, but this also works. | ||||||||||||||||||||
|
51
|
⌘-[ and ⌘-] to indent and unindent selected text. Makes cleaning up source code much easier. | ||||
|
43
|
Hold Option while splitting windows to split vertically rather than horizontally. | ||||||||
|
42
|
Double-click on the square brackets or parentheses to obtain bracket and parentheses matching. | |||
show 1 more comment |
36
|
Control Xcode's text editor from the command line: xed
| |||
show 2 more comments |
31
|
"Ctrl+Left/Right Arrow" to do intra-word text navigation. I use this feature to jump the cursor from the one "camel hump" in a variable to the next. | ||||||||
|
30
|
Xcode supports text macros that can be invoked via the Insert Text Macro menu at the end of the Editmenu. They can also be invoked using Code Sense, Xcode's code completion technology. For example, Typing the key sequence | |||
show 1 more comment |
30
|
Right click on a variable in your function and click edit all in scope. Been using it a lot since I found this out. ctrl ⌘ T | ||||||||
|
28
|
You can have Xcode run the preprocessor over your Info.plist file: <key>CFBundleShortVersionString</key> #ifdef DEBUG <string>1.0 (debug)</string> #else <string>1.0</string> #endif See http://developer.apple.com/technotes/tn2007/tn2175.html for details. | ||||
|
27
|
Debugging - how to use GDB Being new to this still, I find trapping and identifying faults a rather daunting job. The console, despite it being a powerful tool, usually does not yield very intuitive results and knowing what you are looking at in the debugger can be equally difficult to understand. With the help of some of they guys on Stack Overflow and the good article about debugging that can be found at Cocoa With Love it becomes a little more friendly. | ||||
|
26
|
Navigate among open files back and forth: | ||||||||||||||||
|
25
|
Technically an Interface Builder tip, but they're a book-matched pair, so I don't think this is off topic... Shift + Right Click on one of your controls and you get a nice pick list of the object hierarchy. No more click, click, click, frustration! | |||
22
|
With Trackpad:
Tested with Xcode 3.2.5. | |||
21
|
The class browser in Xcode! Reached by pressing shift + ⌘ + c. You can reduce the scope to only show your active project. It gives you a less cluttered view as long as you only want to browse the class hierarchy. | |||
show 4 more comments |
19
|
Using ] to automatically insert
|
|
17
|
Select a block of text and type cmd-/ to comment it out. Do it again to remove the comments characters. This is especially useful when combined with brace-matching by double-clicking on balanced chars (parens, braces, brackets). | |||
show 1 more comment |
16
|
Being able to quickly see all the methods that can be overriden from a super class. For example when extending UITableViewController I just type in my implementation:
and then I hit ESC to see all the methods from my superclass that begin with "ta" such as
This also works when adopting protocols. | |||
14
|
Command ⌘ alt ⌥ shift T : reveal the current edited file in the project tree. | |||
show 2 more comments |
14
|
ctrl + alt + ⌘ + r to clear the log | ||||||||
|
13
|
Use the Class Browser to show inherited methodsApple's API reference documentation does not show methods inherited from a superclass. Sometimes, though. it's useful to be able to see the full range of functionality available for a class -- including a custom class of your own. You can use the Class Browser (from the Project menu) to display a flat or hierarchical list of all the classes related to a current project. The upper pane on the right hand side of the browser window shows a list of methods associated with the object selected in the browser. You can use the Configure Options sheet to select "Show Inherited Members" to show inherited methods as well as those defined by the selected class itself. You click the small book symbol to go to the corresponding documentation. |