iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
⚒️

[#1 Project Creation] Creating Tweaks for Jailbroken iOS Devices

に公開

Series Table of Contents

  • #0 Preparation Guide (Updated 2021/4/14)
  • #1 Project Creation (Updated 2021/4/14) ← Currently Reading
  • #2.1 Exploring Flex-related functions and more (Not yet written)
  • #2.2 Practical Hooking Guide (Same as above)
  • #3 Creating the Settings Screen
  • #4 Setting up Icons
  • #5.1 Creating Your Own Repository
  • #5.2 Distributing Your Tweak

(Please note that unwritten topics are planned and may change in the future.)
(In fact, there is a high possibility I may not write the rest, so please don't get your hopes up too high.)

About This Article

This article is a continuation of the previous one, Preparation Guide (Updated 2021/4/13). (However, you don't need to read it if you have already finished setting up the Theos environment.)

Creating the Project

Open your terminal and navigate to the parent directory where you want to create your project.
Example) If you want to create it in ~/Documents/myTweak, navigate to ~/Documents.

cd ~/Documents

Next, execute theos, for which we created an alias last time.

theos

A list of templates will appear.

Since we are making a Tweak with a very simple settings screen this time, select the iphone/tweak_with_simple_preferences template.
Enter 16 (since it was number 16 in this case). (Note: The numbering may differ from the time of writing if Theos has been updated with more templates.)

You will then be asked several questions as shown in the image below; answer them as follows.

Project Name (required): The name of your Tweak
Package Name [com.yourcompany.mytweak]: Unique ID for the Tweak (must not conflict with others). As shown in the example, if you have your own domain, something like com.mydomainname.mytweakname is recommended.
Author/Maintainer Name [------]: Your name or nickname.
[iphone/tweak_with_simple_preferences] MobileSubstrate Bundle filter [com.apple.springboard]: Just press Enter here.
[iphone/tweak_with_simple_preferences] List of applications to terminate upon installation (space-separated, '-' for none) [SpringBoard]: Just press Enter here as well.

Once finished, it will display:

Instantiating iphone/tweak_with_simple_preferences in mytweak/...
Done.

Project Configuration

Once you have created the project, open it in VSCode or a similar editor.
Upon opening the project, you should see files like the following:

About the Generated Files

Here is an explanation of the role of each file:

  • Preferences.plist: A file that specifies the UI for the settings screen.
  • control: A file containing information about the Tweak.
  • Makefile: A file containing information necessary for make.
  • [Tweak Name].plist: A file that (likely) specifies the target for hooking. If you want to target an app, change:
{ Filter = { Bundles = ( "com.apple.springboard" ); }; }

to

{ Filter = { Bundles = ( "The app's Bundle ID" ); }; }
  • Tweak.x: This is where you write the code that determines the Tweak's behavior. The language used is Logos, which adds various features to Objective-C for Tweak development. Therefore, having some knowledge of Objective-C will make things easier.

Makefile

If you leave it as is, compilation might fail depending on the target you are hooking into, so we will make a few changes to the Makefile.

Makefile
- TARGET := iphone:clang:latest:7.0
+ TARGET := iphone:clang:11.2:11.2
INSTALL_TARGET_PROCESSES = SpringBoard

+ THEOS_DEVICE_IP = 192.168.xxx.xxx(IP address of the jailbroken device)

include $(THEOS)/makefiles/common.mk

TWEAK_NAME = myTweak

myTweak_FILES = Tweak.x
myTweak_CFLAGS = -fobjc-arc

include $(THEOS_MAKE_PATH)/tweak.mk

To perform a regular compilation, use:

make

To package it into a deb file:

make package

If you want to create a deb for release, turning off debug options will compile it for production:

make package DEBUG=0

Using the following command will automatically install the Tweak to the device specified in THEOS_DEVICE_IP:

make package install

Note: You must have OpenSSH installed on the jailbroken device and be connected to the same Wi-Fi.

When you run this for the first time, you will be asked a question like this; select yes.
After that, you will be prompted for the jailbroken device's password (the default is alpine).
Once the correct password is entered, it will even handle the respring automatically.

Also, when you run make, a packages folder is created directly under the project file directory, and the generated deb files will be placed there.

Conclusion

This completes the project creation process.
Please let me know if there are any errors.

References

https://zunda-hack.com/2020:07/20/how-to-use-theos-for-ready/
https://zunda-hack.com/2020:07/21/how-to-use-theos-for-build/
https://tkgstrator.work/?p=1054#Makefile
https://gitra1n.com/Mojave/CustomNoOlderNotifications220/src/branch/master/Makefile
https://www.reddit.com/r/jailbreakdevelopers/comments/cvcud6/how_do_i_switch_theos_to_release_mode/

Previous Article

Next Article

None yet...

GitHubで編集を提案

Discussion