Use IntelliJ for iPhone development using Titanium

Since I wrote the post about setting up Eclipse for iPhone development using Titanium, Appcelerator has acquired Aptana. Titanium studio built on top of Aptana studio is the best supported IDE for mobile and desktop application development using Titanium.

I use IntelliJ for Java development and just out of curiosity wanted to try developing Titanium applications using it.

Enabling code completion in IntelliJ is very simple and straight forward. All we need is to add the JavaScript header file based on Titanium API JSON file to the project source directory.

I have used the PHP script provided by James Low on his blog to generate the JavaScript header file.

Download JavaScript header file for Titanium Mobile 1.7.2

Install git on shared host

Git is a distributed revision control system developed by Linus Torvalds for Linux kernel development. I have heard a lot about git regarding its speed and flexible workflow and decided to install git on my shared host, just to get a feel of it.

The good news is that git is very easy to install, but before you start, you need ssh access to your shared host.

# Make new directory for git
$mkdir git
$cd git

# Download latest version of git from distribution website

#Uncompress source
$gunzip git-, tar -xf git-

#Configure and compile git
$cd git-
$./configure –prefix=$HOME/git
$make && make install

# Update .bashrc file by adding following line and source it
export PATH=$HOME/git/bin/:$HOME/git/lib/libexec/git-core/:$PATH
$source ~/.bashrc

Test your installation
$git –version

if there is no error then you are good to go.

Thanks marlio3 for all the instructions

Setting up Eclipse for iPhone development using Titanium

Working as a Java developer, I enjoy the flexibility which the platform offers. It allows me to develop on/for different platforms, using IDE, framework and application server that suits my requirements and I am comfortable with.

Apple on the other hand has a more restrictive system with their own development platform, SDKs and recommend development tools. The advantage of having their own platform means they can change the hardware or add new features which will be directly available to the developers. Although all iPhone apps have their own unique functionality and interface, having one single platform offers a uniformity in the interface and thus a better user experience.

Having different platform is working well for apple but for developers this means learning new programming language and getting familiar with new development tools. This is where platforms like appcelerator comes into play. Appcelerator Titanium is a platform that allows development of cross platform mobile and desktop applications using common web technologies like javascript. Although I still need Mac OS X and iPhone SDK but I can write code in javascript which titanium will compile to work on different platforms including iPhone. All I need is Titanium developer which comes with its own mobile and desktop sdk. Titanium developer can be used to create new projects, edit project details if required and run/deploy projects on the device or phone emulator.

One thing missing in Titanium developer is an integrated IDE, I can create a project but then I have to use my own code editor to write code. However, this also means that I am free to select my own development tool for writing code. One issue with this approach is that I have to switch between applications. I have to use my IDE to write code and then use Titanium developer to run the application. After doing some research online I found some quick ways to solve my problem and give a better development experience.

Solution to my problem was using Eclipse external tools feature. External tools allow us to configure and run external programs, scripts etc. We can save these external tool configurations to run them later when required.
So to run applications from Eclipse, all we need is to add a new external tool configuration to run a program with following details:

Location: /usr/bin/python (Location where python is installed)

Working Directory: ${project_loc} (Use variable to define project location as working directory)

Arguments: “/Library/Application Support/Titanium/mobilesdk/osx/1.3.2/iphone/” simulator “4.0″ ${project_loc} com.mydomain.${project_name} “${project_name}”

I am using Titanium mobilesdk 1.3.2 and iPhone SDK 4.0, the arguments need to be updated if using different SDKs.  I am using reverse domain name as application id, so if my application is myapp and domain name, my application id is com.mydomain.myapp. I am using variable ${project_name} to construct my application id with com.mydomain as a prefix.

Next thing which I was missing was auto code completion and I found a solution here. We need to install Aptana plugin for eclipse. Aptana is a web development tool for use with programming language like javascript, PHP etc.

Details on how to install Aptana eclipse plugin can be found on this link.

Once aptana plugin is install, switch to aptana perspective in eclipse (Goto Window -> Open perspective -> Aptana).

Next thing needs to be done is change default editor for javascript file (.js) using Eclipse preferences (Preferences -> General -> Editors -> File Associations) .

Now you need to download this javascript file and add into your file references (Goto Window -> Show Aptana View -> References, Create new profile and add file reference).  For more details on how to create this javascript header file on James blog.

Now create a new project and use the project previously created using Titanium developer.

See this video from James David Low for more details:

Eclipe auto code completion for iPhone development using Appecelerator Titanium