Monday, July 6, 2009

Deploy app on iPhone - no wifi - no appstore with full explanation

I received an iPhone (OS 3.0) 2 days ago. My new task is: learning how to deploy our iPhone applications on this device. There is no wifi at my home. Our application is also not uploaded into Apple App Store. So, I need a way that:
1. Only need to copy our application into iPhone and run.
2. No need wifi to copy and setup

Is that difficult?

I read tons of articles and search on many forums but when I follow their steps (no understanding) I got different failed results.

Finally, I find a way after analyzing from many sources. Below is the list of step that I will guide you with my explanation. Anyway, I write this article just for iPhone developers (not for end user). However, in case you are an end user, you can also find some helpful information to solve your problem here.

The solution is:
Connect to your iPhone by using SSH with root account. With the console on SSH, you have the full access right to run any commands (supported by the kernel system behind) to copy/set access right/install/remove your software. However, if you have no wifi - you need a software to bind your an available port on your computer with port 22 (of SSH) on iPhone. The soft to do that is called iTunnel.
iTunnel is worked based on iTune. You should choose to install latest version of iTune to make sure this works ok.
Below is the list of step you need to follow:

Step 0: install latest version of iTune in your computer


This is very important. Without iTune, iTunnel can be run on command line ok. However, when you use SSH to connect to the available port - it will throw error.
In the past, I think this trick does not need installing iTune anymore but I found a problem when I help my team member to do this. At last, we found that the difference between our computer is the iTune version. You must download the latest version of iTune and install it on your computer to make sure this trick works.

Step 1: Install OpenSSH on your iPhone

You need wifi only in this step. To do this, you just need to connect to wifi - go to Cydia - search OpenSSH and install this package. The final result of this step is: OpenSSH will be run as a service in background and open the port 22 to connect. Anyway, you need to check whether the service is turned on or off. To do this, you need to install another software to check. I recommend you should search BossPref (also using Cydia to install).

Step 2: Download and run iTunnel

You can search on Internet to download this software into your PC. I recommend a link that you can download as below:
http://www.makkiaweb.net/blog/2008/09/iphone-tunnel-suite-27

After downloading this, you only need to unzip into a folder. Open the console and go to this directory. Type into the console:

iTunnel.exe 22 [any available port on your computer]
The final result of this step is: iTunnel binds port 22 on your iPhone with a port on your computer.

Step 3: Use any SSH client to connect to the port (on step 2) with root account.


I recommend that you should use WinSCP. The password of root account is: alpine

Example: if I use the port on my computer to bind is: 9000. I will login to SSH on my computer with below information:
HOST: 127.0.0.1 (localhost)
Account: root
Pass: alpine
Port: 9000

After this step, you can see a window (if you use WinSCP) with 2 panels. Left is for your computer, right is folder structure on iPhone. You can copy your app and set execute rights on this. You can also go to menu, open terminal to run any commands you like with root account on iPhone.

Good luck! If you have any problem, leave comments here and I will help.

Update for common questions:
Question 1: I meet "bind error" on the command line when I run iTunnel.
Answer: The port you want to bind was used by another program. So, please try with another port. See step 2 with the command line

iTunnel.exe 22 [any available port on your computer]
After you run the iTunnel successfully, use above port to connect with WinSCP.