iPhone Video Output

There are a couple of options available when preparing to perform a demonstration of an iPhone app to a larger group of people. All these options have flaws, however. The "gather around" method, for example, doesn't work well for groups of more than a few people. Any more and you would ideally want to project the iPhone screen contents onto a big screen.


The "iPhone simulator method" is probably the most used method. It's simple to set up but limits your app navigation to the mouse, making multitouch gestures difficult to perform. Also, there is no way to show off accelerometer functionality like "shake to undo".
The "camcorder method" avoids the simulator's issues, but can be a hassle to set up. It also restricts your movement as you have to make sure to keep the device on screen and avoid reflections as best you can.

Doing it Steve's way
Why don't we take a page out of Steve Job's playbook and mirror the iPhone screen directly from the device onto the big screen?
Sadly this is not straight forward. So far only the iPod application supports video output via Apple's AV cable, at least that's what I thought until I stumbled upon Rob Terrell's iPhone App Video Mirroring blog post (go read it now, I'll wait).

Using the private MPTVOutWindow class in the MediaPlayer.framework API, Rob's code mirrors the iPhone screen onto the AV cable. For demonstration purposes this is a great solution, but being based on a private API it should not be left in the app when submitting it to the App Store.

Originally the code did not support on-the-fly orientation changes and touch indicators, both of which I needed. Thanks to Rob posting the source code I was able to implement these changes and have since submitted the updated code back to him, although I haven't heard back after doing so.

Get your hands on the code
In the spirit of sharing I have prepared a sample project, TvOutputSample, which shows you how to add video output to an Xcode project. This is the application shown in the video above, it should build and run out of the box, using iPhone SDK 3.0.

Download the code: TvOutSample.zip
[UPDATE: The project has moved to github]

I should mention that since the video mirroring is software based it affects application performance somewhat. On an original iPhone 10 fps works well, on an iPhone 3GS I have had no problems running at 20 fps. The fps setting is near the top of the UIApplication_TVOut.m file, do your own tests to see what works best for your app and hardware.

The current version (as of October 2009) of the code does not support OpenGL video output.

 

iPhone SDK development on multiple computers

Sometimes it's good to be able to use several computers to develop your iPhone app. In my case my main development machine is the iMac, but summer is coming up and I may not want to stop developing just because I go out of town. Luckily I have a MacBook, on which I have also installed the iPhone SDK.

In order to test on the device when I develop using the MacBook I have to move my certificate, private key and provisioning profile to it. Here's how I do that.

1. Launch Keychain Access on the iMac (main development computer).

2. Under the Keys category I Ctrl-click the private key that has the certificate for 'iPhone Developer: ' attached to it.

3. In the context menu select 'Export ...'.

4. When saving provide a password, which will be required for importing on the other computer.

5. A .p12 file was saved, transfer it to the target computer.

6. Grab the development provisioning profile (either by downloading from the iPhone Program Portal or by grabbing the right one from ~/Library/MobileDevice/Provisioning Profiles/) and transfer it to the target computer.

7. Double click the .p12 file on the target computer. If you provide the correct password the key and certificate will be installed into the Keychain on the target computer.

8. Drag the provisioning profile onto the Xcode dock icon.

The application can now be installed on the device from the target computer, which in my case is the lovely black MacBook.

Running SDK apps on a jailbroken 2.0.1 iPhone [Updated]

Update: There is useful information in the comments about how to do this with later versions of the SDK as well. Thanks to everyone who has contributed. 

 

This summer I've spent some time working on my iPhone app, which I hope to release on the App Store later this fall.

Since I imported my iPhone from the USA, I have to use the iPhone Dev Team's Pwnage Tool to unlock and jailbreak it. I chose to stay on firmware 1.1.4 until 2.0.1 was available to avoid the performance issues that were widely reported. This means I have not had the opportunity to try my application on the phone itself, but last night I updated to 2.0.1 and tried installing the app.

It turns out my application works great, but I still need to add a few more features and spend some time generating nice visuals to replace the placeholder graphics I am using.

To get the application running on the iPhone I had to copy it using scp to the /Applications directory on the phone and bypass the iPhone Code Signature check. After some googling I found the ldid tool written by Jay Freeman, which takes care of the Code Signature.

Here are the steps I used to get my SDK developed app running on a jailbroken iPhone, all commands should be entered as one liners in the Terminal:

1. Make sure you set Xcode to compile for the device, not for the simulator.

2. Compile the project, then copy the resulting MyApp.app directory to the iPhone's /Applications directory.

mac# scp -r MyApp.app/ root@iphone_ip:/Applications/

3. Access the phone using SSH. The root password is alpine, at least on my phone.

mac# ssh root@iphone_ip 

4. Make sure the executable is marked as such, this step is probably unneccessary but it wont hurt anything.

iphone# chmod +x /Applications/MyApp.app/MyApp

5. Install the ldid tool, this step probably needs Cydia to be installed on your phone.

iphone# apt-get install ldid

6. Run ldid on the application executable on the phone.

iphone# ldid -S /Applications/MyApp.app/MyApp

7. Your application icon should now turn up once the phone is rebooted.

These steps will work even if you have not been accepted to the paid iPhone developer program.

Note that these instructions are experimental. I can't be held responsible for whatever happens if you try them.