Hack your iPhone: install a toolchain

This “hairball” post is ancient and unfinished. Would anyone care about this now? Probably not. Maybe some future data archaeologist will care.

In my previous post I covered what a toolchain is and why you need one to cross-compile applications for the iPhone.

I’ve seen rumors that there will be a Windows toolchain soon, and in theory you can create an iPhone toolchain on older Apple computer with PowerPC chips, but most of the iPhone development these days seems to favor the newer Intel-based Apple computers.

One of the best resources for all iPhone related info is the iPhone dev wiki at http://iphone.fiveforty.net/wiki/index.php/Main_Page (unlinked because the wiki maintainers aren’t sure that they can handle lots of visitors and request that people not link directly). The toolchain page at http://iphone.fiveforty.net/wiki/index.php?title=Toolchain_Project has a lot of details, and the talk page (look for the link labeled “discussion”) gives even more background. But those pages are really terse.

Here’s a little more background info, and I’ll include some additional links at the end.

Getting gcc

Did you know that recent Apple computers (and even the iPhone) ships with a solid UNIX-based kernel? You might have heard that. Something I didn’t know is that Apple computers don’t ship with a compiler such as gcc pre-installed. It should be on the DVD that came with your computer; Apple calls its developer tools Xcode, and Xcode includes gcc.

You can also download Xcode/gcc from the web. Visit http://connect.apple.com/ and sign up for a (free) developer account. After you sign up, the “Downloads” link will become clickable. Click that, then click the “Developer Tools” link. I downloaded Xcode 2.4.1, although there is a beta of Xcode 2.5 available as of today. The download is a DMG file, which stands for “Disk Image.” Double-clicking on the .dmg file will mount the disk image and open a file folder that includes the file “XcodeTools.mpkg” and if you double-click on that package, you’ll get a window that guides you through the installation of Xcode Tools. When you’re done, you can type “which gcc” in a Terminal window and you’ll see that gcc is installed.

Downloading toolchain code

Are you tired yet? Then you might want to take a break, because things are just getting started. For example, the first thing you’ll read on the wiki toolchain page is:

To use the new toolchain, check out the latest branch (as of this writing, 0.20):

svn checkout svn://svn.berlios.de/iphone-binutils/branches/alpha/0.20/

And you might be thinking “What the heck is svn?” It’s a program called Subversion, and it lets you check out source code across the web. Here’s a page about how to install Subversion on a Mac. The short answer is that there’s a couple ways. First, you can install a program called Fink that in turn helps you install more UNIX-related programs such as Subversion. Or you can download a Disk Image file, click the .dmg file, and install svn directly.

Getting Libstreams

The next thing to do on the iPhone dev wiki page says

Download libstreams from Apple’s web site, compile it, and install it.

And I’m thinking “Could they get any more terse?” Plus the dev wiki is locked down to prevent wiki vandalism, so only a few people can edit that wiki. Thanks a lot, wiki spammers, you jerks. Now everybody has to interpret terse instructions on their own and can’t update the wiki with more detailed instructions.

To get/install Libstreams, it looks like you can fetch the correct source (PowerPC/PPC or Intel/x86) from
http://publicsource.apple.com/darwinsource/10.4.9.x86/Libstreams-24.1/ or
http://publicsource.apple.com/darwinsource/10.4.9.ppc/Libstreams-24.1/

You’ll have to log in with an Apple ID. Once you log in, you see about 20 files. Download each one in turn into a single directory, and make sure that you save the files as raw files, not html. Do that by mousing over a file, doing a control-click on the filename, select “Save Link As…” and make sure to change the “Format:” drop-down selector from “HyperText” to “All Files.”

Once you have all the libstreams files in one directory, open a Terminal window, cd into that directory, and type “make” to make the libstreams.a library. Then type “sudo make install” to install the library into the right location on your Apple computer.

Are you still with me? Because we’re really just getting started. Next the wiki says

Get a copy of the iPhone system software, and set the environment variable HEAVENLY to its location (export HEAVENLY=/path/to/iphone/software).

