Pure Swift tweak development framework for iOS 12-16
This is a tool for tweak developers. Probably just me tbh, but others are welcome to use any or all of it they want. If you are an end user, this repo means nothing for you.
Please note that this does require a macOS device with Xcode to compile. You’ll also need to run make spm
and open the Package.swift file in Xcode at least once, as Jinx is distributed through SPM.
python3 install_jinx.py
The Hook protocol is the one which you will most often use, as it is responsible for hooking Objective-C messages.
There are four immutable variables which you must define in a struct conforming to Hook:
AnyClass?
. The class you will hook. A nil
value will prevent the hook from taking place.Selector
. The name of the method you will hook.T
. A closure which replaces the original code.There is also one function which can be used.
(Bool) -> Bool
. Returns true if the hook succeeds, and false if it fails. The onlyIf parameter defaults to true.The HookFunc protocol is responsible for hooking C, C++, and Swift functions.
There are four immutable variables which you must define.
String
. The symbol of the function you will hook. Must have a leading underscore. For C++/Swift functions, use the mangled name.String?
. The path to the image containing the target function. You may pass nil
to refer to the current process.T
. A closure which replaces the original code.There is also one function which can be used.
(Bool) -> Bool
. Returns true if the hook succeeds, and false if it fails. The onlyIf parameter defaults to true.To call original implementation of a message or function, you can add orig()
to your replacement
. Just supply the arguments of the closure and you’re good to go.
To set an instance variable from inside a hook, you can use Mouser.setIvar(_:for:to:)
with the name, object reference, and desired value.
You can also get the value of an instance variable with Mouser.getIvar(_:for:)
with the name and object reference.
To get preferences, you will need to use the tweak_swift_jinx_prefs template, which includes by default all the requisite code.
In the Helpers/Preferences.swift file, you will see a variable isEnabled
, just follow that pattern for assigning variables and change the Root.plist file in Resources folder accordingly.
link |
Stars: 16 |
Last commit: Yesterday |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics