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/ [1] 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 [2] . 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/ [3] [4]
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 [5] . 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 [6] . 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 [7] 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.
Links
- ^ http://connect.apple.com/ (connect.apple.com)
- ^ install Subversion on a Mac (www.wikihow.com)
- ^ http://publicsource.apple.com/darwinsource/10.4.9.x86/Libstreams-24.1/ (publicsource.apple.com)
- ^ http://publicsource.apple.com/darwinsource/10.4.9.ppc/Libstreams-24.1/ (publicsource.apple.com)
- ^ unlocking cell phones in some circumstances (arstechnica.com)
- ^ Landon Fullerâs post (landonf.bikemonkey.org)
- ^ http://ellkro.jot.com/HowToBuildObjCApps (ellkro.jot.com)
No comments:
Post a Comment