49

As most of you have probably seen, Xcode 4 has been released officially today. Now I know that plenty of devs out there have been using the preview versions, and it'd be great if people could post any great tips, tricks, or keyboard shortcuts they've learned using those version now they're no longer under NDA. This could be especially useful for those upgrading from Xcode 3 (like me, downloading right now).

Note: Apple have released a 'transition guide' that has plenty of stuff in about getting from version 3 to version 4, but I bet there are loads of great tricks people out there have learned that aren't in there.

Ben Clayton
  • 80,996
  • 26
  • 120
  • 129
  • i would also like to see some trips and tricks from preview test users! – james Mar 10 '11 at 14:18
  • Well, I do like the single window interface with multiple tabs, kinda serves my work flow. But I've also seen way too many crashes (used betas and both GMs) and the Interface Builder plugin... could use a little improvement. All-in-all, it's a lot less intuitive now, IMHO. But until the crashing is resolved I'm back to Xcode 3. – DarkDust Mar 10 '11 at 14:20
  • 1
    @DarkDust *Less* intuitive than Xcode 3! Oh dear, that doesn't bode well at all. – Ben Clayton Mar 10 '11 at 14:22
  • Adding my two pennies worth I've just downloaded the release version and installed it. I liked the UI in xcode 4 during the beta but it crashed far too often, which is fine for a beta. Let's see how we go. If I find anything natty aside from the new Git support I'll add it. I do like the inbuilt IB though. – Diziet Mar 10 '11 at 14:25
  • 1
    @Ben Clayton: I have to agree with DarkDust. You can test it yourself with a larger project (just a hello world project runs acceptable, but as larger the project becomes the more horrible gets Xcode 4). I would suggest to wait for the next dot update, its not worth the 4Gb download. Oh and btw, Community Wiki much? – JustSid Mar 10 '11 at 14:28
  • My first 'handy tip'. Use CMD-1 (or 2, or 3) to switch between Project Navigator, Symbol Navigator, etc views. – Ben Clayton Mar 10 '11 at 16:37
  • Actually it is a separate question: this question would be of great value to a newcomer. That question would not. but thanks for the link! it is actually the question I wanted answered! – P i Mar 11 '11 at 12:27
  • Agree with @JustSid, seeing as [this similar question](http://stackoverflow.com/questions/5270265/short-and-useful-objective-c-snippets) was CW'd. I've flagged this accordingly. – BoltClock Mar 11 '11 at 12:32
  • Another possible duplicate: http://stackoverflow.com/questions/5256013/tips-for-using-xcode-4 – Paul R Mar 11 '11 at 12:53
  • 1
    XC4 is great! install it ALONGSIDE XC3.x, watch http://pragmaticstudio.com/screencast-tags/xcode4, use it, and you will love it after a day! – P i Mar 15 '11 at 18:02
  • 2
    It is unfortunate that comments can be promoted but not downvoted eg if five people like a comment, it will score five, even if 95 people are diametrically opposed. – P i Mar 15 '11 at 18:03
  • Updated PDF link: http://developer.apple.com/library/mac/documentation/IDEs/Conceptual/Xcode4TransitionGuide/Xcode4TransitionGuide.pdf – Jeevan Takhar Oct 08 '11 at 15:01

12 Answers12

20

I liked reading this Blog: Pilky.me - Xcode 4: the super mega awesome review.

It presents a good comparison, I especially liked his conclusion near the end.

VoodooChild
  • 9,776
  • 8
  • 66
  • 99
  • @Joe Blow: "There are very few areas where Xcode 4 is worse than previous versions. The majority of those areas are where the features simply aren't there, but where they may re-appear in future versions. In every other area it offers major leaps forward in usability, performance and enjoyment." - it clearly doesn't say that XCode4 is buggy, the blogger just points out the differences for people who are already used to the previous version. – VoodooChild Mar 23 '11 at 18:10
15

Currently I have only one tip for Xcode 3 users - don't use xcode 4 unless you have free time to start learning again and/or are willing to report lots of bugs. Wait at least until 4.1. There are still lots of bugs unresolved. Nothing is stable. Also Xcode 4 advertises as having single window ui which is nice, but is unstable as U238. Also - it's probably single thing that is good about new Xcode 4. So here are some of my headaches currently:

  • There is no possibility to commit whole project (except for separately selected modified files);
  • There is no possibility to push (if SMC is git). At least I haven't found that;
  • Since symbol indexing is broken you cannot:
    • see normal syntax highlight;
    • jump to certain symbol definitions;

Jump bar is just one big misunderstanding:

  • Previously comfortable Ctrl+2 shortcut from Xcode 3 which lists method names and pragma marks has now become finger breaking Ctrl+6 (emacs user's rejoice</flamewar>).
  • There is no direct button to switch between interface and implementation files.

If you have 13.3" macbook[pro] - don't even try to use navigators with utilities (inspectors or libraries).

Also transition guide is made for working Xcode 4 which it is far from.

Update 1:

There is no such thing as "Build & Run". Only build, build for running, build for testing, build for profiling, build for archiving. Then just run without building and run without profiling. AFAIK it supposed to be easier so summa summarum - 8 actions instead of 1. Go figure.

So these are only few of my instantly found glitches for Xcode 4.

P.S. probably will be updating this in upcoming few days.

Eimantas
  • 48,927
  • 17
  • 132
  • 168
  • 5
    Your forgot to rant about the debugger that even has to share its very very small frame with the console. – JustSid Mar 10 '11 at 14:31
  • 6
    The missing Command+Shift+Up for switching between header and implementation files also annoyed me a lot. – DarkDust Mar 10 '11 at 14:32
  • 10
    DarkDust - Cmd+Alt+Up went to Ctrl+Cmd+Up .) yes, that was really annoying too! – Eimantas Mar 10 '11 at 14:33
  • 1
    JustSid - my patience didn't reach that far as to launching the app ,) – Eimantas Mar 10 '11 at 14:34
  • I've switched between Xcode 3 and Xcode 4 three times so far, and then gave up on xcode4 because of all the BUGS!!! – Linuxmint Mar 10 '11 at 16:14
  • 11
    "Build and Run" is still present. It's called "Run". Cmd-R will do it, just like it did in Xcode 3. As for "git push", try File -> Source Control -> Push... – BJ Homer Mar 10 '11 at 19:29
  • @Linuxmint: https://bugreport.apple.com/ – Peter Hosey Mar 10 '11 at 20:14
  • "There is no possibility to commit whole project". That bugged me too, until I got into the habit of doing a Select All in the Project Navigator. I do very much like the ability to see the changed before committing and being able to deselect files or even discard changes. Only that commit message window is really awkwardly placed -- even after weeks of using Xcode 4 I still overlook it. – Elise van Looij Apr 28 '11 at 20:19
  • "There is no possibility to commit whole project" - yes there is. I'm using 4.0.2 with Subversion and selecting File > Source Control > Commit... displays a commit dialog with changed files from the entire project. – Tomas Andrle Jun 08 '11 at 20:47
  • Ctrl+Cmd+Up, sometimes work, sometime not. I am really angry with it. I used that so much. – karim Jun 09 '11 at 11:54
6

XCode 4 has a lot of awesome new features. I'd recommend starting to adjust to it by watching last year's WWDC2010 videos - they dedicated a lot of time to going through some of the new stuff.

  • I love the new assistant mode - it makes it really easy to navigate through your interface/implementation files. This mode also allows you to create your user interfaces alongside your controller classes, which makes development both easier and more effective than doing it in two completely separate programs!

  • The jump bar (found along the top of your source code) is a really fast way to leap about your project, making it really easy to get exactly to the place in your code that you're interested in.

  • The version control viewer makes it really easy to track changes. I now use SVN for all my projects, even the ones I work on alone because it really makes it clear to see how the project has evolved over time.

  • There are settings to set how your layout changes and what's displayed when you build, when you run, when you end a run etc. etc. which I'm also finding really useful because you want to see different things when you'e debugging to when you're back in your code. It's really nice that Xcode helps you easily arrange your layout to exactly how you want for different scenarios.

  • The code templates (which can be found in the toggleable right-hand-side toolbar) are also really useful, and you can create your own in order to quickly get code you often write down.

Some more subtle things that I've grown to like:

  • The 'Fix It' feature works really well for quickly replacing typos. I find I don't even have to read the correction Fix It will make because the fix is so natural.

  • Control-I short cut for re-indenting code. This is really useful if you add a new pair of braces round your code and you want to quickly reformat. I don't think there was a nice shortcut for this in Xcode 3.

  • Hitting the escape key to bring up autocomplete suggestions seems to bring up much more helpful suggestions in C++, and looks a lot more beautiful all round!

On reliability, I've been using a combination of Xcode 4 and Xcode 3 since Xcode 4 first entered beta. Whenever Xcode 4 packed in for me or wouldn't let me continue with what I wanted to do then I'd just switch over to Xcode 3 as the two are completely compatible. What I got was a really nice transition period and now I'm completly using the latest build (first week of March) so I think it's very stable.

For people that don't like change, this update is going to be hard. It'll be particularly challenging as a lot of the keyboard shortcuts have changed to make new for a lot of new features. The most obvious difference that people are going to oppose is the new all-in-one window layout. I'm sure people will get used to it over time and realize that this way of viewing everything to do with your project is much more effective both in real estate and in navigation terms.

Enjoy using Xcode 4, it really is an amazing improvement over the last version, and it continues to add to the awesome time I'm having writing Mac and iOS applications. :D

James Bedford
  • 28,702
  • 8
  • 57
  • 64
  • Version control didn't seem to work for me in xcode 4, at least with Unfuddle (a usually excellent SVN/Git/Ticketing service we use). The connection just times out. – Ben Clayton Mar 10 '11 at 16:40
6

@Ohmu: The 3-finger up/down trackpad/magic mouse swipe gesture for switching between header (.h) and implementation (.m) files still works a treat.

Robert
  • 1
  • 2
5

More shortcuts than you can shake a stick at here: http://cocoasamurai.blogspot.com/2011/03/xcode-4-keyboard-shortcuts-now.html

However, completeness is obscuring clarity. For example, I can't straightaway see the shortcut for toggling between a header file and its associated method file. so I recommend one shortcut per answer, and the votes will filter out the best ones.

P i
  • 29,020
  • 36
  • 159
  • 267
3

If you need to open plist files when you are not coding you should keep a copy of XCode3/Applications/Utilities/Property List Editor.

Property List Editor opens within the blink of an eye. But XCode4 takes minutes until it finally shows the plist file.

I guess Apple wants me to replace my 2008 MBPro

Matthias Bauch
  • 89,811
  • 20
  • 225
  • 247
  • 2
    I'm rapidly getting the impression that it's essential to keep the whole of xcode3 installed too, so I can use that instead if xcode 4 drives me crazy ;-) – Ben Clayton Mar 10 '11 at 14:50
