HopOn
HopOn copied to clipboard
Easily inject code into OS X apps
HopOn
Easily inject code into OS X apps
You're gonna get some hop-ons.
This code is rough, but workable. I'm not an expert in mach_inject, XPC, or launchd, so this may be buggy. But it's at least a start.
Injecting Code with HopOn
Here's a rough outline of the steps to use HopOn:
-
Add HopOn as a submodule
-
Bootstrap HopOn:
script/bootstrap. -
Add HopOn.xcodeproj to your project or workspace.
-
Add HopOn.framework and com.diephouse.matt.HopOn-Injector to your project's dependencies.
-
Add a build phase to copy HopOn.framework into your app's Frameworks directory.
-
Add a build phase to copy com.diephouse.matt.HopOn-Injector to
Contents/Library/LaunchServicesin the Wrapper destination. -
Set the
Runpath Search Pathsto@loader_path/../Frameworksin your app's build settings. -
Add a file called
HOPON_HOST_IDENTIFIERin a directory above the HopOn directory that contains the identifier of your app. This is needed for the launch service's permissions. -
Add a
SMPrivilegedExecutablesdictionary to your app's info.plist with the keycom.diephouse.matt.HopOn-Identifierand the valueidentifier "com.diephouse.matt.HopOn-Identifier". -
Create a "Bundle" target in your app to host the injected code. You can add classes and use
+loador a function like this:
attribute((constructor)) void load() { ... }
0. Copy your bundle into your app in a build phase.
0. In your app, call `+[HopOn injectBundleAtURL: intoApplication:];` to inject your bundle into a target app.
## License
Available under the MIT License.