安装Theos和Monkeydev

认真玩越狱一年了,想学习开发插件,总结一下工具的安装

Theos

macOS官方安装教程

我更推荐用MonkeyDev写的安装方法

1
sudo git clone --recursive https://github.com/theos/theos.git /opt/theos

在用户目录下的.zprofile文件内添加如下内容

1
2
export THEOS=/opt/theos
export PATH=$THEOS/bin:$PATH

在 Terminal 中运行

1
nic.pl

有如下提示即为成功

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 ~  nic.pl                                                                  ✔
NIC 2.0 - New Instance Creator
------------------------------
[1.] iphone/activator_event
[2.] iphone/activator_listener
[3.] iphone/application
[4.] iphone/application_swift
[5.] iphone/application_swiftui
[6.] iphone/control_center_module-11up
[7.] iphone/cydget
[8.] iphone/flipswitch_switch
[9.] iphone/framework
[10.] iphone/library
[11.] iphone/notification_center_widget
[12.] iphone/notification_center_widget-7up
[13.] iphone/null
[14.] iphone/preference_bundle
[15.] iphone/preference_bundle_swift
[16.] iphone/theme
[17.] iphone/tool
[18.] iphone/tool_swift
[19.] iphone/tweak
[20.] iphone/tweak_swift
[21.] iphone/tweak_with_simple_preferences
[22.] iphone/xpc_service
[23.] iphone/xpc_service_modern
Choose a Template (required):

MonkeyDev

下载

1
sudo git clone https://github.com/AloneMonkey/MonkeyDev.git /opt/MonkeyDev

安装

1
2
cd MonkeyDev/bin
sudo ./md-install

报错: File /xxx/IDEiOSSupportCore.ideplugin/xxx/Embedded-Device.xcspec not found

macOS 14.5报错如下

bin sudo bash md-install
1
2
3
➜  bin sudo ./md-install
...
File /Applications/Xcode.app/Contents/PlugIns/IDEiOSSupportCore.ideplugin/Contents/Resources/Embedded-Device.xcspec not found
  • 原因:Xcode 13+之后,部分路径变化了,所以找不到对应路径
  • 解决办法:从Xcode中搜索到Embedded-Device.xcspec的实际位置,然后拷贝到报错的路径(如果不存在,先创建对应目录)即可
  • 具体步骤

(1)找到Embedded-Device.xcspec

1
2
3
➜  ~ cd /Applications/Xcode.app/Contents
➜ Contents find . -name Embedded-Device.xcspec
./Developer/Library/Xcode/Plug-ins/XCBSpecifications.ideplugin/Contents/Resources/Embedded-Device.xcspec

找到:

  • /Applications/Xcode.app/Contents/Developer/Library/Xcode/Plug-ins/XCBSpecifications.ideplugin/Contents/Resources/Embedded-Device.xcspec

(2)拷贝到报错目录

先新建该目录

1
sudo mkdir -p /Applications/Xcode.app/Contents/PlugIns/IDEiOSSupportCore.ideplugin/Contents/Resources/

再去拷贝:

1
sudo cp /Applications/Xcode.app/Contents/Developer/Library/Xcode/Plug-ins/XCBSpecifications.ideplugin/Contents/Resources/Embedded-Device.xcspec /Applications/Xcode.app/Contents/PlugIns/IDEiOSSupportCore.ideplugin/Contents/Resources/

确认文件的确存在:

1
2
3
➜  PlugIns ll /Applications/Xcode.app/Contents/PlugIns/IDEiOSSupportCore.ideplugin/Contents/Resources/
total 8
-rw-r--r--@ 1 root wheel 437B 10 12 15:34 Embedded-Device.xcspec

最后重新去操作:

1
sudo ./md-install

报错:File /xxx/Specifications/MacOSX Package Types.xcspec not found

报错如下

1
2
3
  bin sudo bash md-install
...
File /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Specifications/MacOSX Package Types.xcspec not found

解决办法:

然后继续去操作:

  • 【推荐】方法1:使用软链接

    1
    sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/PrivatePlugIns/IDEOSXSupportCore.ideplugin/Contents/Resources /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Specifications
  • 方法2:(修改md-install脚本)改动路径

    修改/opt/MonkeyDev/bin/md-install

    修改路径,改为:

    1
    2
    3
    4
    5
    6
    # macosxSDKSpecificationsPath=$macosSdkPlatformPath/Developer/Library/Xcode/Specifications
    # packageTypesForMacOSXPath="$macosxSDKSpecificationsPath/MacOSX Package Types.xcspec"
    # productTypesForMacOSXPath="$macosxSDKSpecificationsPath/MacOSX Product Types.xcspec"
    macosxSDKSpecificationsPath=$macosSdkPlatformPath/Developer/Library/Xcode/PrivatePlugIns
    packageTypesForMacOSXPath="$macosxSDKSpecificationsPath/IDEOSXSupportCore.ideplugin/Contents/Resources/MacOSX Package Types.xcspec"
    productTypesForMacOSXPath="$macosxSDKSpecificationsPath/IDEOSXSupportCore.ideplugin/Contents/Resources/MacOSX Product Types.xcspec"

    最后重新运行:

    1
    sudo ./md-install

    即可

以上两种错误都是来自我遇到的报错,并且解决方法来自于这里,原文里面还有其他的解决方法,我就不贴了

有佬 fork 了 MonkeyDev 并且适配了 Rootless,在现在这个环境,推荐使用这个,按照readme的安装就好

https://github.com/BigCatGit/MonkeyDev

其他问题

解决 Xcode 报 library not found for -lstdc++ 问题

https://github.com/devdawei/libstdc-

视频教程

视频最后的编译可以试一试,安装还是参考上文

https://www.bilibili.com/video/BV1ovejeXEUU?t=296