lunedì 2 aprile 2012

How to develop iPhone apps on Ubuntu

Abstract

How many of you wish to develop iPhone apps without using a Mac? Well, after several tries, I finally found javacom/toolchan4. This project provides a simple script to install the iOS SDK on Ubuntu 10.10. In addition, it provides an integration with Theos suite.
In this guide I will show you how to prepare your computer for install iOS SDK 4.2 in Toolchan4 and how to upload your iPhone apps on your iDevice.

Before Start

As you can see, Toolchan4 works on Ubuntu 10.10. Although there's a workaround to work on Ubuntu's most recent versions, I will show you how to instal Ubuntu Maverick on Virtualbox. I choose this option to preserve my system, I’ll later show you what do I mean, and also because I don’t want to install an unsupported version.

Stuff


  • Virtualbox stuff
  1. Virtualbox installer for your favourite OS
  2. An Ubuntu 10.10 iso file
  • iOS SDK Installation stuff
  1. xcode_3.2.5_and_ios_sdk_4.2_final.dmg available on Apple Developer site (registration required) 
  2. Java Virtual Machine for Ubuntu (installable from the Ubuntu Software Centre)
  3. 7zip (available on  Ubuntu Software Centre). I will use it to unzip the .dmg file
  4. the cross-platform version of HFSExplorer (file .zip)
  • iPhone stuff
  1. a jailbreaked iPhone
  2. OpenSSH and Installous apps

Install Toolchan4

  • Setting Virtualbox
If you want to install Ubuntu 10.10 on VirtualBox, you can follow any guide you want. The only thing you need to mind is to configure your virtual machine network options. By default Virtualbox sets new virtual machines with "NAT network" option. This option lets the machine to connect to the Internet, but it denies the connection on local devices (even the iPhone). To permit virtual machine to access the iPhone, you have to go to virtual machine Settings then select Network and set "Attached to" to "Bridged Adapter" (Fig.1)
Fig. 1

See Virtalbox's manual (chapter 6) for more.

  • Extract the SDK from Xcode
Now we proceed extracting the SDK 4.2 file from Xcode. First of all we'll need to obtain the 5.hfs file from xcode_3.2.5_and_ios_sdk_4.2_final.dmg. To do that open a terminal (ctrl+alt+t) and run the following code into you download directory:
7z e xcode_3.2.5_and_ios_sdk_4.2_final.dmg 5.hfs

I don't mount the 5.hfs file directly in loopback, but I extract the SDK file using HFSExplorer.
At First search "java" in Ubuntu Software Centre and install the "Openjdk java 6 runtime" package. Now open a terminal in HFSExplorer directory and run the code
./runfsb.sh

In HFSExplorer go to Open -> Load filesystem from file and select the 5.hfs file. Now extract the PhoneSDK4_2.pkg in /Packages directory (Fig. 2)
Fig. 2


Follow the Toolchan4 guide on the project homepage (linked above). Pay attention to step 6, the guide rename some system files (as and ld), this is the reason why I choose to use a virtual machine.
Well, now you can compile an example project to test Toolchain4.


  • Deploy and install ipa package
Before starting, be sure you have OpenSSH and Installous installed. If you don't know how to install those apps, search on Google.
Now to get the iPhone IP address, go to Settings on your Springboard, then select Wi-fi. In "Wi-fi networks" find your network and press the blue circle with an arrow in it. Your iPhone's IP address will now be displayed .
Go back to Ubuntu and select Places -> Connect to server. In "Connect to server" ... select:
Server type: SSH
Server: the iPhone's address
User Name: root (password "alpine". It will be asked you on connection).(Fig. 3)
Fig. 3



When you are logged in search the folder /var/mobile/Documents/Installous/Downloads and copy the .ipa file. Then open Installous on your iPhone device, tap Downloads, select your file and install it.
That's all!


Conclusions

In this guide I showed you what files you have to download to install Toolchan4 and how to setup a virtual machine to deploy and install your iPhone apps. To date an Opensource graphical IDE for iPhone apps does not exist, then you just have to only write code by hand.

Marco "Mad Hatter"

P.S.

If you think you have tons of time to spare, can you please read this and point out the mistakes I did?