iOS Class Hook Examples

So your looking for those examples I talked about in my last tutorial are you? Well here they are finally! By the way, if you haven’t already seen my last tutorial, Cydia Tweaks, it explains the process of how to begin making cydia tweaks and getting the required tools to do so.

“Delete any” app

Anyways, my first example is a simple app that allows you to “temporarily” delete any of the applications on the springboard including the ones that apple has included. The reason I say temporarily is because if you respring or reboot your device after deleting the apps then they reappear as if never deleted. This is also apparent for the deleting cydia and any other jailbreak apps installed. Although, this is merely an example to show you what’s possible as I found this method in only a few minutes browsing the springboard classes.

The methods you will be hooking are:

- (BOOL) isSystemApplication;
- (BOOL) isInternalApplication;

I found them in the SBApplication class along with a few other “is … application” methods that can be utilized as well. Here is how I started my project using terminal if you want to follow along.

$ $THEOS/bin/
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): DeleteAny
Package Name: com.snoapps.deleteany
Author/Maintainer Name: Snoapps
MobileSubstrate Bundle filter:

Then, in my Tweak.xm, I edit it to look like this.

%hook SBApplication

- (BOOL)isSystemApplication {
return false;

- (BOOL)isInternalApplication {
return true;


Basically what’s happening is when you press and hold an app icon on your springboard, it calls these methods to check if they are system “built in” apple apps or if they were downloaded from the App store. By returning false for isSystemApplication no matter what, no app on your springboard is considered “Apple built in”. You will need the springboard class-dump for this which is located in the directory: /System/Library/CoreServices/, copy the class-dump to /opt/theos/include/springboard/ on your mac so the compiler can recognize the class you are hooking, if you do not know how to class-dump goto my previous tutorial, Cydia Tweaks. Now, to test it out go back to your terminal window and cd into your project directory, which for me would be:

$ cd deleteany

and type in the following:

$ sudo make
Making all for tweak DeleteAny...
Preprocessing Tweak.xm...
Compiling Tweak.xm...
Linking tweak DeleteAny...
Stripping DeleteAny...
Signing DeleteAny...

After you enter your password, you will see it doing several things to compile your project. Now to move it to your iDevice for testing, you will need to edit your makefile and add the following line to the top of the file:


Of course you replace the with your idevice’s local ip address which can be found under Settings > Wifi > arrow next to your wifi > Ip Address. Save that file and go back to your terminal window.

Next, type in the terminal window

export THEOS_DEVICE_IP = [your device ip]

Now you can package your project by typing

$ sudo make package

Now to install it to your device type

$ sudo make install

It will ask you for the ssh password a bunch of times and the default for openssh is: alpine. If this process worked your idevice should respring and when you hold down a home screen app it should let you delete any of apples built in apps as well. One issue is that the calendar doesn’t show the date on the icon while this tweak is active. Also, if you respring the device, the apps you weren’t originally able to delete that you deleted will reappear because they weren’t actually deleted. This is because the apps you download from the app store are in a different folder so it doesn’t know what directories to delete when you remove their icon. All this is just to say that this app is mainly for looks and not functionality. Post your comments, questions or if you make any sweet tweaks in the comments below.

My next tutorial will be showing you how to make a tweak to password protect your applications that you don’t want that one annoying person getting into, or just to keeping your data protected for whatever reason. In the mean time, have fun hacking away!

Cydia Tweaks

Have you ever browsed through cydia and wondered, How could I make a cool app such as insert cool app from cydia here. Well, here you learn the basic outline for most tweaks on cydia from the simple UI tweaks to advanced behind the scenes modge podge. To begin you all you need is your mac and an iDevice. Also a few things need to be installed on your system:

(git, curl and perl come default on Mac OS X)

  • git
  • curl
  • perl
  • xcode

Now you need a tool called Theos, follow these steps to get it.

On Your Mac

1.  Open a terminal window and type the following (this sets a variable for your upcoming theos directory).

export THEOS=/opt/theos

2.  Now you need to copy the git for theos into your directory.

git clone git:// $THEOS

3.  Next you need to download ldid into that directory.

curl -s > $THEOS/bin/ldid; chmod +x $THEOS/bin/ldid


On Your iDevice (Using iFile or SSH)

  1. Create a file at /etc/apt/sources.list.d/ containing the following line:
    deb iphone main
  2. Create a file at /etc/apt/sources.list.d/ containing the following line:
    deb ./
  3. As root, issue these commands (using either SSH or MobileTerminal):
    apt-get update
    apt-get install perl net.howett.theos
Note: Theos will be installed to /var/theos/ on your device.

Create The Project

Now you just need to browse to the directory where you want to make a new project and type in:
This will give you a menu something like this.
$ $THEOS/bin/
NIC 1.0 - New Instance Creator
  [1.] iphone/application
  [2.] iphone/library
  [3.] iphone/preference_bundle
  [4.] iphone/tool
  [5.] iphone/tweak
Choose option 5 to make a new cydia tweak. Next it will ask you a few questions about making your new project.
Once you’ve completed the template you will have a new directory as the name of your project with a few files in it. The main important ones are the MAKE file and Tweak.xm. Tweak.xm is the file you will be writing your code insertion methods in and will look along the lines of:
%hook UIAlertView // The class you will override
 -(void)alert { // method to override
    [self setTitle:@"new title"]; // write custom code
    %orig; // Then call original method to finish the original code
%end //end hooking uialertview
   Basically you write out a method for a class you want to modify say UIAlertView. You would type %hook UIAlertView and then type and modify the method you wish to override such as the alert method. Then you can finish the original method by calling %orig or return %orig.


Now to compile it in your terminal window, type:
$ sudo make


This should compile it after you type in your password and then a new obj folder will be created in your projects root directory, copy the file ending in .dylib from that folder and the .plist file from the root dir to your idevice under the directory:  /Library/MobileSubstrate/DynamicLibraries/
Then respring your device or reboot to enable it.
Alternatively, you can add the following line to your make file.


Then turn on ssh on your idevice and type in your mac terminal window:
$ sudo make package install


Finding Classes

To find classes you want to override, install Class Dump from cydia then using ssh or mobileterminal run the following command as root user (Type su and default password is alpine):

$ class-dump -H path/to/your/binary -o /path/where/you/want/your/classheaders

There’s a basic tutorial on the outline of making a cydia tweak, for more examples and tutorials look at my posts soon to come, Thanks for reading and hope this tutorial helped!

iPhone and Web Innovation