Add simulator version of CydiaSubstrate.tbd

This commit is contained in:
Thatchapon Unprasert
2025-01-25 12:42:14 +07:00
parent 0d17004291
commit 0df5b4e72c
3 changed files with 34 additions and 2 deletions
+11
View File
@@ -0,0 +1,11 @@
--- !tapi-tbd
tbd-version: 4
targets: [ armv7-ios, armv7s-ios, arm64-ios, arm64e-ios, i386-ios-simulator, x86_64-ios-simulator, arm64-ios-simulator ]
install-name: '/Library/Frameworks/CydiaSubstrate.framework/CydiaSubstrate'
exports:
- targets: [ armv7-ios, armv7s-ios, arm64-ios, arm64e-ios, i386-ios-simulator, x86_64-ios-simulator, arm64-ios-simulator ]
symbols: [ _MSCloseImage, _MSDebug, _MSFindAddress, _MSFindSymbol,
_MSGetImageByName, _MSHookClassPair, _MSHookFunction,
_MSHookMemory, _MSHookMessageEx, _MSImageAddress,
_MSMapImage ]
...
+2
View File
@@ -62,6 +62,8 @@ rm -rfv /tmp/simject_cycript /tmp/simject_cycript.zip
2. Note that, from the step 1, you can symlink instead of copying `CydiaSubstrate.framework` to multiple places. This is what `installsubstrate.sh` does to ease your life.
3. By default, tweaks built for simulator will not use CydiaSubstrate as logos is configured to generate hooking code using only internal Objective-C runtime methods. While hooking via `%hook` works regardless of generators, hooking via `%hookf` is not supported unless you explicitly specify the logos generator to be `MobileSubstrate` (or `libhooker`) by using [%config](https://theos.dev/docs/logos-syntax). For example, if you want to use CydiaSubstrate for hooking, add `%config(generator=MobileSubstrate)` to your `Tweak.x(m)`. Lastly, to build simulator tweaks successfully, copy `CydiaSubstrate.tbd` from this project to `$THEOS/vendor/lib/CydiaSubstrate.framework` and replace the existing one. Make a backup if necessary.
### simject usage
1. Place your dynamic libraries and accompanying property lists inside `/opt/simject` to load them in the iOS Simulator. Do not delete `simject.plist` and `simject.dylib`.
+21 -2
View File
@@ -13,6 +13,8 @@ then
echo -e "This will install cycript's CydiaSubstrate\n"
echo -e "If you only want to symlink CydiaSubstrate.framework to new iOS runtimes, you can run:\n"
echo -e "\t./installsubstrate.sh link\n"
echo -e "If you are developing simulator tweaks that utilize MSHookFunction, you can install the simulator-supported version of CydiaSubstrate.tbd (tbd v4) by running:\n"
echo -e "\t./installsubstrate.sh theos\n"
exit 1
fi
@@ -29,9 +31,26 @@ SJ_RUNTIME_ROOT_11_BETA=/Applications/Xcode-beta.app/Contents/Developer/Platform
SJ_PATH=/opt/simject
SJ_FW_PATH=${SJ_PATH}/Frameworks
mkdir -p ${SJ_FW_PATH}
cd ${SJ_FW_PATH}
if [[ $1 = "link" ]]
if [[ $1 = "theos" ]]
then
CS_FW_PATH="$THEOS/vendor/lib/CydiaSubstrate.framework"
if [[ ! -d $CS_FW_PATH ]]
then
echo "Error: CydiaSubstrate.framework not found in ${CS_FW_PATH}"
exit 1
fi
if [[ -f $CS_FW_PATH/CydiaSubstrate.tbd.bak ]]
then
echo "Notice: CydiaSubstrate.tbd has already been backed up, skipping"
exit 0
fi
echo "Backing up CydiaSubstrate.tbd..."
mv $CS_FW_PATH/CydiaSubstrate.tbd $CS_FW_PATH/CydiaSubstrate.tbd.bak
echo "Copying the new CydiaSubstrate.tbd to $CS_FW_PATH..."
cp $SELF_DIR/CydiaSubstrate.tbd $CS_FW_PATH/
exit 0
elif [[ $1 = "link" ]]
then
if [[ ! -d CydiaSubstrate.framework ]]
then