Ubuntu 10.04上搭建iPhone开发环境
1. 准备Ubuntu环境
Ubuntu 10.04
sudo apt-get install git-core libxar-dev bison flex patch openssl libbz2-dev libssl-dev autoconf
sudo apt-get install build-essential gnustep gobjc gnustep-make libgnustep-base-dev gnustep-devel uuid
gcc, g++等编译器默认已经安装
sudo apt-get install g++
Ubuntu 10.04 amd64:
在64位系统上,apt-get找不到xar,就从网站上下载xar安装,要先安装依赖文件libxar1, 再安装xar
http://packages.Ubuntu.com/hardy/xar
2.准备SDK和iPhone Fireware文件
2.1
iPhone1,2_3.1.2_7D11_Restore.ipsw
http://appldnld.apple.com.edgesuite.net/content.info.apple.com/iPhone/061-7265.20091008.Xsd32/iPhone1,2_3.1.2_7D11_Restore.ipsw
2.2
iphone_sdk_3.1.2_with_xcode_3.1.4__leopard__9m2809.dmg
3. 准备iphonedevonlinux源代码、SDK和firmware文件
3.1 checkout iphonedevonlinux源代码
$ mkdir -p ~/iPhone/toolchain
$ cd ~/iPhone/toolchain
$ svn checkout http://iphonedevonlinux.googlecode.com/svn/trunk/ ./
目前checkout out的svn版本为revision 83
3.2 拷贝SDK,firmware文件到相应目录
$ mkdir -p ~/iPhone/toolchain/files/firmware
$ mv iphone_sdk_3.1.2_with_xcode_3.1.4__leopard__9m2809.dmg ~/iPhone/toolchain/files/
$ mv iPhone1,2_3.1.2_7D11_Restore.ipsw ~/iPhone/toolchain/files/firmware/
4. 执行toolchain.sh
4.1 sudo ./toolchain.sh headers
4.2 sudo ./toolchain.sh firmware
由于GFW的原因,这一步可能不成功。如果失败了,就手工修改toolchain.sh,直接添加解密firmware的key
修改toolchain.sh如下:
注视掉以下内容:
if [ -z "$DECRYPTION_KEY_SYSTEM" ] ; then
# echo "We need the decryption key for `basename $FW_RESTORE_SYSTEMDISK`."
# echo "I'm going to try to fetch it from $IPHONEWIKI_KEY_URL...."
#
# IPHONEWIKI_KEY_URL=$( wget --quiet -O - $IPHONEWIKI_KEY_URL | awk '
# BEGIN { IGNORECASE = 1; }
# /name="'${DEVICE}'/ { found_phone=1; }
# /.*'${TOOLCHAIN_VERSION}'.*/&& found_phone { found_firmware=1; }
# /.*href=../../.*/&& found_firmware { while(sub(/href=|"/,"", $3));; print $3; exit;}
# ')
#
# DECRYPTION_KEY_SYSTEM=`wget --quiet -O - "http://#www.theiphonewiki.com"$IPHONEWIKI_KEY_URL | awk '
# BEGIN { IGNORECASE = 1; }
# /.*VFDecrypt.*/ { print $3;}
# '`
DECRYPTION_KEY_SYSTEM="a8a886d56011d2d98b190d0a498f6fcac719467047639cd601fd53a4a1d93c24e1b2ddc6"
if [ ! "$DECRYPTION_KEY_SYSTEM" ] ; then
error "Sorry, no decryption key for system partition found!"
exit 1
fi
echo "I found it!"
fi
message_status "Mounting ${FW_RESTORE_SYSTEMDISK}..."
mount_dmg "${TMP_DIR}/${FW_RESTORE_SYSTEMDISK}" "${MNT_DIR}" "${DECRYPTION_KEY_SYSTEM}"
别忘了添加DECRYPTION_KEY_SYSTEM=...这一行
4.3 sudo ./toolchain.sh darwin_sources
4.4 sudo ./toolchain.sh build
在这一步会出错,我遇到两个文件需要修改:
/home/jack/iPhone/toolchain/toolchain/src/cctools/ld64/src/MachOWriterExecutable.hpp:2222: error: ‘sprintf’ was not declared in this scope
/home/jack/iPhone/toolchain/toolchain/src/cctools/ld64/src/Options.cpp:3160: error: ‘fprintf’ was not declared in this scope
查看~/iPhone/toolchain/toolchain/bld/cctools-iphone/make.log文件,找到编译出错的文件,添加下面两行:
#include
#include
然后再次执行 sudo ./toolchain.sh build, 注意在提示是否checkout时,选择"n", patch也选择"n"
如果出现”It seems like the toolchain built!”,说明toolchain build成功。
5. 测试toolchain
5.1 设置PATH、
在~/.bashrc中加入:
PATH=~/iphone/toolchain/toolchain/pre/bin:$PATH
5.2 编译HelloToolchain
cd ~/iPhone/toolchain/app/HelloToolch
执行IP=192.168.1.3 make deploy, 其中IP是iPhone手机的IP地址,前提是已经越狱,并且通过ssh能够进行访问
在手机上可以看到HelloToolchain的应用,点击执行后在手机上显示出“HelloToolchain”
如果编译出错,进行如下处理:
mv ~/iPhone/toolchain/toolchain/sys/System ~/iPhone/toolchain/toolchain/sys/System2mv ~/iPhone/toolchain/toolchain/sys/usr/lib ~/iPhone/toolchain/toolchain/sys/usr/lib2cp ~/iPhone/toolchain/sdks/iPhoneOS3.1.2.sdk/System ~/iPhone/toolchain/toolchain/sys/cp ~/iPhone/toolchain/sdks/iPhoneOS3.1.2.sdk/usr/lib ~/iPhone/toolchain/toolchain/sys/usr/
6. 参考
1. install ldid
You'll need ldid to sign your code, you can get it on the iPhone by doing:
$ sudo apt-get install ldid
Here's how to get it on Linux/OX S:
First, download from saurik's with this:
$ wget http://www.linuxidc.com/system/systemfiles/2011/03/ldid-1.0.610.tgz
Now, Unzip it:
$ tar -zxf ldid-1.0.610.tgz
Move to the result folder:
$ cd ldid-1.0.610
Compile it:
$ g++ -I . -o util/ldid{,.cpp} -x c util/{lookup2,sha1}.c
export CODESIGN_ALLOCATE=.../toolchain/pre/bin/arm-apple-darwin9-codesign_allocate; ldid -S yourlib
关键词:Ubuntu,iPhone
相关阅读
- 05-05ubuntu在vmware下的安装与配置
- 11-30ubuntu 13.04 安装mysql数据库教程
- 11-14Win7和Ubuntu12.04 双系统重装win7引导不见问题的解决方案
- 11-03Ubuntu重装启动失败进入修复grub rescue模式的解决方案
- 07-02用UNetbootin工具制作Ubuntu系统启动U盘
- 06-25ubuntu12.04安装tftp、配置tftp服务 错误解决方案
- 05-30Ubuntu 12.04 安装配置 Tomcat 7.0.40Tomcat 服务器
- 04-04ubuntu下安装了mysql 5 server忘记root密码怎么办?
- 04-04Ubuntu 11.0下配置Web服务器详细教程
- 04-04打破微软垄断笔记本安装Ubuntu9.04教程