Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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.

Jetbrains is actually developing an alternative to XCode, so since you are a fan of IntelliJ Idea you might be in luck soon:

http://devnet.jetbrains.net/thread/291466

Try JetBrains AppCode http://www.jetbrains.com/objc/

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.

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

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.

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.

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.

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.

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.

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.

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!

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

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top