Jailbroken Development : Starter Pack
For me first blog post on iDevBlogADay, I thought I’d talk about a part of iOS development that rarely gets mentioned on blogs, Tweak development (or mobilesubstrate development).
To start you’ll need:
- A Jailbroken iOS device
- OSX 10.6+ (or iOS 3.x+)
- Theos
- A good knowledge of Objective-C
Getting Theos
You can get Theos from DHowett’s official Github profile, although rpetrich has a fork which includes a set of private headers and is kept quite up to date (however the headers are from 3.x). Theos also needs ldid THEOS/bin/ldid
You can find a more complete guide here. If you need to install Theos on your device rather then on OSX you can find a guide on the iPhoneDevWiki.
On Your Device
On your device you should install a few tools first:
- BigBoss Recommended Tools
- syslogd (saves NSLog statements to file)
- MobileSubstrate (obviously)
- Cycript Javascript/Objc mix, install yourself (useful for testing the output of SpringBoard methods)
- gdb (if something goes wrong we can’t use xcodes debugger)
- Mobileterminal, allows you to run commands from the device itself (same as cycript)
- Class-dump-z (gets the method names & classes from an iOS binary file)
Using Theos
Theos comes with a group of tools, the most obvious of which is Logos. Theos itself is a build system (make files and build scripts) which can build you code straight to a .deb file (the format cydia installs).
Logos is a preprocessor-based library to make developing with mobilesubstrate easier by providing an ObjectiveC style syntax.
MobileSubstrate Example (from iFans)
static void __$ExampleHook_AppIcon_Launch(SBApplicationIcon *_SBApplicationIcon) {
UIAlertView* __launchView = [[UIAlertView alloc] init];
__launchView.title = @"No way muchacho";
__launchView.message = @"You can't touch dis!";
[__launchView addButtonWithTitle:@"Dismiss"];
[__launchView show];
// If at any point we wanted to have it actually launch we should do:
// [_SBApplicationIcon __OriginalMethodPrefix_launch];
}
extern "C" void ExampleHookInitialize() {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
// Get the SBApplicationIcon class
Class _$SBAppIcon = objc_getClass("SBApplicationIcon");
// MSHookMessage is what we use to redirect the methods to our own
MSHookMessage(_$SBAppIcon, @selector(launch), (IMP) &__$ExampleHook_AppIcon_Launch, "__OriginalMethodPrefix_");
// We just redirected SBApplicationIcon's "launch" to our custom method, and now we are done.
[pool release];
}
Theos/Logos Example
%hook SBApplicationIcon
-(void)launch{
UIAlertView* __launchView = [[[UIAlertView alloc] init] autorelease];
__launchView.title = @"No way muchacho";
__launchView.message = @"You can't touch dis!";
[__launchView addButtonWithTitle:@"Dismiss"];
[__launchView show];
}
%end
Much less code, much simpler and much easier to understand!
Useful Stuff
This is a collection of useful links & info to help you get started:
StackOverflow is the most useful site for iOS development and for jailbroken development the iPhoneDevWiki is by far the most useful sites for a developer.
- irc.saurik.com
If you have a problem you can’t solve while making your AppStore app you ask on StackOverflow for a solution. If while making your tweak you can’t fix a certain bug/problem you ask on the #theos or #iphonedev channels on Saurik’s (creator of cydia) IRC.
Lots of simple example tweaks from top Cydia developers. It’s now finished but there are still over 60 example tweaks to study.
That’s it hopefully that’s enough to get you started developing tweaks. Enjoy!
tonyh001 likes this
brandon15811 likes this
inthetrulygruesome likes this
officialtechtv reblogged this from iky1e
iky1e posted this