Tweak-Tutorial

Adapting for Rootless

What is rootless?

How does this affect my tweak?


How can I adapt my tweak for rootless?

Firsrly, it is best to always use the most up-to-date version of Theos. Make sure to update it if you installed Theos a while ago.

Theos includes convenient macros for you to use in order to adapt for rootless. They are stored in a header file called rootless.h which is bundled in recent versions. Say we have a file path that needs to be adapted stored within an NSString like so:

NSString *filePath = @"/Library/Application Support/";

This particular directory does exist in non-jailbroken iOS. On “rootful” jailbreaks, tweaks can write to this directory to store files. However, on “rootless” jailbreaks, there is no ability to do that. So, rootless jailbreaks write to /var/jb/Library/Application Support/. So how can we include the /var/jb/ part of the path when compiling for “rootless” but not “rootful?” Well, the macros make that process quite simple. In order to utilize the macros, you need to #import <rootless.h> at in your file. That will give you the ability to access the macros. Then, you can just wrap the path in the ROOT_PATH_NS() macro in order to adapt for “rootless” jailbreaks. So, it can be done as easily as this:

#import <rootless.h>

// ...

NSString *filePath = ROOT_PATH_NS(@"/Library/Application Support/");

The value of this string will be like so:

Compiling for rootless

As previously mentioned, the command needed to compile for rootless requires an extra argument: THEOS_PACKAGE_SCHEME=rootless. Therefore, if you normally compile for rootless with this:

make do

Then you would need to add the extra flag at the end, like so:

make do THEOS_PACKAGE_SCHEME=rootless

Do note that some libraries also need to be updated for rootless, so that is something that needs to be taken into account.


More information about adapting for rootless can be found here.


Previous Page (FLEX Explained)

Next Page (Old ABI)