ldid安装
ldid可以在http://joedj.net/ldid 下载
复制到/opt/theos/bin
里面
执行sudo chmod 777 /opt/theos/bin/ldid
提升权限
libsubstrate.dylib
这个需要用到手机助手的文件管理功能把/Library/Frameworks/CydiaSubstrate.framework/CydiaSubstrate
复制出来
改名为libsubstrate.dylib
,然后放到/opt/theos/lib
中。
dkpg安装
这个命令需要安装MacPorts,选择对应的系统下下来安装即可。
sudo port install dpkg
theos安装
cd /opt
$ git clone --recursive https://github.com/theos/theos.git
环境配置
~./bash_profile
中加入下面的代码,没有这文件就创建一个
export THEOS=/opt/theos
export PATH=/opt/theos/bin/:$PATH
测试一下
cd到准备放工程的目录执行/opt/theos/bin/nic.pl
能输入输出下面的选项,theos就配置好了。
$ /opt/theos/bin/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
[12.] iphone/xpc_service
运行
选择iphone/tweak
这个选项,输入11回车。
会让你输入工程名,bundleId,目标bundleId等。这里呢,我们只是要运行一下demo测试环境搭建是否成功,把工程名输了,其他直接回车就行了,都是有默认的。
打开工程目录下的Makefile
include $(THEOS)/makefiles/common.mk
TWEAK_NAME = firstdemo
firstdemo_FILES = Tweak.xm
include $(THEOS_MAKE_PATH)/tweak.mk
THEOS_DEVICE_IP = 192.168.2.157 #手机的ip地址
iOSRE_FRAMEWORKS=UIKit Foundation #导入的库
ARCHS = arm64 #手机是64位还是32位
after-install::
install.exec "killall -9 SpringBoard" #在安装成功后杀掉SpringBoard,会从新启动以加载我们的插件
打开工程目录下的Tweak.xm
文件
粘贴下面的代码
#import <UIKit/UIKit.h>
#import <SpringBoard/SpringBoard.h>
%hook SBLockScreenDateViewController
- (void)setCustomSubtitleText:(id)arg1 withColor:(id)arg2
{
NSString *str = @"锁屏界面的日期文字变成了这段话!";
%orig(str, arg2);
}
%end
最后make
编译make package
打包make install
安装,过程会叫你输入2次ssh密码,全部成功的话,你就会看到SpringBoard正在重启。重启之后锁屏界面的日期,变成了我们自定义的字符串。
如果提示THEOS_DEVICE_IP错误之类的就先输入export THEOS_DEVICE_IP=手机的ip地址
theos的升级
git submodule update –recursive
注意
在一些老板的安装方法中有sudo /opt/theos/bin/bootstrap.sh substrate
,现在可以不用管了。