-
Notifications
You must be signed in to change notification settings - Fork 66
Usage
Make sure that you have installed Theos Jailed before following this guide.
- Extract and decrypt your target app. Save as a .ipa
- Change to the base directory for your tweak (eg.
cd ~/Desktop
) - Run
nic.pl
and choose the jailed template - Enter a name and bundle ID for your tweak
- Enter an absolute or relative path to your decrypted .ipa file
- Change into your new tweak directory (eg.
cd ~/Desktop/mytweak
) - Edit Tweak.xm as necessary
- Run
make info
and follow the instructions to create a Provisioning Profile - Run
make package install [PROFILE=<your.bundle.id | file.mobileprovision>]
. OmitPROFILE=…
to use Xcode's Wildcard App ID
Note: Unless specified otherwise, the rest of this page requires that you cd
into your tweak's root directory before running any commands.
If you want to add custom resources to your project, you can create a Resources
folder, and add any files to it. If you add an Info.plist
file to Resources
, its keys will be merged with the app's Info.plist
. However, since the most common use of merging an Info.plist
is setting a custom display name and bundle ID, you can also do that using the DISPLAY_NAME
and BUNDLE_ID
variables.
Since Theos Jailed merges the Resources
folder with the app's root directory, it will override any existing files with a clashing name. Due to this, it is highly recommended that you create a <tweak name>.bundle
folder in Resources
to add custom files. To access your tweak's bundle, add the following to the top of Tweak.xm
:
NSBundle* const kTweakBundle = [NSBundle bundleWithPath: [[NSBundle mainBundle] pathForResource: @"tweak name" ofType: @"bundle"]];
And to access files inside the bundle, use:
[kTweakBundle pathForResource: @"name" ofType: @"extension"]
When you're happy with what you've made and want to distribute the ipa, run make package FINALPACKAGE=1
. This will increase compression and remove any debug-specific addons such as Cycript (note that you can explicitly re-enable this using TWEAK_NAME_USE_CYCRIPT=1
).
The following variables can be set either in Makefile
or when running the make
command (make [...] VARIABLE=value
). Replace TWEAK_NAME
with your tweak's name, spelled exactly the way it is in Makefile
. Run grep TWEAK_NAME Makefile
to see the tweak name.
Set TWEAK_NAME_USE_CYCRIPT=1
to be able to remotely attach to Cycript using cycript -r hostname:31337
.
Set TWEAK_NAME_USE_FISHHOOK=1
to use fishhook. Remember to #import <fishhook.h>
as well.
Set TWEAK_NAME_USE_FLEX=1
to use FLEX.
Set PACKAGE_FORMAT=exo
to package your project as an Extensify Exo instead of a .ipa.
Note: The FLEX and Cycript addons are themselves Theos Jailed tweaks that are automatically triggered. If you want to modify them, you may do so by editing the respective tweak in the addons
directory in the root of this repository, and then running make
.
- Download the tweak as a .deb file. To find a website that lets you do this, search Google for something like "Cydia Updates"
- Unpack the .deb file, using the command
dpkg-deb -x file.deb destination
- Extract and decrypt the app targeted by the Cydia tweak. Save as a .ipa
- Create a new Theos project with the
jailed
template, using the decrypted .ipa - Copy the unpacked tweak at
destination/Library/MobileSubstrate/DynamicLibraries/tweak-name.dylib
to the root folder of your project, replacingtweak-name
with the name of the tweak you downloaded - Add
TWEAK_NAME_INJECT_DYLIBS = tweak-name.dylib
to the top ofMakefile
. Doing this still compilesTweak.xm
, so you can add your own changes too - Follow step 9 and 10 of General usage
You may want to change the install location of tweak-name.dylib
in the app directory (eg. Foo.app/MyFrameworks
instead of Foo.app/Frameworks
). To do this, set the COPY_PATH
variable to the path you want in your Makefile
. The default value for this is Frameworks
. If you do this, you will also need to update any dependency's location respectively. In this example, you'd need to replace Frameworks
with MyFrameworks
in steps 3 and 4 of Adding dependencies.
Many tweaks require external dependencies. To use one, you must first fix the install name
of the dependency and the libraries it links against.
- Download and extract the dependency .deb, similar to how you downloaded the tweak
- Create a
Resources
directory inside your project's root directory - Create a
Frameworks
directory inside theResources
directory, and add the dependency to that - Run
install_name_tool -id @rpath/dependency.dylib Resources/Frameworks/dependency.dylib
- Run
otool -L tweak-name.dylib
to see the current linked path to the dependency - Run
install_name_tool -change /linked/path/to/dependency.dylib @rpath/dependency.dylib tweak-name.dylib
Note: Some dependencies (such as rocketbootstrap
and uasharedtools
) do not work on jailed devices, and thus tweaks that require them will not work. If you want to inject a ++ tweak, your best option is using ppsideloader, which is specifically made for that purpose.
External frameworks may be of two types: static and dynamic. To find out which your framework is, run the following command:
file Foo.framework/Foo | grep -q "Mach-O dynamically linked shared library" && echo "Dynamic" || echo "Static"
- Copy the .framework into your project's root directory
- Open
Makefile
in your favourite text editor - Add
TWEAK_NAME_FRAMEWORKS = Foo
, replacingFoo
with the name of your framework. If any additional frameworks are required, add them here too - Add any required libraries to
TWEAK_NAME_LIBRARIES
below theFRAMEWORKS
line. For example, if I wanted to addlibxyz.tbd
to my project, I would add the lineTWEAK_NAME_LIBRARIES = xyz
- Import your framework in Tweak.xm using
#import <Foo/Foo.h>
- Dynamic frameworks are only supported in iOS 8 and above. Add
TARGET_IPHONEOS_DEPLOYMENT_VERSION = 8.0
to the beginning of your makefile - Follow all the steps in Static frameworks, but replace
TWEAK_NAME_FRAMEWORKS
withTWEAK_NAME_EMBED_FRAMEWORKS
in step 3, and use the framework's path instead of its name (Foo.framework
instead ofFoo
)
- Follow steps 1 to 4 of Static frameworks, but replace
TWEAK_NAME_FRAMEWORKS
withTWEAK_NAME_EMBED_LIBRARIES
in step 3, and use the dylib's path instead of its name (libfoo.dylib
) - Import your framework in Tweak.xm, using
#import <foo.h>
Note: To add a framework to a subdirectory inside your project folder, you must add -Fpath/to/subdirectory
to TWEAK_NAME_CFLAGS
and TWEAK_NAME_LDFLAGS
, and for a dylib add -Lpath/to/subdirectory
to TWEAK_NAME_LDFLAGS
. You need not do this if you place the framework/dylib in the project's root directory because that is already added by default.