views:

5098

answers:

15

I've been a Java developer for 10+ years now, and have come to love the power that modern IDEs provide for things like refactoring, finding dead code, finding "usages of", etc. I'm starting to do some iPhone dev on the side, and am utterly frustrated by the lack of such features in XCode. There is no "find usages of this method/class" that I know of, so I resort to doing "find X in project", and even that sometimes misses things (why??!)

I realize that some of these things are perhaps not possible in Objective-C, owing to Java's strong type system and built-in reflection APIs. But even simple things seem to be missing, or at best hard to find. For example, there is no keybinding for "reformat this code"; you have to go to the Edit menu and then navigate 2 submenus to do that.

Has anyone had success in using another IDE for Objective-C/iPhone development? Eclipse? I'm a big fan of Intellij IDEA, but it has no such support, as far as I am aware. Failing that, pointers for setting up XCode would be highly appreciated.

A: 

I'm really not intending on trying to belittle your question, but VIM, make, and gcc work great for me for ALL languages and platforms. It's the one toolset that (for me) is the most portable and reliable. It's not a pretty as you may like, but it gets the job done just as efficiently.

Andrew Sledge
Sledge- I used to be a hardcore command-line and Emacs guy. I resisted using an IDE for years, thinking "who needs this intellisense crap?" Then I had the pleasure of working on a nearly 1M LoC codebase with several other developers, and realized just how useful an IDE is for code navigation alone.
Caffeine Coma
Thing is, emacs doesn't have to be primitive. Sure, it doesn't have intellisense yet (though, I know this is being worked on), but nearly every other cool feature is there if you are willing to do some work...
dicroce
Yeah, I've used Eclipse, VS, et. Al. but I keep going back to VIM.
Andrew Sledge
@sledge then you must be doing something wrong.
foljs
+6  A: 

I still have some trouble adapting to XCode too, but it's getting better the more I use it. I am using vim for everything else but Cocoa programming.

One thing that I found helpful was putting this Xcode keyboard shortcut list next to my monitor.

For menu items that miss keyboard shortcuts, like "Reformat this code", use these instructions to define your own shortcuts.

thesamet
Wow, that's awesome. This will definitely ease the pain of switching back and forth from Intellij/XCode if I can use the same shortcuts.
Caffeine Coma
+21  A: 

I had the same issue when I first started using it. So, I asked a friend who worked for Apple whether XCode is really the tool most internal developers use.

He said it was, and his explicit recommendation was just to bite the bullet and get used to it. You might be able to find an alternative, but you'll be fighting this forever instead of building iPhone apps. Sometimes, when you're in Rome, you must do as Romans do.

dicroce
I tend to agree about not wanting to "fight this forever". Good to know that Apple eats its own dogfood. As thesamet notes below, it's possible to create my own shortcuts, so I will probably take this as the path of least resistance... thanks!
Caffeine Coma
And that's why i'm never going to be an ipone developer, can't you get into android or windows phone 7 that actualy have some developer tools..?
Lavinski
+16  A: 

1) There are refactoring tools in the IDE. You can select a class or variable name and opt to refactor to rename.

2) Use the shortcuts, and the extra features - You can quickly swap between header and implementation files with Cmd-Alt-Up. Alt-Double Click brings up documentation for a framework call, and Cmd-Double Click will jump to the definition of a variable or method.

3) I usually use "find selected text in project" to look for uses of a method - I'm not sure why that would not work for you always.

4) If you want to find some interesting issues there's a great static analyzer you can run over your code, the CLANG scan-build:

http://clang.llvm.org/StaticAnalysisUsage.html

5) I think IB is better than any Java GUI designer I've ever used.

XCode and IB and Instruments together are actually very powerful tools, spend time researching what they can do for you...

Also if you really feel the need for more advanced editing features, there's nothing wrong with jumping out to external editors from time to time if they can do other things for you. A very popular one is TextMate, I also continue to use emacs from time to time.

Kendall Helmstetter Gelner
A: 

While not a true IDE, if advanced text editing is what you're after, TextMate is extremely powerful. It handles a wide variety of languages, and has user-created extensions (bundles) that add a lot of interesting functionality. It's particularly good at the kind of reformatting operations you describe. I use it for all sorts of text editing.