Unless you’re a real geek, you’re probably thinking “What the @#$% does that even mean?” Well, review my toolchain and cross-compiling post. In order to build a proper toolchain, we need some of the software that is only found on the iPhone (header files? libraries? I’m not 100% sure). Since we’re cross-compiling on (say) an Apple computer, that means that we need iPhone software on our Apple desktop machine. That’s a little bit of a problem. In theory, you could copy your iPhone’s filesystem to your computer. There’s even a program called Toolchain Helper mentioned at http://iphone.fiveforty.net/wiki/index.php/Toolchain_Helper that does that. But Toolchain Helper doesn’t run on a pristine iPhone; you need to “jailbreak” your iPhone first. You can also run AppTapp/Installer.app to let you install the Toolchain Helper.

There is another way to get the iPhone software onto your computer. Apple provides the disk image (DMG) file for iPhone software. Woohoo! Except that it’s encrypted. Bleah. But someone figured out how to decrypt the software! Woohoo! Except that some people worry that decrypting the software might be a violation of the Digital Millennium Copyright Act (DMCA). Bleah. But lots of people believe that reverse-engineering software for the purposes of interoperability is legal! Woohoo! And the DMCA contains an explicit exemption for unlocking cell phones in some circumstances. Woohoo! If you’re at all nervous about decrypting a DMG file, then don’t. Consult with your local lawyer to see what your comfort level is.

The best instructions I’ve seen to extract the iPhone DMG contents are Landon Fuller’s post. He has a link to some modified source code to a program called vfdecrypt, but for some reason when I compiled vfdecrypt it wouldn’t work for me on the DMG file. There’s a precompiled vfdecrypt file to be found at http://ellkro.jot.com/HowToBuildObjCApps inside of the phonedmg12.tar.gz file on that page.

And that, sadly, is as far as I’ve gotten so far. I haven’t managed to compile a working toolchain myself yet. I’m using an older PowerPC Mac, and trying to compile things caused errors for me. I enjoyed playing around with toolchains for a day, but I don’t have much more time to invest in this. It’s clear that building a toolchain is still not for the weak of heart. On the bright side, once you have a working toolchain, it looks like there are a ton of cool applications you could write.

Mini-review of the iPad

I played with an iPad yesterday. Here’s my mini-review. The screen is bright and the touch sensitivity is fantastic. Given that it reminds me the most of an iPhone, it’s surprisingly heavy. It feels dense with potential.

On the childlike-sense-of-wonder-scale (as fake Steve Jobs would say), the iPad is better than the Macbook Air but not as stunning as the iPhone when the iPhone first came out. I played with my wife’s iPhone for just a few minutes before I knew I had to have an iPhone. But I never really cared about the Macbook Air, mainly because the screen resolution was worse than my current laptop. The iPad fits between those two products in the spectrum of desirability for me.

The form factor is… weird. You’re going to feel strange carrying one of these into the grocery store, in the same way you felt weird using your cell phone in the grocery store at first. Leave it to Apple to blaze a trail of coolness though; the iPad will make this form factor acceptable, so you won’t feel quite as strange carrying a tablet into a meeting in a few months. The form factor fundamentally is awkward though: the iPad is book-sized, but much more delicate than a book. A screen this big with no protection will get scratched or scuffed. I’d expect to see plenty of articles about dropped iPads like you did about Wiimotes getting thrown into TVs and windows.

The gadget lover in me wants one, but the part of me that cares about open source and tinkering is stronger. I’m with Cory Doctorow on this one. The iPad is gorgeous, but it’s still not worth it for me. Yesterday, I also bought two books at the bookstore to read on a trip. Walking back to my car with “paper media” felt a bit dorky–why am I buying books on paper in 2010? If I could buy a book digitally and really own it (not just obtain a license to read a book, where the license could be revoked), I’d quickly switch to buying my books digitally. But the success of the Kindle shows that a lot of people care more about the convenience than completely owning what they’re buying digitally.

I think the iPad will be a huge hit. Non-tech-savvy consumers will love it because of the user experience, the simplicity, and the lack of viruses/malware/trojans. It’s like a computer without all the hassles of a typical computer (pre-installed crapware, anti-virus software, inconvenient software upgrades). Lots of tech-savvy consumers will love the iPad for the same reasons, and especially for the polish and user experience. The current iPad lacks a few things (such as a camera), which ensures that future generations of the iPad will also be a huge hit.

