Yep, that’s right. Now let’s clear up some questions. (By the way, I’m doing all this from Windows 7 RC). There are several other tutorials that show how to do this, but most of them were quickly written with little or no explanation. I try it explain things a little bit more here, if you have any more questions you can comment at the bottom. I suggest you read through this post (and probably the comments too) before you actually start so you know what’s ahead of you.
Do you need to be apart of the Apple Developers program?
Nope.
Do you need to pay $100 to Apple to run YOUR app on YOUR phone?
Nope.
Do you have to have a mac?
Nope.
What about hackintosh?
Nope.
Does this cost money?
Nope.
Do you have to jailbreak your iphone?
Yep.
What do I have to know to do this?
Some basic unix commands, how to ssh, how to ctrl-c ctrl-v (copy/paste), maybe some basic objective C knowledge (you can learn as you go, that’s what I’m doing), how to use google.
What do I need to do this?
An ipod touch/iphone, (jailbroken, this guide is for iphone OS 3), a wireless AP, a computer on the same network as your iphone. (actually not required, I think you could do this whole thing without a computer except the jailbreaking part).
Here’s the general idea:
1. Jailbreak iphone.
2. Install open toolchain, get headers, get various Cydia packages
3. SSH into your iphone, code an app, compile and install the app, test it!
4. There is no step 4, it’s that easy.
5. This is the 5th and final step. On this step you learn Objective C, the iphone APIs, how to code, whatever. (Just make apps!).
Ok, so what’s the catch?
There is no catch!
Ok, well maybe some minor drawbacks, but nothing too big. You can’t use .nib or .xib files created by interface builder on a mac, because the open toolchain can’t use/compile them. This is no big deal, really. It just requires a bit more coding, and some people that develop with the Apple SDK do this anyway. You’ll be fine.
The other “catch” is that you can’t submit apps to the app store. But, you can to a Cydia repo!
Ok, lets get started. But first, so we don’t have a holdup waiting for the super huge download later, go a head and download the latest Apple SDK. We will extract the headers out of this. (Or, you can find them on the internet somewhere – it is technically illegal to host them, but you can download them from Apple legally. This is what I did.)
1. Jailbreak your iphone.
Sorry, I’m not going to tell you how to do this, it’s on the internet. Use google. I assume you’ve already done this.
2. Install stuff from Cydia
Here we start getting to the good stuff. You may be wondering, “How the heck is this going to work!?” and the answer is simple: hackers!!
<rant>
That is, hackers in the intended use of the word (see this). Not the people that go around and “hack” into your computer and steal passwords. These people have extended the functionality of the iPhone, and are willing to share it with you for free.
Why? Because that’s the way the iphone should be. Your iPhone is a full blown computer, and it can and should be used that way. You should be able to get to the command line. You should be able to write your own apps. You should be able to customize the way your computer phone looks. You should be able to ssh into your phone. You should be able to write a better Stocks app, a better email app, a better SMS app, a better tethering app, a better camera app, a video camera app (period), a better browser app, a better maps app, a better settings app, and even YOUR OWN app, for free. If there’s an app, you should be able to make it, and make it better. And, for free. After all, it’s your phone. It’s not Apple’s phone, it’s not AT&T’s phone, it’s your own darn phone. Do what you want with it.
</rant>
(edit) Thanks to “ziffer” for reminding me that another package needs to be installed before the full iPhone 2.0 toolchain can be installed. It is called “fake-libgcc”, as an “official” libgcc package has not been released for 3.0, but the toolchain can still be installed on the iphone anyway. (I found this here: http://modmyi.com/forums/iphone-ipod-touch-sdk-development-discussion/655111-compiling-iphone-3-0-a.html#post4898409)
I have uploaded a mirror of the package on my site, just in case the original creator moves/removes the package from his dropbox. You can install this package by running the following commands (on the iphone, either ssh into it or use the mobile terminal, you must be logged in as root):
wget http://aaronash.com/iphone/fake-libgcc_1.0_iphoneos-arm.deb
dpkg -i fake-libgcc_1.0_iphoneos-arm.deb
If you type the first command in and it says “command not found”, then you don’t have wget installed. Search for it on Cydia. So anyway after you have installed “fake-libgcc”, open up Cydia and download the following packages:
- iPhone 2.0 Toolchain – This is the important one!! MobileTerminal (if you haven’t already)
OpenSSH </LI>
Those 3 packages alone should get you going. After you install the iPhone 2.0 Toolchain package, there will be many more packages installed because the open toolchain depends on them. The Mobile Terminal is not technically needed, but it can be quite useful.
Here are some packages that are handy for development, though not necessarily required:
- Vi IMproved nano wget adv-cmds shell-cmds top Tape Archive </LI>
You should now be able to compile a basic C program, so lets check it out and make sure! (This is a fun part, but not required).
- SSH into your iphone. If you’re on Windows I recommend PuTTy. This is most easily done by going on the same WiFi network as your iphone and find it’s IP address by typing ifconfig in the Mobile Terminal (if you have that package installed) or by simply loading up SBSettings (if you don’t have it installed, I would HIGHLY recommend it, open it by sliding your finger accross the little bar on top) and looking at the WiFi ip address you see there. Also, you can find it by going to Settings > WiFi > YourSSIDName (tap the blue arrow) and that screen will show it. The first ssh might take a bit because the iphone is generating some crypto keys and it’s a tad bit on the slow side. Login as root, the default password is ‘alpine’. Change it using the passwd command. After you’ve ssh’d into it, type these commands:
echo ‘int main(int argc, char *argv[]) { printf(“Hello, iPhone!\n”); return 0; }’ > test.c
gcc test.c -o test
ldid -S test
./test
After you run the “gcc test.c -o test” test part it may say something like:
test.c: In function ‘main’:
test.c:2: warning: incompatible implicit declaration of built-in function ‘printf’
But this is ok, it still works for some reason. (It should, it does on mine).”
After you run ./test it should print out “Hello, iPhone!”. Congrats! This is exactly what we want. You just compiled a C program ON your iPhone. Now THAT is cool stuff.
(If you had some weird problem, it may have been because you copied and pasted it. If it doesn’t work type it up by hand into the terminal and you shouldn’t have any problems).
That’s it! You have gcc working on your iphone. Now you’re ready for a native Objective C app, or code in normal C. </LI>
Since we’re still technically on step two “Install open toolchain, get headers, get various Cydia packages” we might as well go ahead and grab the headers. This part isn’t so much fun, unless you find somewhere that they’ve already been ripped and uploaded (hint hint). Otherwise, go download the Official Apple SDK (it’s like, 2GB), and save it somewhere. Also install 7-zip. Then open it with 7-zip and keep clicking until you find where they are, check out this post if you’re going to do this manually. (Also, you can check out this).
3. SSH into your iphone, code an app, compile and install the app (this is done on the phone itself), test it!
- SSH into your phone. Also, for easy file transfer, you probably want to use something like WinSCP. It’s a great program, I’d recommend using it. Download our Hello World program code, here: http://aaronash.com/iphone/HelloWorld.zip Unzip it, (you can use 7-zip) and then drag/drop it to your iphone. I keep all my code in /var/root/Code, it’s a good place to keep everything. In your SSH session (or even on the mobile terminal) cd into the directory you copied the code to. “cd /var/root/Code” Type “make”. Type “make install”. Wait for Springboard to reboot. Test the app! </LI>
If it works, great! You just compiled an app on your iphone, for free. How dare you.
4. There is no step 4, it’s that easy.
Actually there is a step 4, and that is to remember everything you did, backup your work, tell someone else how to do it, and take a break.
5. This is the 5th and final step. On this step you learn Objective C, the iphone APIs, how to code, whatever. (Just make apps!).
Self explanatory, I hope you’ve made it this far and you can start coding for your iPhone. If you have any problems, just use google or post here. Good luck!
</DIV>
refer :http://blog.aaronash.com/?p=15
Hiç yorum yok:
Yorum Gönder