Theos for armv7 and arm64
Categories:
Building Tweaks for armv7 and arm64 with Theos

Learn how to configure Theos to compile your Objective-C tweaks for both 32-bit (armv7) and 64-bit (arm64) iOS architectures, ensuring broad device compatibility for jailbroken devices.
Developing tweaks for jailbroken iOS devices requires careful consideration of the target architecture. Modern iOS devices primarily use 64-bit (arm64) processors, but many older, still-jailbreakable devices operate on 32-bit (armv7) architectures. To ensure your tweaks reach the widest possible audience, it's crucial to compile them for both. This article will guide you through configuring Theos, the popular tweak development suite, to support both armv7 and arm64 architectures.
Understanding iOS Architectures: armv7 vs. arm64
Before diving into Theos configuration, it's important to understand the distinction between armv7 and arm64. armv7 refers to the 32-bit ARM instruction set used in devices like the iPhone 4S, iPhone 5, and iPad 2/3/4. arm64, on the other hand, is the 64-bit ARM instruction set introduced with the iPhone 5S and later devices. Compiling for both means your tweak can run natively on a broader range of jailbroken devices, from older A5/A6 chips to the latest A-series processors.
flowchart TD A[Tweak Source Code] --> B{Theos Compilation} B --> C{Target Architecture?} C -->|armv7| D[armv7 Binary] C -->|arm64| E[arm64 Binary] D & E --> F[Universal Binary (Fat Binary)] F --> G[Cydia/Sileo Distribution] G --> H[Jailbroken Device (armv7 or arm64)]
Theos Compilation Flow for Universal Binaries
Configuring Theos for Multi-Architecture Support
Theos simplifies multi-architecture compilation through its Makefile
system. The primary variable you'll interact with is ARCHS
. By default, Theos might only compile for arm64 on newer setups. To include armv7, you need to explicitly define both architectures in your project's Makefile
.
ARCHS = armv7 arm64
TARGET = iphone:clang:11.0:7.0
include $(THEOS)/makefiles/common.mk
TWEAK_NAME = MyUniversalTweak
MyUniversalTweak_FILES = Tweak.xm
MyUniversalTweak_FRAMEWORKS = UIKit
include $(THEOS_MAKE_FILES)/tweak.mk
Example Theos Makefile for armv7 and arm64 compilation
In the example above, ARCHS = armv7 arm64
tells Theos to build your tweak for both specified architectures. The TARGET
variable defines the SDK version and the minimum iOS version your tweak will support. For broad compatibility, especially with armv7, a lower minimum iOS version (e.g., 7.0
or 8.0
) is often necessary, as older devices cannot run newer iOS versions.
Verifying Your Universal Binary
After compiling your tweak with the updated Makefile
, Theos will produce a 'fat' binary, which is a single executable containing code for multiple architectures. You can verify the architectures included in your compiled tweak using the lipo
command-line tool, which is part of Xcode's command-line tools.
1. Compile Your Tweak
Navigate to your tweak's root directory in the terminal and run make package
. This will compile your tweak and create a .deb
package.
2. Extract the Binary
After packaging, the tweak's executable will be located within the .deb
file. You can extract it using dpkg-deb -x yourtweak.deb temp_dir
and then find the executable, typically in temp_dir/Library/MobileSubstrate/DynamicLibraries/YourTweak.dylib
.
3. Check Architectures with lipo
Use the lipo -info
command on the extracted .dylib
file. For example: lipo -info temp_dir/Library/MobileSubstrate/DynamicLibraries/MyUniversalTweak.dylib
. The output should list both armv7
and arm64
.
lipo -info MyUniversalTweak.dylib
# Expected Output:
# Architectures in the fat file: MyUniversalTweak.dylib are: armv7 arm64
Using lipo -info
to verify included architectures
lipo -info
does not show both armv7
and arm64
, double-check your ARCHS
variable in the Makefile
for typos or incorrect values. Ensure your Theos installation is up-to-date and correctly configured.By following these steps, you can effectively configure Theos to build universal binaries for your Objective-C tweaks, ensuring maximum compatibility across the diverse landscape of jailbroken iOS devices. This approach significantly broadens your tweak's reach and provides a better experience for users on both 32-bit and 64-bit hardware.