Skip to content

Commit 3ccd8f8

Browse files
authored
Merge branch 'theos:master' into features2
2 parents bcadb07 + e2dcd16 commit 3ccd8f8

File tree

10 files changed

+161
-29
lines changed

10 files changed

+161
-29
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ source "https://rubygems.org"
33
gem "jekyll", "~> 3.9.0"
44

55
# Needed for macOS ARM
6-
gem "nokogiri", "~> 1.14.3"
6+
gem "nokogiri", "~> 1.15.6"
77

88
# Needed to unbreak jekyll-assets
99
gem "sprockets", "~> 3.7"

Gemfile.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ GEM
7474
rb-inotify (~> 0.9, >= 0.9.10)
7575
mercenary (0.3.6)
7676
minitest (5.14.4)
77-
nokogiri (1.14.3-x86_64-darwin)
77+
nokogiri (1.15.6-x86_64-darwin)
7878
racc (~> 1.4)
79-
nokogiri (1.14.3-x86_64-linux)
79+
nokogiri (1.15.6-x86_64-linux)
8080
racc (~> 1.4)
8181
pathutil (0.16.2)
8282
forwardable-extended (~> 2.6)
8383
public_suffix (4.0.6)
84-
racc (1.6.2)
85-
rack (2.2.6.4)
84+
racc (1.7.3)
85+
rack (2.2.8.1)
8686
rb-fsevent (0.11.0)
8787
rb-inotify (0.10.1)
8888
ffi (~> 1.0)
@@ -114,7 +114,7 @@ DEPENDENCIES
114114
jekyll-seo-tag
115115
jekyll-sitemap
116116
kramdown-parser-gfm (~> 1.1.0)
117-
nokogiri (~> 1.14.3)
117+
nokogiri (~> 1.15.6)
118118
sprockets (~> 3.7)
119119

120120
BUNDLED WITH

_data/docs_sidebar.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
- title: Usage
1717
list:
18+
- title: Concepts
19+
link: /docs/Concepts.html
1820
- title: Configuration
1921
link: /docs/Configuration.html
2022
- title: Commands
@@ -32,6 +34,8 @@
3234
link: /docs/dm.pl.html
3335
- title: Swift
3436
link: /docs/Swift.html
37+
- title: Modules
38+
link: /docs/Modules.html
3539

3640
- title: Tweak Development
3741
list:
@@ -73,10 +77,12 @@
7377

7478
- title: See also
7579
list:
80+
- title: The Apple Wiki
81+
link: https://theapplewiki.com/
7682
- title: iPhone Dev Wiki
7783
link: https://iphonedev.wiki/
7884
- title: /r/jailbreakdevelopers
7985
link: https://www.reddit.com/r/jailbreakdevelopers
80-
- title: theos-ref
86+
- title: theos-ref (legacy docs)
8187
link: https://github.com/theiostream/theos-ref
8288

