среда, 30 декабря 2009 г.

Open iPhone Development on any platform

All further instructions assumes that you have already did your jailbroke(blackra1n,redsn0w - no matter)
  1. Run cydia
  2. Install openSSH to be able to connect to your phone
  3. Install apt 0.7 strict - you will need this package handling utility to install additional libraries without using cydia.
  4. Connect to your phone via ssh(default password will be "alpine" without quotes)

    Example:

    $ ssh root@192.168.1.104
  5. Install essentials

    # apt-get install wget
    # apt-get install vim
  6. You will need libgcc(Thank you Saurik!)
    # cd /tmp
    # wget -c "http://apt.saurik.com/debs/libgcc_4.2-20080410-1-6_iphoneos-arm.deb"
    # dpkg -i libgcc_4.2-20080410-1-6_iphoneos-arm.deb
  7. Now it is toolchain's turn
    apt-get install com.bigboss.20toolchain
Almost done, let's try to compile our first application.
# vim main.c
Example:
#include <stdio.h> int main() {
printf("Hello world!");
return 0;
}
Compile:
gcc main.c -o main
Output:
ld: library not found for -lSystem collect2: ld returned 1 exit status
To get this step done you should copy {libobjc.dylib,libSystem.dylib} files from official iPhone SDK. Put these files into /usr/lib and create links to them.
ln /usr/lib/libSystem.B.dylib /usr/lib/libSystem.dylib ln /usr/lib/libobjc.A.dylib /usr/lib/libobjc.dylib
Now compilation will be successful!
./main Killed!
Oops...No luck... That's because you have not signed your application. iPhone OS have very strict rules to run applications on it. To sign your application you will need a provision profile(remember the story about official development)... Or... Let's say "THANK YOU" to Saurik again:
apt-get install ldid ldid -S main ./main Hello World!
ldid - is a tool that can sign your applications and make them runnable on the iphone.
Let's try with full weight iPhone application!
  1. You will need additional header files which can be found in official SDK or you can download it from here(link from http://antirez.com).
    Copy this folder into your iPhone and then to the /var/inculde
    $ scp -r include-2.0-sdk-ready-for-iphone/ root@192.168.1.104:~/
    # cp -r include-2.0-sdk-ready-for-iphone/* /var/include

  2. To avoid "framework not found" messages:
    ld: framework not found CoreFoundation

    You should copy frameworks folders from the official SDK to your phone.
    # scp -r PrivateFrameworks root@192.168.1.104:~/
    # scp -r Frameworks root@192.168.1.104:~/
    And install them:
    cd Frameworks
    ls | awk -F . '{print "mkdir -p /var/include/"$1";cp -r " $0"/Headers/* /var/include/"$1 ";rm -rf "$0"/Headers" }' | sh
    ls | awk -F . '{print "mkdir -p /System/Library/Frameworks/"$1"."$2";cp -r "$0"/* /System/Library/Frameworks/"$1"."$2}' | sh
    cd ../PrivateFrameworks
    ls | awk -F . '{print "mkdir -p /var/include/"$1";cp -r " $0"/Headers/* /var/include/"$1 ";rm -rf "$0"/Headers" }' | sh
    ls | awk -F . '{print "mkdir -p /System/Library/PrivateFrameworks/"$1"."$2";cp -r "$0"/* /System/Library/PrivateFrameworks/"$1"."$2}' | sh
    cd ../
    rm -rf PrivateFrameworks Frameworks
  3. Now you can download on of the sample applications to start from. You can find one at http://antirez.com or http://blog.aaronash.com

Комментариев нет: