Thursday, January 9, 2014

How to install perl, theos and llvm-clang in iOS for iOS SDK6.1

(1) Install the following packages in Cydia
    APT 0.6 Transitional (and all its dependencies)

(2) If you have previous installation of odcctools, iPhone-gcc, theos and perl, you should first use SSH login shell and remove the packages by using commands
    apt-get remove iphone-gcc odcctools
    apt-get remove perl net.howett.theos

(3) Use SSH login shell commands to install perl & theos & llvm-clang
    apt-get install org.coolstar.cctools org.coolstar.ld64 org.coolstar.llvm-clang
    apt-get install coreutils wget make ldid zip unzip git subversion com.ericasadun.utilities
    cd /var
    git clone git://github.com/coolstar/theos
    wget --no-check-certificate -O org.coolstar.perl.deb 'http://d.pr/f/R0nx+'
    dpkg -i org.coolstar.perl.deb

(4) Download iPhoneOS6.1.sdk.tgz from here

(5) copy iPhoneOS6.1.sdk.tgz to iPhone

(6) Install SDK and additional libraries to sdks under theos

    tar xzvf iPhoneOS6.1.sdk.tgz
    mkdir -p /var/theos/sdks
    mv iPhoneOS6.1.sdk /var/theos/sdks/

# if your device is arm64 (that is iPad Mini 2, iPad Air or iPhone 5s)
    cd /var/theos/makefiles/targets
    ln -s Darwin-arm Darwin-arm64
    cd /var/theos/makefiles/platform
    ln -s Darwin-arm Darwin-arm64

# clone iphoneheaders.git
    cd /var/theos/
    mv include include.bak
    git clone git://github.com/rpetrich/iphoneheaders.git include
    for FILE in include.bak/*.h; do mv $FILE include/; done
    rmdir -fr include.bak/

(7) Create a command line tool project
    cd ~
    /var/theos/bin/nic.pl blocktest

(8) Choose [4.] iphone/tool

(9) Edit blocktest/main.mm like this to test block
main.mm Select all
#include <stdio.h> void EvalFuncOnGrid( double(^block)(float) ) { int i; for ( i = 0; i < 5 ; ++i ) { float x = i * 0.1; printf("%f %f\n", x, block(x)); } } void Caller(void) { float forceConst = 3.445; EvalFuncOnGrid(^(float x){ return 0.5 * forceConst * x * x; }); } int main(void) { Caller(); }


(10) Modify blocktest/Makefile like this
Makefile (Tool) Select all
TARGET := iphone:clang
TARGET_SDK_VERSION := 6.1 TARGET_IPHONEOS_DEPLOYMENT_VERSION := 6.1 ARCHS := armv7 include theos/makefiles/common.mk TOOL_NAME = blocktest blocktest_FILES = main.mm include $(THEOS_MAKE_PATH)/tool.mk

(11) Make and test run

    cd ~/blocktest
    make clean
    make
    ./obj/blocktest

(12) get ilogit for test build package
    cd ~
    wget --no-check-certificate https://dl.dropboxusercontent.com/u/15373/Other/iPhone/ilogit-tweak-ios7-example.tar
    tar -xf ilogit-tweak-ios7-example.tar

    #make symlink
    cd ~/ilogit
    ln -s /var/theos theos


(13) Modify Makefile, like this

Makefile    Select all
TARGET := iphone:clang TARGET_SDK_VERSION := 6.1 TARGET_IPHONEOS_DEPLOYMENT_VERSION = 6.1 ARCHS = armv6 armv7 # test build multiple archs include theos/makefiles/common.mk TWEAK_NAME = iLogIt iLogIt_FILES = Tweak.xm iLogIt_LIBRARIES = substrate
include $(THEOS_MAKE_PATH)/tweak.mk


(14) Test make package

    make clean
    make package


If you need gdb and debugserver for iOS see here