docs/Concepts.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
title: Concepts
3+
layout: docs
4+
---
5+
6+
#### Make
7+
8+
[Make](https://www.gnu.org/software/make/) is a language used to outline the procedure for a program's creation. The steps are written in Makefiles which are then read by `make` and used to route your project files to tools such as `clang` or `ld` via rules. Theos relies on a [collection of such Makefiles](https://github.com/theos/theos/tree/master/makefiles) to build and package your project. While this allows for significant configuration, the interaction between the various Makefiles severely limits the speed from `make` invocation to build completion.
9+
10+
#### Logos
11+
12+
[Logos](https://github.com/theos/logos) is a preprocessor written by the Theos team to simplify C-based hooking. This "hooking" is technically swizziling, which is the process of replacing a method/function's implementation at runtime. Logos translates simple statements such as `%hook` into the equivalent [MobileSubstate](http://www.cydiasubstrate.com/api/c/MSHookMessageEx/), [libhooker](https://libhooker.com/docs/), or [internal](https://developer.apple.com/documentation/objectivec/objective-c_runtime?language=objc) (i.e., ObjC Runtime) hooking API. Logos syntax is converted to these APIs during the preprocessing of your [Logos files](Logos-File-Extensions).
13+
14+
#### Instance
15+
16+
Theos projects are defined through instances, where each instance is a separate piece of the project. For example, a tweak with a preferences subproject is said to be comprised of two instances. These instances' names are given by the user via the `XXX_NAME` variable, where `XXX` is the project type (e.g., tool, tweak, etc). Each instance is built separately and then combined, if specified, in staging (see below).
17+
18+
#### Objects
19+
20+
When your project files (e.g., .c, .m, .x, etc) are compiled, they are converted into object files (.o). These files reside in `THEOS_OBJ_DIR` along with a number of other files. The object directory is configured as such:
21+
22+
```
23+
.theos/
24+
obj/
25+
$(THEOS_SCHEMA)/
26+
$(THEOS_CURRENT_ARCH)/
27+
$(THEOS_CURRENT_INSTANCE)
28+
```
29+
30+
If a schema is configured, Theos will place the object files within an aptly named subdirectory in order to differentiate between possible schema builds. If a `release` schema is specified, the files will be placed within the object directory itself and not a schema-based subdirectory. Within said directory, there will be any number of additional subdirectories for the specified architecture(s) your project is built for (e.g., armv7, arm64, arm64e, etc). Within these directories will be the object files for the given project along with a thin binary built from said objects for the given architecture. Outside of these architecture subdirectories will be a fat binary created from each of the architecture thin binaries via `lipo`. This fat binary is considered the final object.
31+
32+
To solely build objects, run `make` within your project.
33+
34+
#### Staging
35+
36+
Staging is the term given to the two step pre-packaging process comprised of:
37+
38+
1) The creation of the package hierarchy for the chosen project type
39+
40+
2) The placement of the product objects within this structure in preparation for packaging
41+
42+
This staging occurs within the `THEOS_STAGING_DIR` which has a number of potential configurations all of which reside in ```.theos/_/``` by default. If present, the contents of `THEOS_LAYOUT_DIR` are copied into the staging directory along with any resource bundles that may be associated with your project.
43+
44+
If a `THEOS_PACKAGE_SCHEME` containing a `THEOS_PACKAGE_INSTALL_PREFIX` is provided, Theos will create a second stage with the install prefix in `.theos/_tmp/` in order to separate the project type's package structure from the scheme's packaging prefix. The two will be merged prior to packaging.
45+
46+
To build and complete staging without packaging, run `make stage` within your project.

docs/Configuration.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,20 @@ Such rule names include:
5050
- `after-$(THEOS_CURRENT_INSTANCE)-all`
5151
- `internal-$(_THEOS_CURRENT_TYPE)-all`
5252

