Xcode中可用的iOS OpenDev和命令行的theos
這裏只說OS X (mac)上的環境搭建,其他平臺類似
theos的搭建
theos是環境搭建的基礎,不論是否想用Xcode上工作的OpenDev, 都必須要安裝theos
內容來自於[iphonedevwiki]
內含有OS X , Linux, iphone等平臺的搭建過程
1. 前提條件準備
- 安裝Xcode
- 安裝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. 下載安裝包
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等服務)