Theos 制作插件流程
2017-06-22 本文已影响167人
24K_纯帅
Theos 安装流程
- 在安装的过程中, 也算踩了不少小坑, 所以这里做个记录, 以后再次安装也可以进行对比和避免再次踩坑.
- 安装
Theos
必须先装Xcode
的command line tools
, 一般只要你安装了Xcode
打开过一次, 应该就会自动提示你安装了. - 安装多个
Xcode
的坑, 这个坑我自己没有遇到, 但是书上有提到, 就做个记录. 在安装了多个Xcode
的情况下, 需要使用xcode-select
命令指定一个活动Xcode
,命令如下:
sudo xcode-select -s /Applications/Xcode8.app/Contents/Developer
- 开始安装
Theos
, 从 Github 上下载Theos
, 命令如下:
// 创建临时的环境变量
export THEOS=/opt/theos
// clone 项目到/opt/theos目录下
sudo git clone git://github.com/DHowett/theos.git $THEOS
/*
上面这个命令是书上写的命令, 但是发现貌似这样下载不会把依赖下载下载, 所以建议用下面这个命令
因为我在后面打包时, 会出现 ==> Error: The vendor/include and/or vendor/lib directories are missing. Please run `git submodule update --init --recursive` in your Theos directory. More information: https://github.com/theos/theos/wiki/Installation.
后来我在opt/theos目录下, 用 git submodule update --init --recursive 这个命令才解决无法使用make命令打包的问题
*/
git clone --recursive git://github.com/DHowett/theos.git $THEOS
- 至此,
Theos
安装完成了
配置ldid
-
ldid
是专门用来签名iOS可执行文件的工具,用以 在越狱iOS中取代Xcode
自带的codesign, 可以从 http://joedj.net/ldid 下载, 然后放到opt/theos/bin
目录下, 然后赋予它可执行权限:
sudo chmod 777 /opt/theos/bin/ldid
配置CydiaSubstrate
- 由于
Theos
中 没有绑定Substrate
库,所以需要手动将Substrate
配置到Theos
环境中. - 书上在这一步时说的是需要运行
Theos
的自动化配置脚本, 但是最新版的Theos
已经没有这个脚本, 所以运行脚本这一步可以跳过. 但是CydiaSubstrate还是得从越狱手机上导出来. - 从越狱设备的
/Library/Frameworks/CydiaSubstrate.framework
下把CydiaSubstrate
导出到电脑上, 并且将其重新命名为libsubstrate.dylib
放到/opt/theos/lib/libsubstrate.dylib
中, 如果这里有文件直接替换即可
配置dpkg-deb
- deb是越狱开发安装包的标准格式,
dpkg-deb
是 一个用于操作deb文件的工具,有了这个工具,Theos 才能正确地把工程打包成为deb文件 - 使用迅雷直接添加该链接https://raw.githubusercontent.com/DHowett/dm.pl/master/dm.pl 下载, 下载完更名为
dpkg-deb
, 然后放到/opt/theos/bin/
下, 并重新赋予权限:
sudo chmod 777 /opt/theos/bin/dpkg-deb
自此就全部操作完成, 可以开始用 Theos
开发插件了
创建工程
- 随便切换到自己任意的工作目录下, 使用以下命令创建工程:
// $THEOS 是一开始设置好的环境变量
// test 是工程名
$THEOS/bin/nic.pl test - New Instance Creator
- 这时终端会提示让你选择一个想要创建的模板:
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
Choose a Template (required): 11
- 因为我们这里主要是做tweak, 所以选择第11个
- 选完后会让我们输入一些列tweak的工程名称, 还有deb包的名字, 还有作者, tweak作用对象的bundle identifier, 例如
com.apple.springboard
, 最后就是tweak安装完成后需要重启的应用, 以进程名表示, 例如SpringBoard
. - 使用
make
编译, 在tweak目录下使用该命令编译:
> Making all for tweak test…
==> Preprocessing Tweak.xm…
==> Compiling Tweak.xm (armv7)…
==> Linking tweak test (armv7)…
==> Preprocessing Tweak.xm…
==> Compiling Tweak.xm (arm64)…
==> Linking tweak test (arm64)…
==> Merging tweak test…
==> Signing test…
- 从输出的信息看,Theos完成了预处理、编译、 签名等一系列动作,此时会发现当前目录下多了一个 新的“obj”文件夹
- 打包使用的
make package
命令来自于Theos本身,其实就是先执行make
命令,然后再执行dpkg-deb
命令 -
make package install
使用该命令将deb包安装到越狱设备上, 但是需要先用SSH
连接, 可以在终端使用ssh root@IP
来访问设备