3

NB: Apple's official transition guide has moved/been updated (they didn't update the URL, sigh). It's now at:

http://developer.apple.com/library/mac/documentation/IDEs/Conceptual/Xcode4TransitionGuide/Xcode4TransitionGuide.pdf

Adam
  • 32,900
  • 16
  • 126
  • 153
3

The only way for me to like XCode4 is thinking it as a different product. There's NO evolution over XCode3, just lots of drawbacks for the way I use it.

  1. Who changes (almost all) shortcuts between version of the same software?
  2. Why do I have to learn back from zero how to use and configure my projects? Sounds like punishment, not evolution.
  3. How good is XCode4 for multiple monitors usage? It was clearly designed for a single monitor user, but unlike Xcode3, its UI cannot be as easily (and persistently) changed.
  4. Although it can be disabled (and must), auto code check for errors... So we're back on VB6 now?

I'm a BIG Apple fan, though XCode4 falls short on developer satisfaction due to its lack of customization (compared to XCode3).

Not using XCode3 as a comparison, it is indeed a good IDE.

A frustrated developer, Cheers.

colnaghi
  • 481
  • 5
  • 9
2

Risky business: Moving to Xcode 4 will introduce you to a whole new level of strange behaviour, bugs, and pain. E.g. having third-party frameworks (like Three20) in your app, means that you won't be able to build a proper archive, without jumping through various levels of hoops. Don't move to Xcode 4 yet, if you can. If you do, there are some tips below.

