├── Coding-the-tweak-and-installing.md ├── Examining-and-changing.md ├── Installing-stuff.md ├── README.md └── Setting-up-the-project.md /Coding-the-tweak-and-installing.md: -------------------------------------------------------------------------------- 1 | First open up a terminal and cd to the root directory of you tweak (TextChangerTutorial/), then type ```make spm```, the output should be > Creating SPM config… and then nothing 2 | 3 | Now lets open *Tweak.x.swift* in the */Sources/TextChangerTutorial* directory there are 2 things in it *import Orion* and *import TextChangerTutorialC* 4 | The first thing imports orion from THEOS and the seconds imports your (currently none) obj.-c code 5 | 6 | So we have to start with some obj.-c to have ways to hook into the UI that you are trying to change, so go to */Sources/TextChangerTutorialC/include/Tweak.h*. Here is the simple code to do it: 7 | ``` 8 | #import 9 | 10 | @interface _UIStatusBarStringView : UILabel 11 | @end 12 | ``` 13 | Easy, save the file and go back to *Tweak.x.swift* make a class by doing: 14 | ``` 15 | class TextChangerHook: ClassHook { 16 | } 17 | ``` 18 | The part ```TextChangerHook:``` is the name of the class, ```ClassHook<>``` is the thing your class is and ```UILabel``` is what you are hooking into. 19 | 20 | Now make a function inside your class to execute: 21 | ``` 22 | func setText(_ text: String) { 23 | orig.setText("Hello world!") 24 | } 25 | ``` 26 | The ```setText()``` part is what the function should do and the ```"Hello world!"``` part is the text that overwrites ```UILabel```. 27 | Now your entire code should look like: 28 | ``` 29 | import Orion 30 | import TextChangerTutorialC 31 | 32 | class TextChangerHook: ClassHook { 33 | func setText(_ text: String) { 34 | orig.setText("Hello world!") 35 | } 36 | } 37 | ``` 38 | Now save everything and compile! open a terminal and cd to the root directory of the tweak again and type ```make do```, you are gonna get 1 error because you are not doing this over ssh, this does not matter because 39 | theos should have created a folder named *packages* with inside it a .deb file with your tweak. 40 | 41 | You can transfer the tweak to your device either by connecting it via usb or just mailing it to yourself. 42 | 43 | After this you can install it like normal and then respring, if springboard crashes try respring again, if it does again, check if you didnt make any mistakes 44 | 45 | ### You just created your first ever jailbreak tweak, hopefully of many. 46 | -------------------------------------------------------------------------------- /Examining-and-changing.md: -------------------------------------------------------------------------------- 1 | ## Examining what theos made for us and making changes 2 | Open the IDE you installed and open the folder with the name of your project (in my case TextChangerTutorial/ 3 | You will see some stuff and some errors in the corner, dont worry about them, click them away. 4 | 5 | Now lets take a look at the file structure THEOS has created for us and lets go over everything and change some stuff: 6 | 7 | ![image](https://github.com/alseenwalnoot/How-to-theos-swift/assets/124501148/2baaf89b-0b35-49b6-b604-c5a00d589a4b) 8 | 9 | The first thing *.build* doesnt matter and we dont have to go over it, 10 | 11 | The folder *Sources/* contains our actual code but then inside the folder you might think, *What is the difference between TextChangerTutorial and TextChangerTutorialC?*, well one contains the actual swift code: */Tweak.x.swift* 12 | and one contains objective-c: */include/module.modulemap*, */include/Tweak.h*, and */Tweak.m*, so why is there objective-c in our swift tweak? Well the hooks used to change stuff in ios are made in obj.-c and need to be translated to swift. 13 | 14 | The *control* file is used to tell your package manager what the tweak is and how it should handle it in debian language. Here is what a debian control file does (dont try to copy it! debian wont compile with //): 15 | ``` 16 | Package: com.walnutstudios.textchangertutorial //The bundle identifier, think of it as a name for a program but more low level 17 | Name: TextChangerTutorial //The name that your package manager will use as a name 18 | Version: 0.0.1 //This one is obvious, its the version, each time you recompile, the version increases 19 | Architecture: iphoneos-arm //The architecture of the device your trying to make a tweak for arm = rootfull package, arm64 = rootless package and arm64e is roothide packages 20 | Description: An awesome Orion tweak! //The description you will read when you go to install it 21 | Maintainer: dustin //The person who is updating the tweak/debugging it 22 | Author: dustin //The person who initialy made the tweak 23 | Section: Tweaks //Where you will find the tweak in a repo 24 | Depends: ${ORION}, firmware (>= 12.2) //Dependencies for your tweak 25 | ``` 26 | 27 | The *Makefile* this is one of the most important, because your tweak cant compile without it, first lets change the first and second line to: 28 | ``` 29 | TARGET := iphone:clang:latest:16.5 30 | THEOS_PACKAGE_SCHEME=rootless 31 | ``` 32 | This will tell theos for what it should compile. 33 | 34 | *Package.swift* This file is only needed for swift and we dont have to do anything in it. 35 | 36 | *TextChangerTutorial.plist* This is what your jailbreak/semi-jailbreak needs to know what to inject to, for now we can leave it as is. 37 | 38 | ## Go to the next step: [Coding the tweak and installing it](https://github.com/alseenwalnoot/How-to-theos-swift/blob/main/Coding-the-tweak-and-installing.md) 39 | -------------------------------------------------------------------------------- /Installing-stuff.md: -------------------------------------------------------------------------------- 1 | ### First things first, swift make sure you have swift installed (specificaly [5.8.1 RELEASE](https://download.swift.org/swift-5.8.1-release/ubuntu2204/swift-5.8.1-RELEASE/swift-5.8.1-RELEASE-ubuntu22.04.tar.gz), that works for me!). 2 | ### The swift website is REALLY unclear on how to install it so here is the guide to it: 3 | 4 | Step 1: get the swift tarball from above 5 | 6 | Step 2: Get the dependencies with ```sudo apt-get install \ 7 | binutils \ 8 | git \ 9 | gnupg2 \ 10 | libc6-dev \ 11 | libcurl4-openssl-dev \ 12 | libedit2 \ 13 | libgcc-9-dev \ 14 | libpython3.8 \ 15 | libsqlite3-0 \ 16 | libstdc++-9-dev \ 17 | libxml2-dev \ 18 | libz3-dev \ 19 | pkg-config \ 20 | tzdata \ 21 | unzip \ 22 | zlib1g-dev``` 23 | 24 | Step 3: Extract the tarball (you can do this with the ubuntu file manager or ```tar xzf swift-5.8.1-RELEASE-ubuntu22.04.tar.gz```) 25 | 26 | Step 4: Add /home/YOURUSERNAME/Downloads/swift-5.8.1-RELEASE-ubuntu22.04/usr/bin to path (you can also mv the swift directory to something easier if you dont want swift in your downloads, to do this do 27 | 28 | ```mv /home/YOURUSERNAME/Downloads/swift-5.8.1-RELEASE-ubuntu22.04 /home/YOURUSERNAME/Documents/swift``` 29 | 30 | where /home/YOURUSERNAME/Documents/swift is any place you want) to add it to your path do 31 | 32 | ```sudo nano .bashrc``` 33 | 34 | and at the end add ```export PATH=/YOUR/SWIFT/PATH/usr/bin:$PATH``` at the end, click CTRL+X, then y, then enter to save the .bashrc file. make sure after the swift path you have /usr/bin, because this is where the swift binaries are. 35 | 36 | Step 5: Reboot your computer to make swift added to your path. 37 | 38 | Step 6: ***"SANITY CHECK"*** to check if swift is installed run ```swift --version```, the output should be "Swift version 5.8.1 (swift-5.8.1-RELEASE) 39 | Target: x86_64-unknown-linux-gnu". 40 | 41 | ### Next, you need THEOS, here is how to install it: 42 | 43 | Step 1: Get the dependencies with ```sudo apt install bash curl```. 44 | 45 | Step 2: Install THEOS with ```bash -c "$(curl -fsSL https://raw.githubusercontent.com/theos/theos/master/bin/install-theos)"```, if it ask for some toolchain of sorts say y or yes. 46 | 47 | Step 3: After it is done, reboot. 48 | 49 | Step 4: ***"SANITY CHECK, again"*** do ```echo $THEOS``` the output should be "/home/YOURUSERNAME/theos" 50 | 51 | Step 5: Select the orion branch by first going to theos directory, ```cd $THEOS``` then do ```git fetch && git checkout orion && git submodule update --init```. 52 | 53 | ### You would also need the Orion tweak from chariz repo (or roothide repo if you are on bootstrap) installed on the device where you are gonna put your tweak 54 | 55 | ## Go to the next step: [Creating a project](https://github.com/alseenwalnoot/How-to-theos-swift/blob/main/Setting-up-the-project.md) 56 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # An in depth and MODERN tutorial on how to make tweaks for ios using swift, theos and orion in ubuntu, this will even work with something like serotonin and bootstrap 2 | ## for this tutorial i will be using ubuntu 22.04, it is possible in wsl but its stupidly hard to get it working since you dont have an gui, other distro's may also work but the commands will be different. 3 | 4 | ## NOTE: if your tweak doesnt compile it is because THEOS doesnt like ios 16.5 so you have to install the 14.5 sdk (it still works for most things) so download [this](https://github.com/theos/sdks/archive/master.zip) repo and move the iPhoneOS14.5.sdk into $THEOS/sdks 5 | 6 | ## We will be creating this tweak: it will make almost all text what you want! ![IMG_6322](https://github.com/alseenwalnoot/How-to-theos-swift/assets/124501148/60916570-5bdb-43ad-b772-07a13e484b81) 7 | 8 | ## The tutorials 9 | Step 0: [Installing stuff](https://github.com/alseenwalnoot/How-to-theos-swift/blob/main/Installing-stuff.md) 10 | Step 1: [Creating a project](https://github.com/alseenwalnoot/How-to-theos-swift/blob/main/Setting-up-the-project.md) 11 | Step 2: [Examining and making changes](https://github.com/alseenwalnoot/How-to-theos-swift/blob/main/Examining-and-changing.md) 12 | Step 3: [Coding the tweak and installing it](https://github.com/alseenwalnoot/How-to-theos-swift/blob/main/Coding-the-tweak-and-installing.md) 13 | 14 | if you need help or if something isnt working dm me on reddit u/Anonymous_16374 15 | 16 | ### This tutorial is far from done and i am gonna update it a bit more, but this is how you create the most basic of tweaks. 17 | 18 | ####### I Gotta give some credit to sourcelocation, his tutorial is most of my inspiration for this one, but its outdated and has no tutorials on how to install the tools. 19 | -------------------------------------------------------------------------------- /Setting-up-the-project.md: -------------------------------------------------------------------------------- 1 | #### To start a theos project run ```$THEOS/bin/nic.pl``` 2 | you will see something along the lines off: 3 | ``` 4 | NIC 2.0 - New Instance Creator 5 | ------------------------------ 6 | [1.] iphone/activator_event 7 | [2.] iphone/activator_listener 8 | [3.] iphone/application 9 | [4.] iphone/application_swift 10 | [5.] iphone/control_center_module-11up 11 | [6.] iphone/cydget 12 | [7.] iphone/flipswitch_switch 13 | [8.] iphone/framework 14 | [9.] iphone/library 15 | [10.] iphone/notification_center_widget 16 | [11.] iphone/notification_center_widget-7up 17 | [12.] iphone/preference_bundle 18 | [13.] iphone/preference_bundle_swift 19 | [14.] iphone/theme 20 | [15.] iphone/tool 21 | [16.] iphone/tool_swift 22 | [17.] iphone/tweak 23 | [18.] iphone/tweak_swift 24 | [19.] iphone/tweak_with_simple_preferences 25 | [20.] iphone/xpc_service 26 | [21.] iphone/xpc_service_modern 27 | Choose a Template (required): 28 | ``` 29 | for our tutorial we will select iphone/tweak_swift, so in this case 18, then you will get: 30 | ``` 31 | Project Name (required): 32 | ``` 33 | this is what you get to see in your package manager, i will do TextChangerTutorial 34 | ``` 35 | Package Name [com.yourcompany.textchangertutorial]: 36 | ``` 37 | this is what the .deb will be named, i will choose ```com.walnutstudios.textchangertutorial``` 38 | ``` 39 | Author/Maintainer Name [YOURUSERNAME]: 40 | ``` 41 | do something that people would call you on the internet (eg, your discord username) 42 | ``` 43 | [iphone/tweak_swift] MobileSubstrate Bundle filter [com.apple.springboard]: 44 | ``` 45 | this is what your tweak injects into, for this tutorial we can skip it and click enter. 46 | ``` 47 | [iphone/tweak_swift] List of applications to terminate upon installation (space-separated, '-' for none) [SpringBoard]: 48 | ``` 49 | if your tweak needs to reload an app/deamon after installing it, it should be specified here, we can just do - and click enter, thats it, you set up your first theos project! For me all of it is: 50 | ``` 51 | Choose a Template (required): 18 52 | Project Name (required): TextChangerTutorial 53 | Package Name [com.yourcompany.textchangertutorial]: com.walnutstudios.textchangertutorial 54 | Author/Maintainer Name [dustin]: 55 | [iphone/tweak_swift] MobileSubstrate Bundle filter [com.apple.springboard]: 56 | [iphone/tweak_swift] List of applications to terminate upon installation (space-separated, '-' for none) [SpringBoard]: - 57 | Instantiating iphone/tweak_swift in textchangertutorial/... 58 | Done. 59 | ``` 60 | 61 | ## Go to the next step: [Examining and making changes](https://github.com/alseenwalnoot/How-to-theos-swift/blob/main/Examining-and-changing.md) 62 | --------------------------------------------------------------------------------