53+
## Schemas ("Schemata")
54+
55+
Schemas are a way to manage a group of specific master variables which can have their effect easily turned on or off. An example is the built-in debug schema, which when enabled adds extra options to `CFLAGS`, `LDFLAGS`, and `SWIFTFLAGS`.
56+
57+
They are enabled via `THEOS_SCHEMA`, with a space-separated list of the schemas you'd like to enable.
58+
59+
The schema is described by specifying what variables have their values affected by its enabling. Doing so can be done by declaring a variable with the format `schema.VARIABLE`, so that enabling schema will do changes to a possible query of variable `VARIABLE` (e.g., `DEBUG.CFLAGS`). `VARIABLE` must be used in Theos for the changes to have an effect. See [common.mk](https://github.com/theos/theos/blob/master/makefiles/common.mk) for schema logic implementation.
60+
61+
Example:
62+
```
63+
# Enabling schema1 will add the '-DSCHEMA1ENABLED' additional compiler flags.
64+
schema1.CFLAGS = -DSCHEMA1ENABLED
65+
```
66+
5367
## Utilizing Theos' message commands
5468

5569
Theos utilizes a variety of custom `echo` and `printf` commands which it defines as variables in $THEOS_MAKE_PATH/messages.mk. These can be utilized by users in their own project makefiles if so desired.

docs/Installation-macOS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ All of the commands shown in the following instructions are meant to be run as a
1616
* [Homebrew](https://brew.sh/)
1717
* or [MacPorts](https://www.macports.org/install.php)
1818
* or [Procursus](https://docs.procurs.us/Installation/macOS.html)
19-
* [Xcode](https://itunes.apple.com/us/app/xcode/id497799835?ls=1&mt=12)<sup>1</sup> is mandatory. The Command Line Tools package isn’t sufficient for Theos to work. Xcode includes toolchains for all Apple platforms.
19+
* [Xcode](https://developer.apple.com/download/applications/)<sup>1</sup> is mandatory. The Command Line Tools package isn’t sufficient for Theos to work. Xcode includes toolchains for all Apple platforms.
2020

2121
<sup>
2222
<sup>1</sup> Xcode 5.0 or newer. Xcode 4.4 supported, but only when building for ARMv6 (1st/2nd generation iPhone/iPod touch).

docs/Modules.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
title: Modules
3+
layout: docs
4+
---
5+
6+
## Overview
7+
With Theos being Makefile-based, additional functionality can be provided as-desired through "modules."
8+
9+
Modules are directories containing Makefiles with additional rules, variables, and/or checks that you would like your Theos install to contain. A module structure may look something like
10+
```
11+
my-module/
12+
├── instance
13+
│ ├── framework.mk
14+
│ ├── library.mk
15+
│ └── rules.mk
16+
├── package
17+
│ └── deb.mk
18+
└── package.mk
19+
```
20+
where each `.mk` file contains custom code such as
21+
```makefile
22+
_THEOS_INTERNAL_LDFLAGS += -rpath my/path/here/ -rpath $(THEOS_PACKAGE_INSTALL_PREFIX)/Library/Frameworks -rpath $(THEOS_PACKAGE_INSTALL_PREFIX)/usr/lib
23+
```
24+
25+
## Structure
26+
Modules' structure and the respective `.mk` filenames tell Theos where to add your provided functionality. For example, `my-module/package/deb.mk` tells Theos to add the functionality contained in the module's `deb.mk` file to `$(THEOS_MAKE_PATH)/package/deb.mk`. Providing additional functionality through modules is only supported for specific parts of Theos, however. These parts include:
27+
28+
- `rules.mk`
29+
- `common.mk`
30+
- `package.mk`
31+
- `platform/*.mk`
32+
- `targets/**/*.mk`
33+
- `package/*.mk`
34+
- `install/*.mk`
35+
- `instance/*.mk`
36+
- Except `aggregate.mk`
37+
- `master/*.mk`
38+
39+
Modules should be placed in `$(THEOS_MODULE_PATH)` and are imported by Theos *only* when you explicitly ask them to be through `MODULES = my-module`. The exception to this are package schemes, which can be provided in module form (see `$THEOS/vendor/mod/rootless` for an example). For package schemes, the scheme specified by `THEOS_PACKAGE_SCHEME` will be imported without needing to specify the module explicitly via `MODULES`. These are "enabled" through Makefile's `-include` feature and are typically included *after* all of the stock Theos functionality has been defined. Thus, modules support all Theos variables that have been defined by the time your specific Module is imported.

docs/Rootless.md

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ layout: docs
77

88
Practically all jailbreaks prior to iOS 15 have been 'rootful' as they work on and install files to the (root) system directories (e.g., `/usr`, `/Library`, `/Applications`, etc). Moving forward with iOS 15 and beyond, most if not all jailbreaks will have to be 'rootless' as Apple now prevents writing to the system directories with a protection called [Signed System Volume (SSV)](https://support.apple.com/guide/security/signed-system-volume-security-secd698747c9/web). There are workarounds for this, namely bindFS, but these are less than ideal.
99

10+
Note that 'rootless' does not imply lack of `root` user permissions, contrary to what its name might suggest.
11+
1012
To work around SSV, the [Procursus Team](https://github.com/procursusteam/) has thought up a rootless scheme that is now the de facto rootless standard. The changes namely involve working in and installing tweaks/addons to `/var/jb` and using the `iphoneos-arm64` package architecture. To learn more about the specifics of this implementation, see [The Apple Wiki](https://theapplewiki.com/wiki/Rootless).
1113

1214
With this new target location, *all* projects will have to be recompiled to reference resources from and install to `/var/jb`. This involves changing the internal structure of .deb's to include this new path and specifying library and framework install paths using `@rpath` instead of absolute paths. Theos will handle both of these changes for you. For more information on what `@rpath` is and how it works, see Mike Ash's [informative blog post](http://www.mikeash.com/pyblog/friday-qa-2009-11-06-linking-and-install-names.html).
@@ -18,47 +20,63 @@ With this new target location, *all* projects will have to be recompiled to refe
1820
**Important Notes**:
1921
- You must run `make clean` when switching between a rootful and rootless build
2022

21-
- If you maintain a library, you'll want to add some variation of the following to your code so that it will have the correct install path:
22-
```make
23-
ifeq ($(THEOS_PACKAGE_SCHEME),rootless)
24-
XXX_LDFLAGS += -install_name @rpath/<lib-name>.dylib
25-
endif
26-
```
27-
28-
- Likewise, if you maintain a framework, you'll want to add some variation of the following to your code so that it will have the correct install path:
29-
```make
30-
ifeq ($(THEOS_PACKAGE_SCHEME),rootless)
31-
XXX_LDFLAGS += -install_name @rpath/<project-name>.framework/<project-name>
32-
endif
33-
```
34-
3523
- The iOS 14 arm64e ABI mentioned in [arm64e Deployment](arm64e-Deployment.html) is now *required* for the relevant devices
36-
- Currently, it's only possible to build for the new ABI on macOS
37-
- If you want to maintain support for earlier versions, you can grab the toolchain from an earlier Xcode release as specified in [arm64e Deployment](arm64e-Deployment.html) and switch between it and the newer toolchain as desired by setting the `PREFIX` variable to the older toolchain's bin (i.e., `<xcode-ver>.xctoolchain/usr/bin/`) in your project's makefile
24+
- Currently, it's only possible to build for the new ABI on macOS as the necessary `ld64` changes, included in Xcode, have not been made open source
25+
- Unfortunately, this newer toolchain does not support building for the old ABI. If you want to maintain support for earlier versions, you can grab the toolchain from an earlier Xcode release as specified in [arm64e Deployment](arm64e-Deployment.html) and switch between it and the newer toolchain as desired by setting the `PREFIX` variable to the older toolchain's bin (i.e., `<xcode-ver>.xctoolchain/usr/bin/`) in your project's makefile
3826
- That being said, developers on other platforms can circumvent this *if necessary*:
39-
- By adding `oldabi` as a dependency to their package (preferably only as a last resort)
27+
- By [using GitHub Actions](https://github.com/p0358/SilentScreenshots/blob/master/.github/workflows/build.yml) to compile their tweaks (free for both public and private repos)
28+
- By using a macOS virtual machine
29+
- See KVM on Linux and VMware on Windows
30+
- If you want to reduce resources used by the VM (after installing Xcode and Theos):
31+
- [Enable SSH access in System Preferences](https://osxdaily.com/2022/07/08/turn-on-ssh-mac/)
32+
- Disable the WindowServer daemon with `sudo launchctl disable system/com.apple.WindowServer` and reboot.
33+
- This will disable macOS's graphical user interface, reducing the idle CPU and RAM usage to ~900 MB
34+
- Reboot and SSH into the VM to use Theos
35+
- By using [allemande](https://github.com/p0358/allemande) (static binary converter to old ABI)
36+
- This is currently the best solution if you cannot use macOS and Xcode
37+
- It does not work with tweaks containing Swift code (including the Cephei v2.0 library)
38+
- By adding `oldabi` as a dependency to their package (preferably only for testing or as a last resort as it applies system-wide and may cause instability for users)
39+
- If you intend to release packages without the `oldabi` dependency, make sure to uninstall `oldabi` from your device during testing to avoid accidentally releasing a tweak that silently relies on it without your knowledge!
40+
- **Please note**: this only applies to arm64e binaries (i.e., system binaries and libraries). It does not apply to App Store apps or regular CLI binaries as arm64e is disallowed due to its unstable ABI. That is, you can continue compiling tweaks for non-system apps with any toolchain and do not need to target arm64e for your apps or CLI binaries.
4041

4142
---
4243

4344
Theos supports building for the rootless scheme in a few ways:
4445
- Provides rootless-compatible libraries and frameworks in `$THEOS_VENDOR_LIBRARY_PATH/iphone/rootless`
4546

46-
- Provides `rootless.h` -- a header that contains convenient macros to easily convert rootful paths to rootless ones in your code at compile-time, assuming you compile for the rootless scheme (see below)
47+
- Provides [`rootless.h`](https://github.com/theos/headers/blob/master/rootless.h) -- a header that contains convenient macros to easily convert rootful paths to rootless ones in your code at compile-time, assuming you compile for the rootless scheme (see below)
4748
- `#import <rootless.h>`
48-
- Courtesy of [opa334](https://github.com/theos/headers/commit/9f00c9663aff892b512f87666dbfbf8fe4943e84)
49+
- Courtesy of opa334
4950

5051
- `THEOS_PACKAGE_SCHEME=rootless` -- a variable to enable a handful of internal changes including:
5152
- Searching for libraries and frameworks when linking in `$THEOS_LIBRARY_PATH/iphone/rootless` and `$THEOS_VENDOR_LIBRARY_PATH/iphone/rootless`
53+
- Handling install_name changes to use @rpath for libraries and frameworks
5254
- Passing the relevant prefixed rpaths to the linker so your project can find the linked rootless libraries and frameworks on-device
5355
- Sharing the install prefix (`THEOS_PACKAGE_INSTALL_PREFIX=/var/jb`) with the compiler for use in your code
5456
- Setting the package architecture to `iphoneos-arm64` if your control file specifies `iphoneos-arm`
5557

5658
Additional notes:
5759
- You do *not* need to create separate package identifiers for rootful/rootless versions of the same package
5860
- Newer versions of rootless-compatible package managers (e.g., Sileo and Zebra) will present only the compatible version to users
61+
- Cydia will display duplicate packages, but both point to the rootful version
62+
- This can be corrected with [cyarchfix](https://github.com/PoomSmart/cyarchfix) by PoomSmart
5963
- The behavior of other package managers varies and may or may not supply the correct package to users
6064

6165
- All non-DEBIAN items (e.g., maintainer scripts) are placed in `/var/jb`
66+
- Please ensure that any additional resources you provide (e.g., newly created or laid out files and directories) are stored in a prefixed path and not a rootful path, as the latter could lead to jailbreak detection in a non-jailbroken state
6267

6368
- This new rootless scheme only supports iOS 15+, which itself only supports newer devices
6469
- This means that you do not need to compile for legacy architectures (e.g., `armv7(s)` or older) if you were previously and can bump your deployment target to 15.0 when building for rootless
70+
71+
---
72+
73+
If desired, you can conditionally check for the package scheme in your project's Makefile to selectively apply rootless build settings:
74+
```make
75+
ifeq ($(THEOS_PACKAGE_SCHEME),rootless)
76+
ARCHS = arm64 arm64e
77+
TARGET = iphone:clang:latest:15.0
78+
else
79+
ARCHS = armv7 armv7s arm64 arm64e
80+
TARGET = iphone:clang:latest:7.0
81+
endif
82+
```

docs/Variables.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,9 @@ The various public (i.e., configurable) variable types are as follows:
540540
- Space-separated list
541541
- Must be present in $(THEOS_MODULE_PATH)
542542

543+
- SCHEMA (str)
544+
- An alias for THEOS_SCHEMA
545+
543546
- LOCAL_BUNDLE_NAME (str)
544547
- Name for the current project instance's bundle
545548

@@ -616,8 +619,10 @@ The various public (i.e., configurable) variable types are as follows:
616619
- Lowercase name of the target platform
617620

618621
- THEOS_SCHEMA (str)
619-
- Schema to build for "Release," "Debug," or "" (default: `Debug`)
620-
- This will adjust what variables are enabled/disabled in Theos' internal configuration
622+
- Schema ("Schemata") to build for
623+
- Space-separated list
624+
- Can be custom or one of the provided "Release," "Debug," or "" schema (default: `Debug`)
625+
- This will adjust what schema-variables, and associated functionalities, are enabled/disabled in Theos' internal configuration
621626

622627
- THEOS_PLATFORM_NAME (str)
623628
- Lowercase name of the current host platform (default: `$(shell uname)`)

docs/arm64e-Deployment.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ There are two ways to overcome this:
4444
# Alternatively, you can temporarily change your command line tools version
4545
# for just this terminal session:
4646
export DEVELOPER_DIR=/Applications/Xcode-11.7.app/Contents/Developer
47+
48+
# Or you can change the command line tools version for just the particular
49+
# Theos build command invocation:
50+
DEVELOPER_DIR=/Applications/Xcode-11.7.app/Contents/Developer make package
4751
```
4852

4953
You can also use the Xcode GUI to change your command line tools version, via Xcode &rarr; Preferences &rarr; Locations &rarr; Command Line Tools.

0 commit comments

Comments
 (0)