[Tutorial] Install Theos on Mac OS X for Jailbreak Development

Hi guys, Chris here and I thought I would create a follow-up blog post on how to install Theos but this time we will be installing it on your Mac OS X machine. There are a ton of perks to developing on a Mac machine rather than an iDevice for many different reasons and is the method in which I prefer! Before we get started we will need to download a few things:

  1. XCode 5.0 or newer (App Store)
  2. Homebrew
  3. iOS SDKs
  4. Header Files

Once we have both XCode and Homebrew installed, we will need to open up our Terminal window to install the latest Command Line Tools. To do this, simply type the following command into your active Terminal window:

xcode-select --install

A dialog should then appear. All you need to do now is click on Install and wait for the download and installation to complete. Once the installation has completed we will need to install dpkg and ldid using Homebrew which we downloaded previously. To do this, open up a new Terminal window and enter the following command:

brew install dpkg ldid

This should then download and install both packages. Once the packages have been installed, we can now install Theos to our desired directory. The most common directory, and the directory that I installed Theos in, would be ‘opt/theos’. What we will want to do is change our directory via Terminal to this directory. If you notice though, the opt folder is not visible so we need to run a command so we can view this folder. To do this, simply enter the following command into any active Terminal window:

sudo SetFile  -a  v  /opt

Once we have made our folder visible, we need to navigate to that folder via Terminal like so:

cd ../../opt

This will navigate backwards two directories to our root directory and then into the opt folder. Once we have navigated to this folder successfully, we need to run the following command to download Theos:

git clone --recursive https://github.com/theos/theos.git

This command will download and install Theos on our machine. Essentially, we are done at this point because Theos is installed but we will want to download the necessary files to start developing as well as setup some features to make it a little easier on us in the future!

The first thing we will want to do is edit our ‘~/.bash_profile‘ file. To do this, we need to run a Terminal command to allow us to open the file in TextEdit:

touch ~/.bash_profile; open ~/.bash_profile

Once the file has opened, add the following text to the end of the file:

#THEOS SETTINGS
export THEOS=/opt/theos
export PATH=$THEOS/bin:$PATH
export THEOS_DEVICE_IP=192.168.0.1 THEOS_DEVICE_PORT=22

The only thing you will need to change in the above text is the device IP address. You can find the IP address of your device by going into Settings > WiFi and then clicking on the (i) icon to the right of your network name.

At this point, we have successfully installed Theos but we will still need to download the header files needed for development as well as the target SDK we will be developing for. To download both, scroll to the top of the blog post and download the necessary files. Once they are downloaded we can now put them where we need them. To install the header files, copy all of the contents of the download into the following directory:

/opt/theos/include

Now that we have installed the headers, we now need to install the SDK files. To do so, simply copy and paste the downloaded file into the following directory and unzip the file:

/opt/theos/sdks

We should now be completely ready to start developing our first tweak! To check and see if we have successfully installed Theos, navigate to a directory we want to save our tweaks in and enter the following command:

$THEOS/bin/nic.pl

If all was done correctly, you should now see a menu displaying options like so:

If you have any questions, please feel free to leave a comment below or contact me via one of the options listed on the Contact page of my website!

[Tutorial] Install Theos on iDevice for Jailbreak Development

Hi guys, Chris here and I decided to go ahead and create a tutorial on how to setup Theos on your favorite iDevice if you are wanting to get into the world of jailbreak tweak development! When I was following other tutorials online they either weren’t detailed enough or they left out some very important details that I had to figure out for myself so I am creating this tutorial in hopes that I will cover everything and you all will be developing your very own tweaks in no time! That’s enough preface, so lets get started!

Before we start diving into this tutorial, we need to open our Cydia application and two different repos. Most everything needed else wise will be located on our default Cydia repos. If you don’t know how to add a repo to your Cydia that’s okay because I am going to tell you!

  1. Open Cydia from your Springboard
  2. Click on Sources located at the bottom of Cydia
  3. Next, click on Edit in the top right corner
  4. Then click the ‘+’ sign located in the top left corner

At this point we should now see a text input alert view on our screen This is where we are going to type in our repo address to add it to our sources. The repos we will be adding are as follows:

http://coolstar.org/publicrepo/
http://nix.howett.net/theos/

Once we have added these repos, we are ready to move on to the next step! Click on the Search icon located in the bottom rightmost corner of our Cydia app. It’s now time to start downloading the files needed to get Theos up and running on your iDevice! There are a few packages we need to download and they are as follows:

  • BigBoss Recommended Tools
  • Perl (Coolstar’s Repo)
  • iOS Toolchain
  • MTerminal
  • iFile
  • Theos (Howett’s Repo)

Now that we have all of the necessary files downloaded, its time to move on to the next step! Go back to your Springboard and locate the application iFile. Once you have found that, click on the application icon to launch.

Now that we are in iFile we should be looking at our root directory. If not, click on the center most icon located in the bottom navigation bar that looks like an open book and then click on Disk which should be the very first option. We now should see a list of files and folders located in our root directory. Scroll down until you see /var and click on that. If the installation of Theos was successful we should now see the following directory within the root of our device:

/var/theos/

Once we have confirmed that Theos is now installed we can celebrate a little but there is still more work to be done. Remember how we had to add a repo and install Perl from it? Well now you are going to see why. We need to go back into the root of our iDevice and navigate to the following path:

/usr/local/bin/

In that directory we should see a file called perl5.22.0. Once you have located that file, click on Edit in the top right corner and then select it. Now we need to click on the clipboard icon located in the bottom right of iFile and then click Copy/Link. Once we have copied the file we need to go back into our root directory and navigate to the following path:

/usr/bin/

Click on the Edit button once more and then click on Create Link. DO NOT click on paste. This step is extremely important! We do not want to simply paste it but create a SymLink to the original file. We should now have the file name perl5.22.0 located into our new directory. Click Edit again and the click on the blue (I) icon to rename our file. We want to change the name to “perl”. Once we have renamed our file we need to navigate to:

/var/theos/bin/

We need to find the file ‘bootstrap.sh’ When you have located the file click on it and open using a Text Viewer. Now we need to find the line of code that reads as such:

if [[ "$(uname -s)" == "Darwin" && "$(uname -p)" != "arm" ]]

We need to add 64 to the end of arm so it should now look something like this:

if [[ "$(uname -s)" == "Darwin" && "$(uname -p)" != "arm64" ]]

Once you have made that change, save the file and now we need to navigate to yet another directory. The directory we will be visiting now is:

/var/theos/makefile/targets/

We now need to find the folder named ‘Darwin-arm.’ Once you have located the folder, click on Edit and then click on the blue (I) icon once more. We need to rename this folder to ‘Darwin-arm64.‘ Now that we have renamed our folder, we need to once again navigate to a different directory. The directory is:

/var/theos/makefiles/platform/

There should only be one file located in this folder called ‘Darwin-arm.‘ We need to simply add 64 to the end of that filename resulting in ‘Darwin-arm64.‘ Now that we have made Theos compatible with arm64 devices, we can now download the SDK files corresponding to our current iOS version. The highest jailbreakable iOS version at the time of this post is iOS 9.3.3 so that will be what I use as an example for this tutorial.

Open your Safari app and navigate to the following website:

https://sdks.website/

We now need to find the iOS 9.3 SDK and click on Download. When you click download, a new tab should appear showing us a file to download. Since we have iFile installed we should see a link that says ‘Open in iFile.‘ This is exactly what we want! Click on that and it should open iFile for us automatically. We now need to click on Edit and Copy the file. Once you have the file copied to the clipboard, we again need to navigate to a different directory. That directory is:

/var/theos/

If you have a folder called ‘sdks‘, perfect! If not, we need to create that folder. Once you have created the folder click on it to navigate inside. We then need to click on Edit and then Paste the file into that folder. Now that the .zip file has been successfully copied into that folder, click on it and click Unarchiver to extract the SDK into that folder.

If you have made it this far then you are dedicated and want to start developing your very own tweaks so I commend you for that! I am going to simplify this next part of the tutorial by creating a list of commands we need to enter into Terminal to finish setting up Theos. Now we need to open up Terminal and login to our device by typing the following:

su
Password: alpine

Now I am going to show you the list of commands to enter. Please note that after each command, you must click the Return/Enter button on your keyboard to sent that system command to your device. The commands are:

cd /usr/bin
ldid -s clang
ldid -s clang++
cd /var/mobile

Now that we have successfully ran all of those commands, we are now ready to launch Theos and get started on making our very first tweak! To do this we need to open Terminal and navigate to any directory we want to create our project in. I would recommend creating a new folder in your Documents directory called Development so you can better keep track of everything. To do this, open iFile and click on the ‘open book’ icon and then click on Documents. Then click on Edit and then the ‘+’ icon in the bottom left. Change the type to Directory and name it how you wish. Then in Terminal we need to run he following command to get to our Development folder:

cd /var/mobile/Documents/Development

Now that we are in the directory we want to create our tweak in, we need to run this command to show us our Theos menu:

/var/theos/bin/nic.pl

If a menu appears showing us option to choose from then we have successfully installed Theos and can now start developing our tweaks! If you don’t want to run that command every time your create a new tweak, there is a simple trick to use so you can simply just type ‘Theos‘ and the menu will appear. To do this follow these steps:

  1. Open iFile
  2. Navigate to /bin
  3. Once there, create a file named theos
  4. Now open that file using a Text Viewer and then enter the command used to show the theos menu (/var/theos/bin/nic.pl)
  5. Save the file and then close iFile

Now whenever we are inside of a folder we can simply just type ‘theos’ and the Theos menu will appear!

I hope you have learned how to setup Theos on your iDevice today and if you have any questions, feel free to drop a comment and let me know and I will try my best to answer any questions you may have!

 

Welcome to my world!

If you have found yourself here I would like to say thank you! I hope that you will find what you are looking for here on my website and continue to come back for more! My goal is to not only showcase my portfolio but to also teach other developers along the way.

I plan to post programming tutorials and anything technological here and hope to not only teach other developers some tricks but also learn from you guys as well. So again, thank you very much for stopping by and let’s get to work!