But the iPad isn’t for me. I want the ability to run arbitrary programs without paying extra money or getting permission from the computer manufacturer. Almost the only thing you give up when buying an iPad is a degree of openness, and tons of people could care less about that if they get a better user experience in return. I think that the iPad is a magical device built for consumers, but less for makers or tinkerers. I think the world needs more makers, which is why I don’t intend to buy an iPad. That said, I think the typical consumer will love the iPad.

Leaving the iPhone

I’m three weeks into a new 30 day challenge: no iPhone. When I got a Nexus One in December, I spent a few weeks carrying both phones around in the pockets of my jeans. It took a little while to adapt to Android, but I’m very happy with my Nexus One and I don’t plan to go back to the iPhone. Both the iPhone and Android are great operating systems, but it’s important to me that I can write or run the applications I choose on my phone.

The best way I can describe the transition is to read this article by Jason Kincaid and this article by Danny Sullivan. Danny contends that the iPhone is better, mentioning that after “literally an hour or less of playing with my wife’s iPhone” he was an iPhone convert.

I think both Danny and Jason are right in some ways. Like Danny, it only took me a couple hours of playing with my wife’s iPhone before I knew that I had to have one. In a post that I wrote in 2007 but never published, I said “I think the iPhone is going to be a monster hit.” And it was. But here’s the thing: I was comparing the iPhone to my previous phone, which was an LG enV. That was like comparing a Ferrari to a old station wagon.

If you’re coming from a feature phone (or almost any type of phone other than an iPhone 3GS), you’ll probably love Android right away. But if you’re already an iPhone power user? Well, you’ve learned how things work on an iPhone. Maybe you have your music in iTunes, and you’ve already built up a list of favorite apps. That makes switching to a different make of phone much harder. Jason Kincaid describes it well: “Imagine if you took a longtime Windows user and sat them in front of a Mac for a couple days.” Things seem weird and different in arbitrary ways, like the power button is on the other side of the phone. But those things fade away after a few days of using Android, and you’re left with a powerful platform that feels like it’s under your control.

Do I still miss a few things on the iPhone? Absolutely. For example, the iPhone makes it easy to take a snapshot of the screen — just press the power and home button at the same time. The iPhone fits 20 apps on the home screen instead of 16 on the Nexus One. I use a password for my phone, and the iPhone has a setting that says “If you’ve used the phone in the last N hours, don’t lock the phone,” while the Nexus One needs me to unlock it each time I wake it up. I prefer the default ringtones on the iPhone. I preferred the iPhone’s finance app for the news sources it showed.

But the Nexus One outshines the iPhone in other ways. Voice recognition built into every text box. Google Voice. And judging from the jitter in Google Sky Map vs. the iPhone Yelp Monacle Monocle, I think the sensors in the Nexus One are a little more robust. Once you use the high-resolution screen on the Nexus One, it’s hard to go back to the iPhone (and the screen on the Droid is very nice too). And I love kicking off a podcast in Listen and then multitasking in a web browser.

The iPhone is praised (rightly so) for its fit-and-finish. But glitches happen on the iPhone too. I went back to check on something a few weeks ago and the iPhone browser kept dying and kicking me back out to the home screen. Overall, I would still rate the iPhone higher on fit and finish, and the iPhone is simpler for a non-tech-savvy person to understand. But polish and simplicity aren’t the most important things to me as a phone user. I want maximum functionality, and the velocity of Android in that area has been staggering. Going from the G1 to the Nexus One in about a year is amazing. I can’t wait to see what new things show up in Android.

Ultimately though, what matters the most to me is control. I have a simple rule of thumb, which is that I don’t put data somewhere that I can’t get it back. That’s the reason that I didn’t buy songs in iTunes, purchase ebooks for the Amazon Kindle, or really log into Facebook at all. It’s also the reason that I recently switched my computer from Microsoft Windows to Ubuntu Linux. With Android, I feel like I have more control. It’s pretty easy to write your own programs for free. My contacts and calendar and email are sync’ed with Google, which lets me easily export that data. I can put widgets or folders or whatever I want on my phone’s home screen. And yes, I could install an app to wobble pictures if I wanted to. Why? Because phones are increasingly mini-computers with a phone attached, and I should be allowed to run the programs I want on my own computer.

