Friday, April 26, 2013

Day 3: Development Environment

XCode is the official IDE and a natural choice for new iOS developers. However I have been a longtime user of IntelliJ IDEA for Android development as well as other JetBrains products including PhpStorm, PyCharm, and RubyMine.

Hoping to leverage my existing knowledge of these other IDEs, after a brief introduction to XCode I decided to try AppCode, the JetBrains Objective-C IDE.

AppCode runs on top of XCode, meaning XCode must be installed, and even uses XCode for all graphical UI editing capabilities. Anytime you open a Storyboard (.storyboard) or Interface Builder (.xib) file in AppCode, it launches XCode to interact with that file.

At first glance I like the overall layout of AppCode better, but that could be just because I am unfamiliar with XCode, where I still have a hard time finding things. And AppCode's Darkula theme is so much easier on the eyes than the bright white editor of XCode. Already being fluent with IntelliJ's keyboard shortcuts, it was pretty easy to get started. AppCode also gives you the option to use XCode's keyboard shortcuts (as well as many others).

One of the features I appreciate most about IntelliJ is the powerful code completion and code generation engine. The ability to quickly hit Option+Enter to generate a new class/method/variable on the fly saves a ton of time when coding. While the same concept exists in AppCode, these tools seem slightly less refined in IntelliJ's younger cousin.

For example, when attempting to call a method that does not exist, the statement is underlined in red.

The method someFunctionThatDoesNotExist appears with a red underline because it is not yet defined.
Pressing the keyboard shortcut for QuickFix Option+Enter reveals the ability to create a new method or property. This will update the header file StackOverflowManager.h and implementation file StackOverflowManager.m with a skeleton for the new method. If this function included input parameters those would also be configured through a form in a modal window.

The Option+Enter keyboard shortcut for Quick Fix reveals the ability to create a new method or property.
Here is another example of calling an undefined method, but this time the call is nested inside a macro. This example shows a SenTest macro from the OCUnit testing framework.

The method someFunctionThatDoesNotExist is currently undefined.
Unfortunately when the undefined method is written as an argument to the macro the option to create a new method or property is not available. This is unfortunate because calling a new function inside a macro is especially common when writing new code using test-driven development.

Quick fix keyboard shortcut does not reveal create method/property options when nested in a macro.
The workaround here is to declare a local variable to capture the result of the undefined method.

Result of someFunctionThatDoesNotExist is assigned to a local variable.
Now declared outside the macro the advanced code generation tools are once again available.

Option to create new method/property is revealed when declared outside the macro.
What also seems to be missing is the ability to quickly generate a new test method using Control+N in a test file. Looks like I will be adding a custom Live Template for this use case, which is an AppCode extension to XCode snippets.

For more code generation goodness, checkout this article on the official AppCode Blog.

Does anyone else have experience using both XCode and AppCode? If so, I am interested to hear about which one you like better and why in the comments.

1 comment:

  1. I love JetBrains too, but I'd give Xcode a chance (note, I also have a license to AppCode). You'll still have to use Xcode regardless, and it does have a lot of tools. And obviously you can at least set the editor to a darker color (though I agree, Darcula rocks).

    So why do I stick to Xcode? At least for now, it's because everything is in one place. The point of an IDE is to be self contained, and switching between AppCode and Xcode feels odd. Besides, whether I use AppCode or not, I have to use Xcode.

    I still love my IntelliJ IDEs, but for now, for iOS, I stick to Xcode.

    ReplyDelete