This post is different from the usual struct.ca fare: it’s focused on Flash instead of iOS, and it gets a little technical. Consider yourself warned.
Flash to iOS
For the past week I’ve been playing around with the Adobe AIR 2.6 SDK. I used to be a Flash developer and I still really enjoy using AS3, so when Adobe announced a version of AIR with better support for iOS, I had to check it out. It’s pretty impressive, or at least, it’s not awful anymore. You can see an example of it in action here (note that this is NOT something I made, just an example I found):
I tried porting a couple random Flash projects to iOS and they worked well. They didn’t run perfectly, but they ran well enough to say that Flash-to-iOS is actually viable now. (For the record, the iPad doesn’t run Flash stuff nearly as well as the Playbook, but I haven’t had a chance to try it out on an iPad 2 yet.)
I do my Flash development on Windows (now I’ve really lost everyone ), and one of the issues that frequently comes up while testing Flash-to-iOS apps is the pain of getting IPA files onto my iPhone and iPad. On OSX, it’s easy, you just drag and drop IPA files directly onto the device in Xcode’s Organizer, there’s no need to even bother with iTunes.
On Windows, it’s trickier. You could use iTunes, but its syncing is just way too slow. You could also use Apple’s iPhone Configuration Utility, which is pretty sweet when it works. Unfortunately, I get errors and other weird glitches with it most of the time, but maybe you’ll fare better.
The third option is jailbreaking, which just isn’t worth the hassle, and the fourth is using something like TestFlight or HockeyKit. These tools are awesome when you want to send out ad hoc betas to testers, but it’d be overkill to use them for actual development.
A different way
The way TestFlight works intrigued me, so I decided to do some further investigation. In iOS 4, Apple added the ability to wirelessly download apps directly from your browser, as long the apps are signed and provisioned correctly for your device. This article has all the necessary info on how to do it. You have to create a webpage that links to a plist, and the plist then has links to some icon PNG files and the actual IPA file. There are some caveats, but that’s the gist of it; it’s actually pretty straight forward.
I decided I would create a local web server to host a basic html page and all the required files for wireless app distribution. Think of it like a local version of TestFlight running on your computer. The beauty of it is that it works over wifi, and the IPA gets served directly from wherever it is on your computer, with no uploading required. The issue with most web servers is that they’re usually a bit of work to get running, and I wanted something that was super-lightweight and ridiculously easy to set up, which is how I ended up with good old Adobe AIR.
Over the AIR
Server Sockets are an oft-forgotten feature of Adobe AIR that let you create HTTP servers. This great article by Chrisophe Coenraets is a solid primer on how it’s done. The ability to write a *cross-platform* web server in less than 100 lines of code is pretty powerful.
To get it working all you have to do is start the server and select an IPA file. It even monitors the IPA file for changes using the ideas from this post, so that any time it’s modified, a chime will sound. This is handy because AIR’s IPA packager usually takes a couple minutes, so it’s nice to know when your IPA has been created. I also set it up so that if you keep your device’s browser open, it’ll actually automatically trigger the new IPA to install when it’s been changed.
I use the FZip library to browse through the IPA file (which is really just a zip file), and extact some data from the Info.plist, specifically the bundle identifier, the version number and the app name. These pieces of info only matter while the app is downloading, because after the download finishes, the values in the app’s Info.plist take over.
Once you start the server, all you have to do is navigate to the correct url on your phone (usually something like 192.168.0.10:9999) and you’ll be good to go. Just wait a few seconds or hit the “GET APP” link and the app will download straight to your phone.
Here’s something sneaky: every time you download the app, it appends an incrementing integer to the version number, so that the device always thinks it’s a new build. When the version number says “1.5.1″, it’s actually using “220.127.116.11″, “18.104.22.168″, “22.214.171.124″, etc.
It’s called “EasyIPA”. The magic of AIR means it’ll work on Windows, OSX, and Linux. Just be aware that I didn’t test it very much on OSX (or at all on Linux).
- On OSX (and probably Linux), you’ll have to manually figure out your machine’s local ip (look in network settings).
- If you get a “Port #### may be in use” error when starting the server, refresh your device’s browser then restart the server.
- It can’t extract data from binary Info.plists. This isn’t really a big deal, you’ll just have to enter the info manually (the info doesn’t really matter anyway).
To get it, download and run this.
The AIR runtime should install automatically, but if it doesn’t, get it here.
I threw this together really quickly just as a proof of concept, so the code isn’t very pretty, but if you want to have a look, you can get it here. Feel free to do whatever you want with it.
Please post a comment if you find the app useful or if you run into any issues. Thanks!
UPDATE April 7th: Just made a new version and updated the links above. The only change is that now there’s a field for you to manually specify the server’s IP. This should help in those cases where it can’t figure out your local IP automatically.