I could ramble on about the iPhone compared the Nexus One (both really are great phones in different ways), but I’ll wrap up this post. But my 30 days with no iPhone is going so well that last week I started a new 30 day challenge. My new 30 day challenge is reducing my sugar consumption. I won’t be able to get to 0% sugar (even A1 steak sauce has sugar as an ingredient?!?), but I’m trying to stop eating sugar, candy, Splenda, and anything with sugar as a primary ingredient, even (sob) yogurt. You have to understand, I love yogurt. Wish me luck: only 27 more days to go. Sigh.

Finding the best cell phone carrier

Okay, someone tell me if this device exists (or build it!). I want a device where I can pay $10-15 to get a gadget in the mail. The gadget would sit in my pocket for a week wherever I go. The device would record cell phone signal strength for each of the four major U.S. carriers every few seconds. After a week or so, the device would deliver the verdict on which cell phone carrier would have the strongest signal for me. Then I could mail the device back so someone else could use it — sort of a Netflix-like model to temporarily borrow this device.

At any point, I could go to a web page to view a map of where I’d been. The page would show a “heat map” of signal strength for each carrier or frequency band. Maybe I could also slice/dice by time or see the total number of readings in each location. I’m pretty sure you could rig this up out of 2-3 cell phones running Android in the worst case.

So far, I’ve found:

Android

- RF Signal Tracker is a nice app to collect and map signal strength data. It looks like it can upload to OpenCellID, which is a project to create an open database of cell IDs (numbers that correspond to cells).
- Antennas is a pretty cool free app to show you nearby antennas and signal strength. It can even export some data in KML for use with Google Maps/Earth, but it doesn’t seem to make a heat map that could be easily grokked.
- Sensorly has a free Android app, but they seem to want you to pay to zoom in closer than city level. I’m willing to do that, but didn’t see the for-pay addon in the Android Market.

iPhone

- I also found an iPhone app called Signals that will continuously collect signal data and upload it.
- AT&T offers an iPhone app called Mark the Spot to report dropped calls, no coverage, etc. I have to admit that I don’t understand why this is manual though. Personally, I’d want my phone to ping my carrier with its location every time the phone dropped a call.

Web

- SignalMap is a website to (manually!) submit the number of bars for a location. It doesn’t appear to have any mobile app to back it up. Likewise, Dead Cell Zones and Got Reception? appear to rely on manual reports. I don’t think manual reports is the best way to tackle cell phone coverage maps though — you really want an app for this.
- http://www.cellreception.com/ has the standard manual reports data, but also will map the location of cell phone towers based on the location of cell phone towers registered with the FCC.
- Root Wireless powers the cell phone signal strength maps that CNET uses, but I didn’t see any apps I could download or install on a phone. I registered to be a beta tester a long time ago, but no one ever contacted me.

That’s what I could find. Do you know of any good Android (or iPhone) programs to collect, map, or upload cell phone strength measurements? If so, let me know in the comments.

Hidden Google Gem: Google Mobile App

We recently recorded a video of one of my favorite “hidden gems” at Google: the Google Mobile App, which does voice recognition to make searches easier on a mobile phone. It’s available for the iPhone, Android phones, BlackBerry, Nokia S60, and Windows Mobile. In the video below, I ran the Google Mobile App through its paces on an iPhone:

We basically decided to say queries until something went badly wrong, and I almost ran out of queries. I did:
[behavioral economist]
[ed felten dmca]
[fox theater redwood city california]
[time in beijing]
[39 centimeters in inches]
[answer to life the universe and everything]
[safebrowsing api safari firefox]
[custom made pinata] < – this got recognized as [old custom made pinata], but the search results were still fine
[google quality guidelines]
[sheraton hotel boston massachusetts]

I can’t promise that the voice recognition work as well for you, but I have noticed that the voice recognition has improved considerably since the mobile app first launched. If the recognition doesn’t quite understand your accent, I hope it will in the future. Give it a try though, because you might like it.

css.php