Welcome, guest ( Login )

Create new page

Invite people

WikiHome » iPhoneHacking » HowToBuildObjCApps

HowToBuildObjCApps

Version 26, changed by admin. 08/04/2007.   Show version history

How To: Building ObjC Apps on the iPhone

By kroo, tested and debugged by darkten

product of the iphone-uikit team at irc://irc.osx86.hu/iphone-uikit

Before you start:

Things only work with an intel mac right now.  Make sure that you are using 10.4.10, and that you have installed the Apple Developer tools.

Step 1: Download some stuff

Download these things:
 Name (with link)
unarchive it, then put it here
 phonedmg /Users/[your username]/phonedmg
 Software Restore Image
 /Users/[your username]/phonedmg/[files go here]
 Macports [just open the dmg, install it, then remove this file if you want]
 anything else...?
 

Step 2: Breaking into your iphone

(taken mostly from http://www.hacktheiphone.com/iphone_first_ten_steps_to_modding.html )
  1. Quit iTunes
  2. go to the Applications directory, open the Utilities subdir, then double click Terminal
  3. type "killall iTunesHelper" into the terminal window, hit return
  4. type "cd ~/phonedmg" hit return
  5. Pray, hide in a corner, cross your fingers, or whatever you do for increased luck.
  6. type "./jailbreak", hit return, then follow the instructions
  7. if that didn't work, try once more
  8. if that didn't work, join irc.osx86.hu/iphone-uikit (or iphone-shell), and ask around
  9. type "./iPhoneInterface", hit return
  10. if all goes well, you should see a shell prompt (a line with "#" at the beginning)
  11. type "ls", you should see lots of different files -- especially System, usr, and bin directories

Step 2: Installing SSH

(taken mostly from NerveGas's SSH Tutorial at http://iphone.natetrue.com/)
  1. [TODO, put dropbearkey into phonedmg folder]
  2. Make sure you have a terminal window open, and that you are in the phonedmg folder (type "cd ~/phonedmg" if you are not, or are unsure).
  3. Open iPhoneInterface, and make sure you can still see lots of files when you type 'ls'
  4. Run these commands one at a time, and make sure nothing happens after you run them (except that a new "# " prompt appears)
    mkdir /etc/dropbear
cd /etc/dropbear
putfile dropbear_rsa_host_key
putfile dropbear_dss_host_key
cd /bin
putfile chmod
putfile sh
cd /usr/bin

--- TODO list lots of binaries to put here
putfile chmod
putfile bash
putfile ls
--- End TODO

putfile dropbear       
cd /usr/sbin
    putfile update
cd /System/Library/LaunchDaemons
putfile com.apple.update.plist
putfile au.asn.ucc.matt.dropbear.plist
exit
  1. SSH should now be installed! reboot your iphone twice (just by holding down the power button, then sliding to shutdown), then run
    ssh root@[your iphone ip]
  1. Clean up after yourself.  In the terminal window (should not be running iphoneinterface anymore), run:
    mv com.apple.update.plist.orig com.apple.update.plist
mv update.orig update
  1. now run iphoneinterface again:
    ./iPhoneInterface
cd /System/Library/LaunchDaemons/
putfile com.apple.update.plist
cd /usr/sbin
putfile update

Step 3: building toolchain

Congrats, you have made it this far.  This is by far the trickiest section, with lots o' hacks:
  1. Make a dedicated directory for your toolchain, put it at /Users/[yourusername]/toolchain/ or ~/toolchain for short.
  2. Make a dedicated directory for the unencrypted "heavenly" image -- at /Users/[yourusername]/toolchain/heavenly/ or ~/toolchain/heavenly/ for short
  3. open a terminal window, type "cd ~/toolchain", then type (or actually, please copy and paste): (Note: Decrypting the iPhone firmware image may be illegal in your country. Check with local laws before proceeding)
    ./vfdecrypt -i 694-5262-39.dmg -o decrypted.dmg -k 28c909fc6d322fa18940f03279d70880e59a4507998347c70d5b8ca7ef090ecccc15e82d
  1. next type "open decrypted.dmg"
  2. a terminal window should pop up. close it, and return to the terminal window. type
    sudo cp -R /Volumes/Heavenly1A543a.UserBundle/* ~/toolchain/heavenly/
  1. we need to install libstreams.
    sudo port install libstreams
  1. Next, we need to get the latest copy of the toolchain.
    cd ~/toolchain/
svn checkout svn://svn.berlios.de/iphone-binutils/trunk
  1. if the second command returns immediately with "command not found", download and install it [link]? otherwise,
  2. Wait until svn is done
  3. now type
    cd trunk/
./configure --with-heavenly=/Users/[your username]/toolchain/heavenly/
  1. Theres a problem with the makefile -- change line 34 to read:
    cd llvm-2.0 && $(MAKE) ENABLE_OPTIMIZED=1 install
  1. wait for configure to complete, then make, and type your password at the prompt:
    sudo make
  1. this installs lots of stuff into the /Developer/SDKs/iPhone/
  2. if you get errors during the compilation of llvm-2.0, try copying /usr/include/assert.h into llvm-2.0/include/ (Props to lednerk for finding a fix for this one)
  3. add the binaries to your path:
    echo "export PATH=$PATH:/Developer/SDKs/iPhone/bin/" >> ~/.profile; source ~/.profile
  1. we need to do another round of downloading:
 Name (with link)
unarchive it, then put it here
Hello application
 /Users/[your username]/toolchain/helloapp/
 UITextTraitsClientProtocol.h /Developer/SDKs/iPhone/include/UIKit/
  1. we need to patch a few header files:
    patch < /Developer/SDKs/iPhone/include/CarbonCore/MachineExceptions.h.diff
patch < /Developer/SDKs/iPhone/include/CarbonCore/fp.h.diff
  1. When it asks which file to apply it to, paste in: "/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/MachineExceptions.h" for the first one and "/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/fp.h" for the second one.

  1. you need to change /usr/include/machine/limits.h on line 5, /usr/include/machine/signal.h on line 26, and /usr/include/machine/_limits.h on line 25 so that it reads
    #if defined (__ppc__) || defined (__ppc64__) || defined (__arm__)
  1. edit line 315 of /usr/include/sys/cdefs.h to read:
    #if defined(__ppc__) || defined (__arm__)
  1. oh, and another thing the svn doesnt follow any order whatsoever -- to fix this for them, we kindly need to put libarmfp where it belongs:
    sudo cp /Developer/SDKs/iPhone/lib/libarmfp.dylib /Developer/SDKs/iPhone/heavenly/usr/lib/
  1. a recent SVN commit just broke everything. you need to fix it: (all in the /Developer/SDKs/iPhone/include/UIKit/)
    1. Symlink your CoreGraphics/include dir to your include path:
    sudo ln -s /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Headers /Developer/SDKs/iPhone/include/CoreGraphics
    1. UIPushButton needs to include CDStructures.h. put #include <UIKit/CDStructures.h> at the top.
  1. finally, try making the hello application!
    cd ~/toolchain/helloapp/
make

Attachments (3)

  File By Size Attached Ver.
 phonedmg11.tar.gz admin 2M 07/29/2007 2 Delete attachment
 UIKit.h admin 98B 07/30/2007 1 Delete attachment
 phonedmg12.tar.gz admin 2M 07/30/2007 1 Delete attachment