Keep your archives safe: ...prior to installing Xcode 4 (from 3). You will lose them (most likely) and with them lose your ability to symbolicate your crash logs.

Adding frameworks: It took me a while to figure this out, and it's nowhere in the docs. You cannot simply do this by right-clicking on the project or a group (like in Xcode 3). You need to go to the project view, select your target and go to "Build Phases" tab. Frameworks can be managed under the "Link Binary with Libraries" section.

Setting target dependencies: Similar to the above, in the "Target Dependencies" section of the "Build Phases" tab.

Delete action-BEWARE: "Delete" (instead of "Remove Reference Only") directly erases the file from your drive. It doesn't go into the Trash, so you cannot recover it.

Text Editor: Here a couple of good ones:

  • Cmd-clicking on a class name will take you to the implementation (or header) file of that class, cmd-clicking on an object will take you to where the object is declared.
  • Alt-clicking will open a documenation popup for the object you clicked on.
Nick Toumpelis
  • 2,717
  • 22
  • 38
  • http://stackoverflow.com/questions/3352664/how-to-add-existing-frameworks-in-xcode-4 – Nick Toumpelis Mar 10 '11 at 17:06
  • 1
    This github link https://github.com/pazustep/three20/commit/4a9aad4eb90a6962dd729d245f9293a7cc0d7f36 includes a fix for the Three20 archiving issue on xcode 4. Haven't tried it yet, but it looks relevant. – Ben Clayton Mar 10 '11 at 18:13
  • Thanks, Ben. I used a similar approach to overcoming this, a while ago - I think that this one works as well. – Nick Toumpelis Mar 10 '11 at 22:23
  • Re Adding frameworks: if the target is an application, you can simply add it in the Summary view, practically the same as in Xcode 3. – Elise van Looij Apr 28 '11 at 20:23
