Testing on mobile devices without the hardware
One problem with mobile web development is testing, which I mentioned a few months ago in a post about Opera Mobile emulator and Opera Mini simulator. Emulating or simulating a specific browser is definitely better than nothing, but what about entire mobile devices?
Many developers don’t have physical access to a whole lot of different mobile devices, and buying a load of phones and tablets just for browser checking can be hard to justify. But another option is using a simulator or an emulator for browser checking. It’s not exactly the same as using the real thing, but it beats not testing at all.
I’ve been using the iOS Simulator and the Android Emulator for this. Both are available for free and do the job.
You can get the iOS Simulator, which is part of Xcode, in two ways, both of which are free:
- Join the Apple iOS Developer Program and download XCode from Apple’s developer site
- Get Xcode 4.1 from the App Store
The difference is that the App Store only seems to offer XCode 4.1 which appears to require Mac OS X Lion. So if you haven’t upgraded to the latest Mac OS X yet you’ll need to join the developer program, where it looks like you can still get XCode 4 that will run on Snow Leopard. Unfortunately the developer program isn’t free (anymore, I’m pretty sure it used to be) – it costs USD 99 per year.
Once Xcode is installed you can find the iOS Simulator in /Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/.
The application runs really well and lets you choose between emulating an iPad or an iPhone with or without Retina display. You can also choose which iOS version to run on the simulated device. You can rotate the devices, pinch, etc. Very smooth. From what I can tell there is very little, if any, difference between how a web site/app renders in the simulator and on the real thing.
One major advantage of running the iOS Simulator instead of a real iOS device is that it uses your computer’s hosts file, so you can browse to development sites on your local web server. This is much quicker than having to upload your files to a publically available server before testing.
A lot of people use Android devices, so checking your work on one makes sense. The Android web browser does use WebKit, just like Safari on iOS, but there are some differences between them.
The Android Emulator is part of the Android SDK, which can be downloaded for free.
The Android SDK installation instructions mention installing the Eclipse IDE and a plugin for it. You don’t need Eclipse or the plugin if all you want is the emulator to check your websites in. Just skip that part and follow the rest of the instructions to get the Android SDK and AVD Manager up and running. That’s where you add SDK Platforms and create virtual devices.
Now, I’m sure there are reasons for this, but the Android emulator is slow and extremely CPU heavy, at least when running on a Mac. A look in the Activity Monitor shows it occasionally using 100% CPU when emulating a tablet-size device running Android 3.0 on my quad-core MacBook Pro. It isn’t far from being unusably slow. Typing in a URL will really test your patience. Sure, it is an emulator and not a simulator, but still… I don’t remember running Windows in VirtualPC on a PPC Mac being this slow. My memory may be off, of course.
Another problem is that it doesn’t seem like the Android Emulator can browse to local sites, which makes changing things while testing a bit of a hassle. Still, slow or not, it’s much better than nothing.
Update: A reader kindly pointed me to the Referring to localhost from the emulated environment section of the Android documentation. Entering 10.0.2.2 in the Android browser is the same as entering 127.0.0.1 on your host computer, which brings up your local root site.
That does help, but only just a little since it doesn’t let you browse to your locally configured virtual hosts. I can’t speak for everyone, but I have many virtual hosts configured that I need to access while developing. If you’re in the same boat, maybe Push Hosts file to Android Simulator can help.
Another option is localtunnel. I haven’t tried it so I don’t know how well it works, but it may be worth checking out.
Software is good, but get hardware if you can
If you can get hold of hardware it’s probably a better option, especially for Android since the Android emulator is so slow. For iOS the iOS Simulator is fast and works very well, but it’s only available for Macs, so if you don’t have one you’ll still need to get a real iOS device.
But again, software options like these are very useful for those of us who can’t or won’t fill up half their office with mobile devices.