However, I do all of my Mac / iPhone development in Xcode. I've tried other tools, like TextMate, but I keep coming back to this IDE. Almost all experienced Mac developers that I've met use Xcode and most are happy with its functionality and layout. It may be that you need to adjust to the design of this IDE, as opposed to Eclipse or Visual Studio. Frankly, I was not impressed with those IDEs (or KDevelop, where I'd done some Linux work) and found that Xcode fit me well.

As has been stated, Xcode 3.0 and 3.1 brought some significant improvements to the IDE.

Brad Larson
+1  A: 

There is a command line utility called xcodebuild. You can set up a project in Xcode so that Xcode generates all the necessary files and whatever else it does, but you can use any external editor you like. All you have to do is run xcodebuild in the same directory as the Xcode project itself and it will build it. You can even choose which target and which build configuration you want to use from the command line.

It's a bit of a silly idea since you'll have to deal with more than one IDE, but I've done it on occasion because sometimes I find it easier to develop on the command line.

dreamlax
Thank you for this post as it inspired me to use xcodebuild + vim to compile xcodeproj.
manifest
+5  A: 

The XCode tricks and tips thread has some real gems - I encourage you to read it if you haven't already.

Jane Sales
Thanks Jane. Tried to contact you at ambientindustries, but the address in the mailto on your site just bounces. :-(
Caffeine Coma
we're firstname @ ambientindustries dot com. Try rog if jane bounces.
Roger Nolan
+1  A: 

The ObjectivEClipse project is a new effort to add ObjectiveC support to Eclipse CDT. Its still very young but if anyone here is willing to participate in open source development please take a look.

Mike Kucera
+3  A: 

In order to really love XCode I had to make the following changes:

  • Switch to the All-in-one layout: this really helped avoid the window orgy that was going on.
  • Switch the Debugger Display to the Vertical Layout: this made debugging much more pleasurable
  • Installed uncrustify and created user scripts to uncrustify my files (bound to command-1): this made editing other people's code much easier, I like whitespace and { on a new line, most Objective-C code doesn't look that way.

Just those three changes will go a long way towards improving your XCode experience. The more that I use it, the more I like it. They still need to improve the find/replace functionality and improve the speed of adding/removing breakpoints, but otherwise I am very happy with it.

jessecurry
I suspect you're really going to like XCode 4 then: http://developer.apple.com/videos/wwdc/2010/
Tim Keating
To switch to All-in-one close all projects, then Xcode > Preferences. Click the General button in the preferences window toolbar. Choose All-In-One from the Layout pop-up menu.
manifest
To set the Debugger display to vertical layout:Run > Debugger Display > Vertical Layout
manifest
A: 

I you're a Java developer, and like all the cool features brought by the Eclipse Java plugin, so as an analternative to pulling ObjectiveC out of XCode, you can try to stick to Java , and use iSpectrum ( http://www.flexycore.com ). With this compiler+Eclipse plugin solution, you keep developping in Java, in a well known an appreciated environment to build native iPhone applications!

Butters
Does Apple allow this?
Arne Evertsson
Hmm, it generates objective-c. I think Apple explicitly prohibits code translation, but maybe you could get away with it anyway?
manifest
A: 

@jessecurry

Wow that debugger vertical layout thing jut eliminated like half the remaining suck of my Xcode install. You just made my whole week!

I'm starting to think that Xcode is actually configured perfectly for machines with 2 to 4 of those Apple 30" monitors to spread everything out on.....and that those of us who don't have the $4000 to $8000 to spend on monitors just need to go through Xcode and change EVERY SINGLE setting.

Brian
Why not add this as a comment? It is not an answer and just adds clutter.
manifest
A: 

@ Brian: I agree, I'm starting to like Xcode a lot more after making some of the changes suggested in this thread. The defaults for Xcode seem to be a bit bizarre, or at least (as you say) they assume a lot more desktop space than I have on my 13" MBP!

SpaceMonkey
Again, not an answer. Just adding clutter
manifest
Add comments as comments, not as answers.
tadman
@manifest: They're answers because users with less than 50 rep can't leave comments.
mipadi
@mipadi Right, forgot about that, but I'd still mod down because they're useless. They shouldn't post anything at all if they can't comment
manifest
A: 

I prefer vim as a single interface for multiple languages/platforms. For the vim freaks out there, I put this in my ~/.vimrc:

"xcode make program
let prg="xcodebuild"
let makepath=$MAKEPATH
let &makeprg="cd ".$BASE.";".prg.' '.makepath
"/Users/user/Project/Classes/stuff.m:46: error: 'somecrap' was not declared in this scope
set errorformat=%f:%l:\ error:%m

Then when I want to vim code with Visual C++ on a windows box:

"Visual C++ 2008 make program
let prg="devenv"
let makepath=$MAKEPATH
"makeprg= cmd /c "devenv /some/path/to/some.sln"
let &makeprg='cmd /c "'.prg.' '.makepath.'"'
"2>c:\cygwin\home\user\proj/blah.cpp(1657) : error C2065: 'blah' : undeclared identifier
set errorformat=%.%#>\ %#%f(%l)\ :\ %#%t%[A-z]%#\ %[A-Z\ ]%#%n:\ %m

There are some fancy ways to set the makeprg depending on what type of file you're editing but I haven't done that yet. Either way, setting the makeprg and errorformats in combination with :cw should make any vim fan happy. I still have to debug in the corresponding IDE's but I can code and compile extremely fast with vim alone.

manifest
A: 

For example, there is no keybinding for "reformat this code" - Caffeine Coma (OP)

Partial solution: use control-I on a single line or within a selected region to re-indent it.

Off-topic:

Why not add this as a comment? It is not an answer and just adds clutter.

stackoverflow forces newbies to do that or else remain silent. People need 50 points to comment. Before downgrading an answer, consider checking the poster's SO points. Ironically, demoting newbies' comment-ish answers may exacerbate the problem by making it harder for newbies to reach 50 points.

Kevin
A: 

Some shortcuts that I find helpful:

  1. command+shift+d go to definition of function/variables/types etc (click in the middle of or double click to highlight what you're looking for and then do cmd+shift+d )

  2. alt+double click : hold down alt and double click brings up quick help as well as a button to go to documentation

  3. hold alt and click on a file to open it in adjacent side-by-side view (xcode 4)

those are my most used ones. Additional shortcuts here: http://cocoasamurai.blogspot.com/2008/02/complete-xcode-keyboard-shortcut-list.html

Jlam