Article Image

Last time, we used Cycript to do a little memory tweaking and change the "No Notifications" sign to something a little different.

To do this we found the object that controlled the "No Notifications" sign, in this case a UILabel, and ran the setText method on it.

[nnLabel setText:@"S'all Good"]

To make it permanent, we need to make a tweak that will load when the Springboard loads, and injects a little bit of code to run the above snippet. Luckily for us, there is a suite of tools called Theos available to make developing tweaks that inject code in this way quick and easy!

If you don't already have Theos set up, visit this page, follow the instructions and come back once it's done.

## Setup the tweak

First thing to do is create a project for your tweak by running $THEOS/bin/nic.pl. When you run it, it will ask you for some bits and pieces. Be sure to choose the iphone/tweak option! Things in square brackets are defaults and you can just hit enter to accept them. $THEOS/bin/nic.pl
NIC 1.0 - New Instance Creator
------------------------------
[1.] iphone/application
[2.] iphone/library
[3.] iphone/preference_bundle
[4.] iphone/tool
[5.] iphone/tweak
Choose a Template (required): 5
Project Name (required): ItsAllGood
Package Name [eu.teggers.itsallgood]: eu.teggers.itsallgood
Authour/Maintainer Name [Your Name Here]:
Instantiating iphone/tweak in itsallgood/...
Done.
$ Head inside the new folder that NIC has created. The first thing I always do is fix the Makefile, which needs a little update for newer SDKs and 64 bit devices. Here's an example of a working Makefile, change it to your needs and replace yours. ARCHS = armv7 armv7s arm64 TARGET = iphone:clang:latest:latest include theos/makefiles/common.mk TWEAK_NAME = itsallgood itsallgood_FILES = Tweak.xm itsallgood_FRAMEWORKS = UIKit include$(THEOS_MAKE_PATH)/tweak.mk

after-install::
install.exec "killall -9 Springboard"


Now open up Tweak.xm, there will be some commented code explaining how to use the mini-language of THEOS known as LOGOS.

## Hook the UILabel

We wanted to edit objects of type UILabel, so let's hook that...

%hook UILabel

%end


One way to ensure that our "No Notifications" label is changed to something else is by intercepting and changing the code that's run to set a UILabel's text in the first place. We can simply test for "No Notifications", and change the label if it matches.

To intercept the code, we need the definition of the method we want to change. Luckily one can easily find the definition of the setText method using dumped headers, as discussed in part 1.

%hook UILabel
- (void)setText:(NSString)arg1{    //setText defintion
%orig(@"S'all Good");
} else {
%orig;
}
}
%end


The above code indeed modifies the setText method of the UILabel class. The code checks if the input string is equal to "No Notifications". If not, the LOGOS code %orig is called. This calls the original function with the original arguments. So if our string doesn't match, the normal setText code is run!

If the string does match, the code runs

%orig(@"S'all Good");

This is LOGOS speak for "run the original code, with modified arguments". In our case it replaces the text with "S'all Good". Perfect!

Head over to a terminal and run

make package and make install

If THEOS is set up correctly, this will make the tweak and install it on your iOS device. If all is good it will also respring and the change should be automatic from now on!

Of course if you want to undo the change, you can uninstall the tweak using Cydia :)

Image