Saturday, May 22, 2010

Developing My Own Jailbroken iPhone App

I've been wanting to do this for a while now. In my Electrical Engineering program, I simply haven't learned enough about programming. Many of the jobs I applied for require mastery/competence in some form of programming or another. That's why I'm combining that fact with my enjoyment of my jailbroken iPhone. It's a great platform with many developers making it easier to use every single day. I won't get into the whole "To jailbreak or not to jailbreak" or "iPhone versus Android" cans of worms, except to say that it simply comes down to how the system fits best into your life. Shall we? This will be as much a tutorial as an adventure journal. I have found very little documentation on the matter, so I'm trying to lay at least some form of foundation for that. I have absolutely no idea why there aren't more guides on how to start developing for jailbroken "iDevices" (it's in quotes because, though referring to iPhones, iPod touches and iPads, Apple has many "iDevices," eg. iMac), so I'm trying to make at least some form of comprehensible handbook. It may or may not be improved over time into a bona fide tutorial. If there is some sort of gag rule on guides for developing for jailbroken "iDevices," I simply haven't read anything in my extensive Googling, so on we trudge.

There are a lot of basics that I'm skimming over here. If you have any questions, ask a question in the comments. I'm only providing this documentation as a complement to what I used and whatever else is out there. Don't take this guide to be complete or necessarily correct. I take no responsibility for any damage caused to your system.

For now, I won't say what I'm trying to do for fear of someone with actual skills swooping in and making the app before I get a chance to. I know this isn't in the spirit of sharing and openness, but this is a learning experiment for me (and you). I won't learn as much if someone goes ahead and creates an example of what I'm trying to do. I'd just be copying and differentiating from them. In this way, it will help the reader form some sort of understanding of what it's like to blaze a new trail.

So where am I starting? I have a PC, and I want to keep it that way. Unless I absolutely have to, I don't want to shell out so much money for a MBP. I may be more easily tempted if the 13.3" MBP gets the Core i3. Thus, according to iphone-dev at Google Code, only certain platforms work with the iPhone toolchain. I am going with Debian because that's what saurik uses. I tried installing Etch, but I couldn't figure out how to get that done. I ultimately went with the Lenny version of Debian, so we'll see how that works out later on. Since that was a huge sore in my side, I'll try and break that down in this post.

I installed Debian over USB onto a new partition. I think that means you need a separate partition. Unfortunately, I didn't have a big enough second partition, so I had to back up all my stuff and reinstall Windows 7. You may need to grab a new key if so. Luckily, I got my copy of Windows 7 Professional from the Microsoft Developer Network Academic Alliance, so I got a new key pretty easily. I don't see why you can't reuse the key if you format your hard drive, but it probably has something to do with money. Anyways, so I did that and gave myself about 50GB for my Linux partition. Should probably be enough. We'll see how that turns out.

You need to have Linux installed before you can set it up, so go ahead and install whatever Ubuntu you want on your new partition. I used UNetbootin to install a Ubuntu Live CD to my USB, and that's how I was able to format the new partition to ext3, which is the file system that Linux uses by default. You're supposed to use Debian 2.6.18 according to iphone-dev, but it was so confusing figuring out how to get it installed. I don't understand how Linux source files work, so searching for 2.6.18 was a bit of a bust. I'll just walk through how I installed Lenny, and I'll try to figure out how to get the actual 2.6.18 on my computer later. I'll explain about that when the time comes. For reference, the link the Etch Installation Information can be found here. Boot the USB from the BIOS, install Ubuntu, and update all your packages.

By the way, for the super beginner, apt-get is a sweet package. It will install stuff within your list of sources just by saying
apt-get install the-particular-name-of-whatever-it-is-you-want-to-install
To update anything already installed, type in
apt-get update
This works the same way in MobileTerminal on your iDevice as well. You add sources, install single packages within those sources, and then update them whenever. Cydia is just a graphical version of this process.

As per the Lenny Installation Guide, in order to get the USB boot, get the necessary vmlinuz and initrd.gz files from the server. You should be within Ubuntu by now, so pick whichever platform your computer uses (mine was AMD64), click on installer-(yourplatformhere)/, click on current/ (there were other folders, but it just worked for me by going with the current folder *shrug*), images/, hd-media/, then grab the initrd.gz and vmlinuz. The gtk folder holds the graphical installation files, but I didn't go that way. It was "easy" enough going with the non-graphical version, so do whatever you want. For the sake of following my work, grab the non-gtk files.

Then follow this part of the guide to boot from your USB. Back up whatever is on that USB first. Install GParted to format your USB into FAT16. I recommend installing the Master Boot Record to your USB to save time. When you boot up from your USB from the BIOS, you may see a screen that says
MBR FA:
Click "A" on your keyboard. It stands for Floppy or Advanced, I believe. Then another screen should pop up that says
MBR 1234FA
You should click "1." Then one or two lines will pop up describing something. You might then see something that says
boot:
at which point you should type in
vmlinuz
Then the installer should do the rest. You may or may not see these screens. I saw them sometimes and sometimes I didn't. I think that MBR stuff only showed up for Etch and not for Lenny, but I still had to type in vmlinuz. Moving on.

The non-graphical installer should now pop up. (The installer seemed kinda graphical, but maybe I'm missing out on something even better than BIOS-type graphics.) You have to choose all your settings, plus you need a wired internet connection. Debian doesn't start off with wireless, eh? We'll get to that later. When it asks to connect by DHCP, you need to keep retrying when it asks and plugging your Ethernet cable in and out until it works. Eventually, the installer will ask if you want to install from the CD/USB or from the network, but I just chose to install from the network at this point, even though I had a full CD. This way, you'll be up to date and stuff. That's kinda cool. Yeah, just do that. *shrug* >_> Don't forget to choose the Desktop Environment. I also chose Laptop and Base System, but I'm not sure what Laptop really does. The Desktop gives you the pretty GUI you're used to from Ubuntu. When I installed Etch, it didn't have my laptop's 1366x768 resolution, so things were looking really weird with the 1200x768 resolution. It was also remarkably slow.

You'll also need to set up your wireless connection. As of this writing, the MadWifi project was in transition to ath5k or something, so these instructions might become dated. Anyway, follow these instructions:

http://madwifi-project.org/wiki/UserDocs/FirstTimeHowTo

Some problems came up, but they were resolved using this thread.


See the post at "03/18/09 11:43:02 changed by teetz@gmx.de"

At this point, that's where my development has stopped. I'll let know how things develop. Mind you, this post sums up three weeks of frustration. I've barely even gotten into any of the programming. Alas, good experience for the scholar, yes? I will go back and try to install Etch instead of Lenny, but the process remains almost completely the same. It's just switching out one installation image iso to another almost. We'll see how that goes. See? Everyone's learning. Yay for documentation. Yay for weekend projects. Hope this post helps at least one person. Thanks for tuning in.

No comments:

Post a Comment

 
Website Traffic