### Install Prerequisites for Theos Source: https://theos.dev/docs/installation-ios Installs essential command-line tools required for Theos. Run this as root. ```bash apt-get install bash curl sudo coreutils xz-utils ``` -------------------------------- ### Example Header File Source: https://theos.dev/docs/logify.pl This is an example of an Objective-C header file for the SSDownloadAsset class. ```objective-c @interface SSDownloadAsset : NSObject - (NSString *)finalizedPath; - (NSString *)downloadPath; - (NSString *)downloadFileName; + (id)assetWithURL:(id)url type:(int)type; - (id)initWithURLRequest:(id)urlrequest type:(int)type; - (id)initWithURLRequest:(id)urlrequest; - (id)_initWithDownloadMetadata:(id)downloadMetadata type:(id)type; @end ``` -------------------------------- ### Run Theos Installer Script Source: https://theos.dev/docs/installation-ios Downloads and executes the official Theos installation script. Run this as a normal user. ```bash bash -c "$(curl -fsSL https://raw.githubusercontent.com/theos/theos/master/bin/install-theos)" ``` -------------------------------- ### NIC Configuration Example Source: https://theos.dev/docs/nic Example of a .nicrc file showing how to set package prefix, skip package name prompt, and specify username. ```ini package_prefix = "ws.hbang" skip_package_name = 0 username = "HASHBANG Productions " ``` -------------------------------- ### Example NIC Control File Source: https://theos.dev/docs/nic-syntax This example shows how to define a template name, constrain a file to package creation, and prompt the user for input with a default value. ```nic name "Awesome Template" constrain "control" to package prompt PIES "Number of Pies to create" "10" ``` -------------------------------- ### Install Legacy Theos Templates Source: https://theos.dev/docs/nic Use this command to clone and install the legacy templates module for Theos. ```bash git clone 'https://github.com/theos/templates-legacy.git' "${THEOS}/mod/templates-legacy" ``` -------------------------------- ### Install Prerequisites on SUSE-based Linux Source: https://theos.dev/docs/installation-linux Installs essential packages like bash, curl, and sudo on openSUSE and similar distributions. Run as root. ```bash zypper install bash curl sudo ``` -------------------------------- ### Install GNU Make using Homebrew Source: https://theos.dev/docs/parallel-building Use this command to install the latest version of GNU Make via Homebrew. ```bash brew install make ``` -------------------------------- ### Initialize Theos Git Submodules Source: https://theos.dev/docs/upgrading-from-legacy-theos After updating your Theos installation, run this command to clone and initialize all necessary Git submodules. ```bash $ git submodule update --init --recursive ``` -------------------------------- ### Install Prerequisites on Debian-based Linux Source: https://theos.dev/docs/installation-linux Installs essential packages like bash, curl, and sudo on Debian, Ubuntu, and similar distributions. Run as root. ```bash apt install bash curl sudo ``` -------------------------------- ### Install Theos Script Source: https://theos.dev/docs/installation-macos Run this command in your terminal to download and execute the official Theos installer script for macOS. ```bash bash -c "$(curl -fsSL https://raw.githubusercontent.com/theos/theos/master/bin/install-theos)" ``` -------------------------------- ### Clone iOS Toolchain for 32-bit Windows Source: https://theos.dev/docs/installation-cygwin Clones the iOS toolchain specifically for 32-bit Windows installations. This is part of the deprecated Cygwin setup. ```bash git clone https://github.com/coolstar/iOSToolchain4Win.git $THEOS/toolchain/windows/iphone ``` -------------------------------- ### Example Module Structure Source: https://theos.dev/docs/modules A typical directory structure for a Theos module. Each .mk file can contain custom build rules and variables. ```makefile my-module/ ├── instance │ ├── framework.mk │ ├── library.mk │ └── rules.mk ├── package │ └── deb.mk └── package.mk ``` -------------------------------- ### Install Prerequisites on Arch-based Linux Source: https://theos.dev/docs/installation-linux Installs essential packages like bash, curl, and sudo on Arch, Manjaro, and similar distributions. Run as root. ```bash pacman -S --needed bash curl sudo ``` -------------------------------- ### Install Prerequisites on Red Hat-based Linux Source: https://theos.dev/docs/installation-linux Installs essential packages like bash, curl, and sudo on Fedora, CentOS, and similar distributions. Run as root. ```bash dnf install bash curl sudo ``` -------------------------------- ### Clone iOS Toolchain for 64-bit Windows Source: https://theos.dev/docs/installation-cygwin Clones the iOS toolchain for 64-bit Windows installations using the x86_64 branch. This is part of the deprecated Cygwin setup. ```bash git clone -b x86_64 https://github.com/coolstar/iOSToolchain4Win.git $THEOS/toolchain/windows/iphone ``` -------------------------------- ### Schema Configuration Example Source: https://theos.dev/docs/configuration Define a custom schema to modify compiler flags. Enabling 'schema1' will add '-DSCHEMA1ENABLED' to CFLAGS. ```makefile # Enabling schema1 will add the '-DSCHEMA1ENABLED' additional compiler flags. schema1.CFLAGS = -DSCHEMA1ENABLED ``` -------------------------------- ### Run Theos Troubleshoot Command Source: https://theos.dev/docs/help Execute `make troubleshoot` within a project directory to upload diagnostic information to GitHub Gist. Ensure the `gh` CLI tool is installed beforehand. ```bash make troubleshoot ``` -------------------------------- ### Generated Logos Tweak Example Source: https://theos.dev/docs/logify.pl The output generated by logify.pl, which includes hooks for each method in the header file with logging and original call wrappers. ```objective-c %hook SSDownloadAsset - (NSString *)finalizedPath { %log; NSString * r = %orig; NSLog(@" = %@", r); return r; } - (NSString *)downloadPath { %log; NSString * r = %orig; NSLog(@" = %@", r); return r; } - (NSString *)downloadFileName { %log; NSString * r = %orig; NSLog(@" = %@", r); return r; } + (id)assetWithURL:(id)url type:(int)type { %log; id r = %orig; NSLog(@" = %@", r); return r; } - (id)initWithURLRequest:(id)urlrequest type:(int)type { %log; id r = %orig; NSLog(@" = %@", r); return r; } - (id)initWithURLRequest:(id)urlrequest { %log; id r = %orig; NSLog(@" = %@", r); return r; } - (id)_initWithDownloadMetadata:(id)downloadMetadata type:(id)type { %log; id r = %orig; NSLog(@" = %@", r); return r; } %end ``` -------------------------------- ### Download and Extract iOS SDKs Source: https://theos.dev/docs/installation-cygwin Downloads the master zip archive of Theos SDKs, extracts it to a temporary directory, moves the SDK to the Theos installation, and cleans up temporary files. This is for obtaining an iOS SDK for the toolchain. ```bash curl -LO https://github.com/theos/sdks/archive/master.zip TMP=$(mktemp -d) unzip master.zip -d $TMP mv $TMP/sdks-master/*.sdk $THEOS/sdks rm -r master.zip $TMP ``` -------------------------------- ### XML Filter Property List Example Source: https://theos.dev/docs/packaging This XML format is used for the filter property list. It specifies which bundles, executables, or classes should trigger the loading of your tweak. ```xml Filter Bundles some.bundle.id Executables executable-name Classes class-name ``` -------------------------------- ### NeXTSTEP (Text) Filter Property List Example Source: https://theos.dev/docs/packaging This text-based format, also known as NeXTSTEP format, provides an alternative way to declare the filter property list. It achieves the same filtering as the XML version. ```text { Filter = { Bundles = ( "some.bundle.id" ); Executables = ( "executable-name" ); Classes = ( "class-name" ); }; } ``` -------------------------------- ### Get Rootless Path for Objective-C Strings Source: https://theos.dev/docs/rootless Use ROOT_PATH_NS to obtain the correct prefix for Objective-C strings when working with rootless jailbreaks. This function is provided by libroot. ```objective-c #import NSString *dylibPath = ROOT_PATH_NS(@"/Library/MobileSubstrate/DynamicLibraries/libFLEX.dylib"); ``` -------------------------------- ### Custom Linker Flags in Module Source: https://theos.dev/docs/modules Example of adding custom linker flags within a module's Makefile. This snippet demonstrates modifying `_THEOS_INTERNAL_LDFLAGS`. ```makefile _THEOS_INTERNAL_LDFLAGS += -rpath my/path/here/ -rpath $(THEOS_PACKAGE_INSTALL_PREFIX)/Library/Frameworks -rpath $(THEOS_PACKAGE_INSTALL_PREFIX)/usr/lib ``` -------------------------------- ### Creating a Project with NIC Command-Line Arguments Source: https://theos.dev/docs/nic Automate project creation using NIC by specifying template, name, package name, and author via command-line arguments. This avoids interactive prompts for these details. ```bash # Example using --template and --name $THEOS/bin/nic.pl -t iphone/tweak -n MyTweak # Example using --nic and --packagename $THEOS/bin/nic.pl --nic /path/to/my.nic.tar --packagename com.mycompany.myapp # Example using --user $THEOS/bin/nic.pl -u "My Name " ``` -------------------------------- ### Creating a Theos Template Archive Source: https://theos.dev/docs/nic Use nicify.pl to create a .nic.tar archive from a project directory. This command bundles the modified template files. ```bash ~$ $THEOS/bin/nicify.pl tweak/ ``` -------------------------------- ### Interactive Project Creation with NIC Source: https://theos.dev/docs/nic Use NIC interactively to create a new project by selecting a template and providing project details. Defaults can be accepted by pressing Enter. ```bash ~$ $THEOS/bin/nic.pl NIC 2.0 - New Instance Creator ------------------------------ [1.] iphone/application_modern [2.] iphone/application_swift_modern [3.] iphone/application_swiftui [4.] iphone/control_center_module-11up [5.] iphone/framework [6.] iphone/library [7.] iphone/null [8.] iphone/preference_bundle [9.] iphone/preference_bundle_swift [10.] iphone/theme [11.] iphone/tool [12.] iphone/tool_swift [13.] iphone/tweak [14.] iphone/tweak_swift [15.] iphone/tweak_with_simple_preferences [16.] iphone/xpc_service_modern Choose a Template (required): 13 Project Name (required): Example Package Name [com.yourcompany.example]: dev.theos.example Author/Maintainer Name [Craig Federighi]: Craig Federighi [iphone/tweak] MobileSubstrate Bundle filter [com.apple.springboard]: [iphone/tweak] List of applications to terminate upon installation (space-separated, '-' for none) [SpringBoard]: Instantiating iphone/tweak in example/... Done. ~$ cd example ~/example$ ls Example.plist Makefile Tweak.x control ``` -------------------------------- ### Listing Created Template Archives Source: https://theos.dev/docs/nic This command lists the generated .nic.tar archive files. ```bash ~$ ls *.nic.tar ``` -------------------------------- ### logify.pl Command Line Usage Source: https://theos.dev/docs/logify.pl Shows the basic usage and available options for the logify.pl command-line tool, including include and exclude flags for specific methods. ```bash Usage: logify.pl [options] filename ... Options: [-i|--include] Comma-separated list of methods to include -i "launchedTaskWithLaunchPath:arguments:,arguments" (for example) [-e|--exclude] Comma-separated list of methods to exclude -e "launchedTaskWithLaunchPath:arguments:,arguments" (for example) [-h|--help] Display this page ``` -------------------------------- ### NIC->mkdir Source: https://theos.dev/docs/nic-syntax Creates a new Directory with the specified name and mode in the template archive. Returns the newly created Directory object. ```APIDOC ## NIC->mkdir ### Description Create a new Directory with the given name and, optionally, mode. ### Method _method_ ### Parameters #### Path Parameters - **name** (string) - Required - The name of the new directory. - **mode** (string) - Optional - The mode for the new directory. Defaults to `0755`. ### Response #### Success Response - **Directory** - The newly-created Directory object. ``` -------------------------------- ### Create Directory and Update File Name Source: https://theos.dev/docs/nic-syntax This snippet demonstrates how to create a directory based on a package name and then update a file's name to include this new directory path. It uses NIC->mkdir to create the directory and string manipulation to form the new file path. ```perl my $packageName = NIC->variable("PACKAGENAME"); my $packageDirectory = $packageName; # Transform the package name into a package directory, replacing . with / (s!old!new!g acts as a search and replace). $packageDirectory =~ s!\.!/!g; # Create a new directory entry with the name we just transformed. my $directory = NIC->mkdir($packageDirectory); # Look up the file "main.m" and set its name to include the new path. NIC->lookup("main.m")->name = $directory->name . "/main.m"; ``` -------------------------------- ### Get Pointer to Original Function/Method Source: https://theos.dev/docs/logos-syntax Use &%orig to obtain a pointer to the original hooked function or method. This pointer can be called explicitly. ```objective-c &%orig ``` ```objective-c // Call from outside hooked method: void (*orig_ClassName_start)(id, SEL) = nil; void doStuff(id self, SEL _cmd) { if (self && orig_ClassName_start) { orig_ClassName_start(self, _cmd); } } %hook ClassName - (void)start { %orig; orig_ClassName_start = &%orig; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ doStuff(self, _cmd); }); } %end // Call with another object: %hook ClassName - (int)add:(int)a to:(int)b { int (*_orig)(id, SEL, int, int) = &%orig; ClassName * myObject = [ClassName new]; int r = _orig(myObject, _cmd, 1, 2); [myObject release]; return r; } %end ``` -------------------------------- ### Logos Command Line Usage Source: https://theos.dev/docs/logos Displays the usage instructions for the logos.pl command-line tool, including available options for configuration and help. ```bash Usage: logos.pl [options] Options: [-c|--config] Modify Logos' configuration (MobileSubstrate, default) -c generator=[internal|libhooker|MobileSubstrate] -c warnings=[default|error|none] [-h|--help] Display this page ``` -------------------------------- ### NIC->mkfile Source: https://theos.dev/docs/nic-syntax Creates a new File with the specified name and mode in the template archive. Returns the newly created File object. ```APIDOC ## NIC->mkfile ### Description Create a new File with the given name and, optionally, mode. ### Method _method_ ### Parameters #### Path Parameters - **name** (string) - Required - The name of the new file. - **mode** (string) - Optional - The mode for the new file. Defaults to `0644`. ### Response #### Success Response - **File** - The newly-created File object. ``` -------------------------------- ### dm.pl Command Line Usage Source: https://theos.dev/docs/dm.pl This snippet shows the basic usage and available options for the dm.pl command-line tool. It details how to specify the input directory, output package name, and various compression settings. ```bash Usage: dm.pl [options] Options: -b This option exists solely for compatibility with dpkg-deb. -Z Specify the package compression type. Valid values are gzip (default), bzip2, lzma, xz and cat (no compression). -z Specify the package compression level. Valid values are between 0 and 9. Default is 9 for bzip2, 6 for others, and 0 is equivalent to cat. Refer to gzip(1), bzip2(1), xz(1) for explanations of what effect each compression level has. --help, -? Print a brief help message and exit. --man Print a manual page and exit. ``` -------------------------------- ### Using logify.pl to Generate Logos Tweak Source: https://theos.dev/docs/logify.pl This command demonstrates how to use logify.pl with a header file to generate a Logos tweak for logging method calls. ```bash $THEOS/bin/logify.pl ./SSDownloadAsset.h ``` -------------------------------- ### Listing Extracted Template Files Source: https://theos.dev/docs/nic After extraction, this command shows the files within the created template directory. ```bash ~$ ls tweak/ ``` -------------------------------- ### Initialize Method and Function Hooks Source: https://theos.dev/docs/logos-syntax Use %init to initialize method and function hooks. It can initialize the default group, substitute expressions for classes, or initialize specific groups. ```objective-c %init; ``` ```objective-c %init([=, …]); ``` ```objective-c %init(GroupName[, [+|-]=, …]); ``` ```objective-c %hook ClassName - (id)init { return %orig; } %end %ctor { %init(ClassName=objc_getClass("SwiftApp.ClassName")); } ``` -------------------------------- ### Initialize Logos Group Across Files Source: https://theos.dev/docs/logos-hook-splitting This snippet demonstrates how to initialize a Logos group in one file and call it from another. It includes the group definition and the static C function to trigger initialization. ```objective-c // Group.xm #import "Shared.h" %group TweakGroup %hook SpringBoard - (void)applicationDidFinishLaunching:(id)arg1 { %orig; NSLog(@"[Group Test] SpringBoard has finished launching"); } %end %end extern "C" void InitGroup() { %init(TweakGroup); } ``` -------------------------------- ### Theos Object Directory Structure Source: https://theos.dev/docs/concepts Illustrates the directory structure for object files within Theos projects, including schema, architecture, and instance-specific subdirectories. ```makefile .theos/ obj/ $(THEOS_SCHEMA)/ $(THEOS_CURRENT_ARCH)/ $(THEOS_CURRENT_INSTANCE) ``` -------------------------------- ### Call Group Initialization from Constructor Source: https://theos.dev/docs/logos-hook-splitting This snippet shows how to import the shared header and call the `InitGroup` function from a constructor (`%ctor`). This initializes the Logos group defined in a separate file. ```objective-c // Tweak.xm #import "Shared.h" %ctor { NSLog(@"[Group Test] Our hook for SpringBoard should show up below this"); InitGroup(); } ``` -------------------------------- ### Define a Runtime Subclass with Properties Source: https://theos.dev/docs/logos-syntax Use %subclass to create a new Objective-C class at runtime. Properties can be added using %property, and new methods using %new. Instantiate with %c. ```objective-c %subclass ClassName: Superclass /* %properties and methods */ %end ``` ```objective-c // An interface is required to be able to call methods of the runtime subclass using block syntax. @interface MyObject : NSObject @property (nonatomic, retain) NSString * someValue; @end %subclass MyObject : NSObject %property (nonatomic, retain) NSString * someValue; - (instancetype)init { if ((self = %orig)) { [self setSomeValue:@"value"]; } return self; } %end %ctor { // The runtime subclass cannot be linked at compile time so you have to use %c(). MyObject *myObject = [[%c(MyObject) alloc] init]; NSLog(@"myObject: %@", [myObject someValue]); } ``` -------------------------------- ### File Class Source: https://theos.dev/docs/nic-syntax Represents a file in the template, inheriting from NICType. ```APIDOC ## File ### Description Represents a file in the template. ### Properties - **data** (string) - read/write - The file’s data. ``` -------------------------------- ### Update Theos using the script Source: https://theos.dev/docs/installation Run this command to update Theos to the latest version from the Git repository. Ensure you have the necessary permissions. ```bash $THEOS/bin/update-theos ``` -------------------------------- ### Directory Class Source: https://theos.dev/docs/nic-syntax Represents a directory in the template, inheriting from NICType. ```APIDOC ## Directory ### Description Represents a directory in the template. ### Methods _Contains no additional methods._ ``` -------------------------------- ### Update Theos using make Source: https://theos.dev/docs/installation If the update-theos script is unavailable, navigate to a directory with a Theos makefile and use this command to update. This is an alternative method for updating Theos. ```bash make update-theos ``` -------------------------------- ### File Acquisition with `find` Command in Makefile Source: https://theos.dev/docs/configuration Leverage the `$(shell find ...)` function to execute the `find` command for locating files, especially useful for complex directory structures when pattern matching is insufficient. ```makefile XXX_FILES = $(shell find . -type f -name "*.m") ``` -------------------------------- ### Generate Function Hook with %hookf Source: https://theos.dev/docs/logos-syntax Use %hookf to generate a function hook. The function name can be set in %init for dynamic lookup. This allows for hooking C functions. ```c FILE *fopen(const char *path, const char *mode); ``` ```logos %hookf(FILE *, fopen, const char *path, const char *mode) { puts("Hey, we're hooking fopen to deny relative paths!"); if (path[0] != '/') { return NULL; } return %orig; // Call the original implementation of this function } ``` ```logos %hookf(BOOL, MGGetBoolAnswer, CFStringRef string) { if (CFEqual(string, CFSTR("StarkCapability"))) { return YES; } return %orig; } ``` ```logos %ctor { %init(MGGetBoolAnswer = MSFindSymbol(NULL, "_MGGetBoolAnswer")); } ``` -------------------------------- ### GNU Make Info Directive Source: https://theos.dev/docs/configuration Use the `$(info ...)` directive in your Makefile to print informational messages during the build process. These messages are displayed directly. ```makefile $(info some text here) ``` -------------------------------- ### Header for Cross-File Group Initialization Source: https://theos.dev/docs/logos-hook-splitting This header file declares the `InitGroup` function, which is used to initialize the Logos group defined in another file. It must be imported into the main Logos file. ```objective-c // Shared.h #import extern "C" void InitGroup(); ``` -------------------------------- ### Conditional Build Settings for Rootful vs. Rootless Source: https://theos.dev/docs/rootless Conditionally set build architectures and deployment targets in your Makefile based on the THEOS_PACKAGE_SCHEME variable. This allows for distinct configurations for rootless and rootful builds. ```makefile ifeq ($(THEOS_PACKAGE_SCHEME),rootless) ARCHS = arm64 arm64e TARGET = iphone:clang:latest:15.0 else ARCHS = armv7 armv7s arm64 arm64e TARGET = iphone:clang:latest:7.0 endif ``` -------------------------------- ### NIC->symlink Source: https://theos.dev/docs/nic-syntax Creates a new Symbolic Link pointing to a target. The target can be a NICType object or a string. Returns the newly created Symlink object. ```APIDOC ## NIC->symlink ### Description Create a new Symbolic Link with the given name pointing to the given target. ### Method _method_ ### Parameters #### Path Parameters - **target** (NICType or string) - Required - The target of the symbolic link. Can be a NICType object or a string. - **destination** (string) - Required - The name of the symbolic link to create. ### Response #### Success Response - **Symlink** - The newly-created Symlink object. ``` -------------------------------- ### Prepend Homebrew Make to PATH (Bash) Source: https://theos.dev/docs/parallel-building For macOS versions earlier than 10.15 Catalina, use this command to prepend Homebrew Make to your PATH in the Bash profile. ```bash echo PATH="$(brew --prefix make)/libexec/gnubin:$PATH" >> ~/.bash_profile ``` -------------------------------- ### NIC->lookup Source: https://theos.dev/docs/nic-syntax Finds an existing File, Directory, or Symbolic Link in the template archive by its name. Returns the NICType object on success or undef on failure. ```APIDOC ## NIC->lookup ### Description Find an existing File, Directory or Symbolic Link in the template archive. ### Method _method_ ### Parameters #### Path Parameters - **name** (string) - Required - The name of the file, directory, or symbolic link to find. ### Response #### Success Response - **NICType** - The retrieved NICType object (File, Directory, or Symlink). #### Error Response - **undef** - Returned on failure. ``` -------------------------------- ### Log Method Arguments Source: https://theos.dev/docs/logos-syntax Use %log to dump method arguments to syslog. Typed arguments can be included for more detailed logging. ```objective-c %log; ``` ```objective-c %log[(), …]); ``` -------------------------------- ### Clone Theos Repository Source: https://theos.dev/docs/installation-cygwin Clones the Theos repository recursively to the directory specified by the THEOS environment variable. ```bash git clone --recursive https://github.com/theos/theos.git $THEOS ``` -------------------------------- ### Export Variables for All Project Instances in Makefile Source: https://theos.dev/docs/configuration Use the `export` keyword to make a variable apply to all instances within a project, including subprojects. This avoids duplicate declarations in subproject Makefiles. ```makefile export TARGET = iphone:clang:latest:12.0 ``` -------------------------------- ### Extracting a Theos Template Archive Source: https://theos.dev/docs/nic Use denicify.pl to extract a .nic.tar archive into a project directory. This command unpacks the template files for modification. ```bash ~$ $THEOS/bin/denicify.pl $THEOS/templates/ios/theos/tweak.nic.tar tweak ``` -------------------------------- ### Makefile Rule Definition Source: https://theos.dev/docs/configuration Define custom commands for specific build stages by appending rules to your project's Makefile. These rules can hook into Theos's build process. ```makefile rule-name:: your_command your_command ``` -------------------------------- ### Set arm64e Deployment Target to iOS 14.0+ Source: https://theos.dev/docs/arm64e-deployment Use this Makefile export to specify building for iOS 14.0 and newer when arm64e compatibility is required. ```makefile export TARGET = iphone:latest:14.0 ``` -------------------------------- ### Generate Anonymous Constructor with %ctor Source: https://theos.dev/docs/logos-syntax Use %ctor to generate an anonymous constructor. This function executes after the binary is loaded into memory. ```logos %ctor { /* body */ } ``` -------------------------------- ### Theos Link Configuration Source: https://theos.dev/docs/nic Configuration options for managing Theos symlinks and environment variables. ```ini link_theos = 0 ignore_parent_theos = 0 ``` -------------------------------- ### Call Original Hooked Function/Method Source: https://theos.dev/docs/logos-syntax Use %orig to call the original hooked function or method. Arguments can be passed, but 'self' and '_cmd' are handled automatically. Not compatible with %new'd methods. ```objective-c %orig ``` ```objective-c %orig(args, …) ``` ```objective-c %hook ClassName - (int)add:(int)a to:(int)b { if (a != 0) { // Return original result if `a` is not 0 return %orig; } // Otherwise, use 1 as `a` return %orig(1, b); } %end ``` -------------------------------- ### Prepend Homebrew Make to PATH Source: https://theos.dev/docs/parallel-building Add the Homebrew Make executable to your PATH environment variable to ensure it takes precedence over the system's version. This command modifies the Zsh profile. ```bash echo PATH="$(brew --prefix make)/libexec/gnubin:$PATH" >> ~/.zprofile ``` -------------------------------- ### Conditional Statements in Makefile Source: https://theos.dev/docs/configuration Implement conditional logic using `ifeq`, `ifneq`, `ifdef`, and `ifndef` for complex configuration scenarios. Ensure all conditions are closed with `endif`. ```makefile ifeq ($(variable), $(variable-to-check-against)) something=0 else ifneq ($(variable2), $(variable-to-check-against)) something=1 else ifdef ($(variable3)) something=2 else ifndef ($(variable4)) something=3 else something=4 endif ``` -------------------------------- ### File Acquisition with Wildcards in Makefile Source: https://theos.dev/docs/configuration Employ the `$(wildcard pattern)` function to find files matching a specified pattern. This is useful for projects with many files or complex directory structures. ```makefile $(wildcard pattern-to-match) ``` ```makefile XXX_FILES = $(wildcard *.m) $(wildcard files/*.x) ``` -------------------------------- ### Add New Objective-C Method with %new Source: https://theos.dev/docs/logos-syntax Use %new to add a new method to a hooked class or subclass. A method signature can be provided; otherwise, one will be generated. This must be within a %hook or %subclass block. ```logos %new - (void)handleTapGesture:(UITapGestureRecognizer *)gestureRecognizer { NSLog(@"Received tap: %@", gestureRecognizer); } ``` ```logos %new(signature) /* objc method */ ``` -------------------------------- ### Re-enable Theos Symlink Source: https://theos.dev/docs/faq Configure Theos to revert to using a symlink for 'theos' by adding 'link_theos = "1"' to your ~/.config/theos/nicrc file. This changes how Theos is accessed. ```bash $ echo 'link_theos = "1"' >> ~/.config/theos/nicrc ``` -------------------------------- ### Set Local Project Variables in Makefile Source: https://theos.dev/docs/configuration Declare variables directly to keep them local to their project instance. This is the standard way to configure variables for a specific project. ```makefile ARCHS = arm64 arm64e ``` -------------------------------- ### Symlink Class Source: https://theos.dev/docs/nic-syntax Represents a symbolic link in the template, inheriting from NICType. ```APIDOC ## Symlink ### Description Represents a symbolic link in the template. ### Properties - **target** (NICType or string) - read/write - The target of the symbolic link, as either a reference to a `NICType` object or a string. ```