2

3-finger sideways gesture to left is the Back button, and goes to your previous file. Gesture to right goes to your next file in the stack. (not sure if this was true in XCode3)

Z S
  • 7,039
  • 12
  • 53
  • 105
2

http://pragmaticstudio.com/screencast-tags/xcode4

After watching these great little videos, I instantly warmed to XCode4

They have really sorted it out big-time in so many different places, making conceptual changes such as:

  1. one window = NICE
  2. TextWrap
  3. removed annoying 'stop running + rerun' dialog
  4. good color scheme facility
  5. CMD SHIFT O to locate a header file
  6. The auto completion is sorted out beautifully
  7. clear console button
  8. search & replace NICE
  9. new keybindings NICE
  10. On-the-fly error checking - love it!

As you can see, I made notes over the first 2 days of using it; every time I liked something, or every time something went wrong I would jot it down.

So far I have listed 16 problems, but these are all glitches, such as the colouring system going wrong in certain situations etc... ie all minor things that will get patched up pretty soon in updates.

With the occasional crash, I am not going back to 3.x unless I absolutely have to.

The only thing which really gets my goat is that Apple STILL refuse to support incremental updates. it is totally crazy, and I hope everyone makes a lot of noise about it until they sort it out.

P i
  • 29,020
  • 36
  • 159
  • 267
  • 2
    Not everyone has the luxury of a 1MB/s Internet pipe. And even those that do are in for a long wait. It is grossly inefficient, and a waste of disk space. given that Apple have shipped a product with a zillion bugs, it would be nice product design to get the patches as they come, say an automatic check every day, maybe a download of a couple of megabytes every week, it could all be done seamlessly. Wouldn't that be wonderful? – P i Mar 17 '11 at 04:19
  • Even if we all have super connections, it is very irritating to have to download and reinstall 4GB+ just for some minor incremental update. example: some Apple dev coded CTRL+CMD+M toggle upside down, obviously it resets itself to YES when it needs to reset itself to NO. it would be nice if he could fix it, issue a minor update that would download in < 200k within a couple of seconds my launching Xcode, and prompt me to fix/apply update with a single click. that is what all of the other software is doing. It isn't rocket science. – P i Mar 17 '11 at 07:00
  • How about the largest piece of software on your box (aka OSX) ? – P i Mar 23 '11 at 14:31
  • You don't even have to go to the "patch" level. You can look at the Packages folder in the Xcode download and see that if they only updated DeveloperTools.pkg, a 130M download would have been enough. – Jorge Bernal Mar 31 '11 at 18:23
  • Joe Blow clearly does not know what he's talking about, and seems to feel the compulsion to defend Apple. hence I'm not interested in pursuing the discussion. – P i Apr 01 '11 at 13:29
2

I wondered where per-file compiler flags had gotten to.

Spoiler: Select project, select target, select Build Phases tab, expand Compile Sources phase and rejoice.

Joshua Nozzi
  • 60,946
  • 14
  • 140
  • 135