iOS 越狱开发环境搭建

来源:互联网 发布:js文件 编辑:程序博客网 时间:2024/05/16 07:51

Xcode中可用的iOS OpenDev和命令行的theos

这里只说OS X (mac)上的环境搭建,其他平台类似


theos的搭建

theos是环境搭建的基础,不论是否想用Xcode上工作的OpenDev, 都必须要安装theos

内容来自于[iphonedevwiki]
内含有OS X , Linux, iphone等平台的搭建过程

1. 前提条件准备

  1. 安装Xcode
  2. 安装ldid , 终端中$: brew install ldid
brew的安装请参考homebrew的安装,一个很方便的软件管理软件,类似于apt, yum等… —[homebrew]

2.安装

1 >. 首先配置theos目录,如指定为/opt/theos (mkdir /opt/theos)

export THEOS=/opt/theos

2 >. 下载theos到指定的$THEOS目录中

git clone –recursive git://github.com/DHowett/theos.git $THEOS

3 >. 将theos环境配置到系统路径中

export THEOS=/opt/theos
export PATH=$THEOS/bin:$PATH
export THEOS_DEVICE_IP=192.168.1.101 THEOS_DEVICE_PORT=22
/*这里的DEVICE_IP是iphone与机器同一网段下的相应ip, PORT为ssh端口号*/
将这三行写入~/.bash_profile 或/etc/bashrc中

4 >. 取得Substrate

wget http://apt.saurik.com/debs/mobilesubstrate_0.9.6011_iphoneos-arm.deb
mkdir substrate
dpkg-deb -x mobilesubstrate_*_iphoneos-arm.deb substrate
mv substrate/Library/Frameworks/CydiaSubstrate.framework/CydiaSubstrate $THEOS/lib/libsubstrate.dylib
mv substrate/Library/Frameworks/CydiaSubstrate.framework/Headers/CydiaSubstrate.h $THEOS/include/substrate.h

这样,theos就算正式安装完成,可以进行开发测试


Xcode可用的iOS OpenDev搭建

1. 下载安装包

http://iosopendev.com/download/

2. 安装时遇到错误时

常见错误及安装错误时日志显示方法: [Wiki地址]
下载附件:
[点击下载]

第一次提示错误:
/Application/Xcode/Content/Developer/Platforms/IphoneOS.platform/Developer/Library/Xcode/Specifications: No such file or Directory.

mkdir -p /Application/Xcode/Content/Developer/Platforms/IphoneOS.platform/Developer/Library/Xcode/Specification
将附件中的iPhoneOS*四个文件拷贝到/Applicaiton/Xcode/…./Specificaitons/下

第二次提示错:
/Application/Xcode/Content/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Xcode/Specifications: No such file or Directory.

mkdir -p /Application/Xcode/Content/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Xcode/Specifications

第三次提示错误
`/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/: No such file or Directory`

mkdir -p /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/
将附件中的iPhone Simulator *四个文件拷贝到/Applicaiton/Xcode/…./Specificaitons/下

3. Xcode中编译时遇到错误

如 HBLogError未定义的标识符等,说明theos版本和iOS OpenDev版本不匹配,可以下载旧版theos来结局
git clone -b stableversion https://github.com/haorenqq/theos/ $THEOS


theos测试编译

1. 前提条件

我的iphone和电脑连接了同一路由器, iPhone IP:192.168.1.105

2. 建立一个项目

1 >. 适用模版建立项目

# nic.pl

NIC 2.0 - New Instance Creator
——————————
[1.] iphone/activator_event
[2.] iphone/application_modern
[3.] iphone/cydget
[4.] iphone/flipswitch_switch
[5.] iphone/framework
[6.] iphone/ios7_notification_center_widget
[7.] iphone/library
[8.] iphone/notification_center_widget
[9.] iphone/preference_bundle_modern
[10.] iphone/tool
[11.] iphone/tweak
Choose a Template (required): I

输入11, 输入后续信息

2 >. 修改项目配置文件

修改Makefile文件, 第一行前加入

export ARCHS = arm64 {我的机器为arm64}

修改之前配置的export THEOS_DEVICE_IP=192.168.1.101

export THEOS_DEVICE_IP=192.168.1.105 {我的iPhone IP : 192.168.1.105}

3 >. 添加代码

修改Tweak.xm文件,删除所有内容,写入以下代码:

#import <SpringBoard/SpringBoard.h>%hook SpringBoard-(void)applicationDidFinishLaunching:(id)application {    %orig;    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Welcome"        message:@"Hello world,你好世界"        delegate:nil        cancelButtonTitle:@"确定"        otherButtonTitles:nil];    [alert show];    [alert release];}%end

4 >. 编译

make

5 >. 打包安装

make package install

期间会让输入iPhone的root密码 (iPhone事先需要安装ssh等服务)

0 0