We write a full-fledged tweak for iOS using iOSOpenDev

Good day!

Today I would like to touch upon the development of jailbreak-programs for iOS again. On the Russian-language Internet, it is quite problematic to find something understandable for beginners, so I will try to correct this misunderstanding and explain how some points are solved.

Installing software, setting up the environment and device, writing a tweak from scratch - this is what awaits you under the cut. If you are interested in how to change part of iOS for yourself - welcome.

Let's get started!

What do we need?

  • Mac OS X computer with git, dpkg utilities;
  • Xcode with Command Line tools installed (I use 5.1.1, however, 4.0+ is suitable);
  • Theos ;
  • IOSOpenDev Package ;
  • iDevice with jailbreak'om and installed OpenSSH.


The first step is to install Xcode. You can download it from the Mac AppStore, as well as from the download page on the Apple website. I will not dwell on this in detail.

Next you need to put theos. We are told that it can be crammed onto any platform, and it will work, but today we do not invent a bicycle, we do everything on the native iOS SDK system.

Download theos to the / opt / theos folder. You can put it in any folder, but at your own peril and risk:

export THEOS=/opt/theos
git clone git://github.com/DHowett/theos.git $THEOS

On this, theos setup can be completed.

Download iOSOpenDev and run the installer. He will do everything for you.
In the event of an unknown error, most likely the application is not called “Xcode.app” or you did not run it at all.

The freebie is over. Variable setup time.
Open ~ / .bash_profile and edit the following lines:

export iOSOpenDevDevice=айпи.адрес.вашего.устройства

Now iOSOpenDev will know the IP of your device, it remains only to allow you to connect via SSH without asking for a password and download all the necessary library database:

iod-setup base
iosod sshkey -h 

We enter the device password twice, and, if requested, we create a password for the keychain.
Moreover, you need to download a bunch of headers and put in / opt / iOSOpenDev / include.

The hardest part here is with IOSurfaceAPI.h, since it is not freely distributed code. But if you can’t get it from the system (I didn’t find it on Mac OS X 10.10), then take the “stub” from the _fallback folder, and it will be enough for our analysis.

On this installation can be considered completed.

We write the basis

All development will take place in Xcode, although with some limitations.

We create a new project and meet the new item "iOSOpenDev".

We need Logos Tweak: We

fill in the information about the project. Include Simple PreferenceLoader will add a simple settings block in Settings.app to the project. But about him later.

Now we must do what Xcode itself does not do - add UIKit.framework and libsubstrate.dylib to the list for the linker (the latter is in / opt / iOSOpenDev / lib /).

After that, go to our .xm file, demolish the #error directive and click on the assembly. The first build will fail, and the second should succeed, that's fine. There is no syntax highlighting in the xm file, but this is solved by closing and opening Xcode after the first build.

Let's put all the dots over “i”: the .xm file is responsible for the tweak code, and the .mm file is “intermediate”, it is automatically generated by the logos preprocessor and then compiled.

First steps

Today we will change the dull inscription “Unlock” the lock screen to your text.

Firstly, it would be nice to get the headers of the “experimental” binary. With SpringBoard, everything is much simpler - people are ready to upload springboard headers for each version of iOS. But if you want to make them yourself, then the class-dump-z utility will help you with this.

I am writing for iPad 4 on iOS 8.1, which is why the headers look appropriate.

There are two ways to quickly find what we need. The first is to use cycript and look at the hierarchy of objects to find what you need. The second is to search by the contents of the headers. In this case, I decided to search for “unlockText” and found this method in the SBLockScreenView class:

- (id)_defaultSlideToUnlockText;

Suppose this is what we need. Let's write the first sketch:

%hook SBLockScreenView
- (id)_defaultSlideToUnlockText
    return @"Привет, Хабр!";

To compile with installation on the device, select Build for profiling:

And, oh, a miracle! Surprisingly, everything worked the first time:

Our main goal is to make the text change, so we will create a constructor (% ctor) and we will load the settings.

#define SETTINGS_FILE @"/var/mobile/Library/Preferences/ru.firemoon777.LockLabel8Bundle.plist"
NSDictionary *settings;
%hook SBLockScreenView
- (id)_defaultSlideToUnlockText
    return [settings objectForKey:@"Text"];
static void loadSettings()
    settings = [[NSDictionary alloc] initWithContentsOfFile:SETTINGS_FILE];

Create a settings panel

Create a new goal: File - New - Target - iOS Open Dev - PreferenceBundle; Let's call it LockLabel8Bundle.
There is a big plus of the project with "complex" PreferenceBundle'om - in the settings you can make the entire graphical interface for the application and not bother with running from the root and signatures. But there is a minus - the panel in the settings and the tweak itself are collected in separate packages, so for the release you will have to combine them as well.

You can try to build a template and enjoy the many possible built-in PSSpecifiers.

Perhaps it does not accumulate immediately as it should. So, you missed downloading the headers, about which I spoke at the beginning of the article.

Of all, I will leave only the first and last group, TextView and one button.

You can also edit the “label” field so as not to shine with this “Bundle”.

The button has an Action "respring:", so we will describe the respring method in LockLabel8BundleController:

- (void)respring:(PSSpecifier*)specifier
    system("killall SpringBoard");

With the development inside the settings, everything is much simpler: the same laws apply here as in ordinary applications.

Source code is available on github .

Support for multiple versions of iOS?

When a tweak becomes a large-scale project from a simple sketch, the question arises, but how to organize support for several versions of iOS so that nothing extra loads? Then groups come to the rescue.

%group iOS6
// Методы для iOS6
%group iOS78
// Методы для iOS7+
    if (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_7_0) {
    } else {


iOSOpenDev is just a plugin for Xcode, but, in my opinion, it is much simpler and more convenient than the bare theos. On Mac OS X, it greatly facilitates the development of iOS tweaks for beginners.

Also popular now: