The course was great, we all learned a lot, and several of our folks are working on some apps, including one that they announced recently at JBoss World.
80% or more of our consultants have MacBook Pros, however, I opted for a Dell with Ubuntu when I joined Chariot about a year and a half ago.
I borrowed a MacBook for the course (thanks, Ken!), but have been feeling a bit left out since then, as the official Apple development tools (XCode and Interface Builder) only run on OS X.
I had previously whined about the fact that the official toolchain uses GCC under the covers, and that therefore, someone who knows GCC well (as in not me) ought to be able to get something working on Linux. Since then, I’ve seen a few pages on the web with instructions for getting arm-apple-darwin9-gcc working on Linux, but none seemed to have complete instructions on how to get the development environment working.
Well, yesterday, I decided to look harder, and found a site that
explains setup of an iPhone development environment on Linux in detail.
With the help of the instructions there, I was able to get the toolchain working under Linux, and with some information gleaned from other websites as well, was able to compile an iPhone app, install it on my phone, and run it. I can stop whining now:-)
So, I’m putting all of the information that I have about this process here, in one place, where I can find it again later – if you have read this far, then I hope it helps you too.
What you need:
- A computer running Linux
- A Jailbroken iPhone (see my previous blog post for instructions)
- A Wifi network to enable your computer to communicate with your iPhone
- A copy of the phone’s firmware – since you just jailbroke your phone, you have a copy of this – it’s the .ipsw file
- The IPhone 3.0 SDK (see http://developer.apple.com/iphone/)
- Make sure that the Cydia package manager is installed on your iPhone – if you followed the instructions linked above, it should have been installed as part of the jailbreaking process.
- Use Cydia to install OpenSSH – this installs an SSH Daemon on your phone, so that you can ssh into the phone from your computer. Your makefiles will include ssh and scp commands to get the app to your phone and install it properly. Before moving on to the next step, make sure that you can get OpenSSH running, and can successfully ssh into your phone as root, and get a shell prompt. If you need help with this, look here.
- Use Cydia to install Apt. Sometimes things are just easier from the command-line.
- Use Apt (or Cydia) to install the “ldid” package. Some makefiles that you will encounter will use this to pseudo-sign the app directly on the phone.
- Follow the instructions at http://code.google.com/p/iphonedevonlinux/wiki/Installation to install the toolchain, including installation of the packages listed there.
- Follow the instructions to download and build the HelloToolchain application. Note: make sure that your phone and computer are both connected to the same wifi network, that the SSH daemon is running on your phone, and that you know your phone’s IP address. To make things easier on myself, I set up my wifi router to recognize the iPhone’s mac address, and to always give it the same IP address. Now, I can use a shell script to invoke make with the proper address, and I don’t have to check the phone’s address each time.
Once that simple app builds, installs, and runs, you are almost in business. The major issue is that HelloToolchain, being a simple test app, doesn’t show you how to structure things for a “real” application. And if you’re not a Makefile geek, it may not even be obvious how to build an app that consists of more than one source file. So, go to http://code.google.com/p/apiexplorer/ and download the iPhone API Explorer project. It demos just about every user interface object, and has a really well-thought-out Makefile (be sure to use Makefile.linux) that shows how to build a complex project.
If you have gotten this far, you are probably tired by now of typing
in the password for your phone three or four times for each build.
To set up public key authentication for your phone:
- ssh into your phone, use apt to install vim if necessary, and then use it to edit /etc/ssh/sshd_config
- uncomment the line: PubkeyAuthentication yes
- use the ssh-copy-id script to copy your public key to the phone.
That should do it. Happy iPhone programming!