Skip to content

Commit

Permalink
Scripts to automatically build and copy an appropriate CydiaSubstrate…
Browse files Browse the repository at this point in the history
….framework to the appropriate location.
  • Loading branch information
Thatchapon Unprasert committed Oct 14, 2018
1 parent 19f28f3 commit 6f4bfd4
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Now, we will need to create a version of `CydiaSubstrate.framework` that has sup

### Getting Cydia Substrate to function properly with simject

Unless you want to do it manually, you can use either `substrate.sh` or `substrate-pre10.sh` script to copy over this framework to the target runtime.

If you use Xcode 10 (and above) and target iOS 12 (and above), you need to use [substitute](https://github.com/coolstar/substitute) instead of Cydia Substrate.

Due to the incompatible `libstdc++` in iOS 12 simulator of Xcode 10, the Cydia Substrate binary from cycript that requires this library will not work (it will complain `/usr/lib/libstdc++.6.dylib: mach-o, but not built for iOS simulator`). While Cydia Substrate is not open-sourced to allow us to recompile the binary, we still have substitute as a replacement. You can run the following commands:
Expand Down
37 changes: 37 additions & 0 deletions substrate-pre10.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh

if [ "$EUID" -ne 0 ];then
echo "This script must be run as root"
exit 1
fi

if [[ -z $1 ]];then
echo "Runtime version is required"
echo "Example: ./substrate-pre10.sh 8.4"
exit 1
fi

SJ_RUNTIME_ROOT=/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS\ ${1}.simruntime/Contents/Resources/RuntimeRoot
# In-Xcode directory: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot

if [[ ! -d "${SJ_RUNTIME_ROOT}" ]];then
echo "Error: iOS $1 runtime is not found in /Library/Developer/CoreSimulator/Profiles/Runtimes"
exit 1
fi

mkdir -p "${SJ_RUNTIME_ROOT}/Library/Frameworks"

curl -Lo /tmp/simject_cycript.zip https://cache.saurik.com/cycript/mac/cycript_0.9.594.zip
unzip /tmp/simject_cycript.zip -d /tmp/simject_cycript
mkdir -p CydiaSubstrate.framework
mv /tmp/simject_cycript/Cycript.lib/libsubstrate.dylib CydiaSubstrate.framework/CydiaSubstrate
rm -rf /tmp/simject_cycript /tmp/simject_cycript.zip

rm -rf "${SJ_RUNTIME_ROOT}/Library/Frameworks/CydiaSubstrate.framework"
mv CydiaSubstrate.framework "${SJ_RUNTIME_ROOT}/Library/Frameworks/CydiaSubstrate.framework"

if [ $? -eq 0 ];then
echo "Done copying"
else
echo "Error copying"
fi
40 changes: 40 additions & 0 deletions substrate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/sh

if [ "$EUID" -ne 0 ];then
echo "This script must be run as root"
exit 1
fi

if [[ -z $1 ]];then
echo "Runtime version is required"
echo "Example: ./substrate.sh 12.0"
exit 1
fi

SJ_RUNTIME_ROOT=/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS\ ${1}.simruntime/Contents/Resources/RuntimeRoot
# In-Xcode directory: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot

if [[ ! -d "${SJ_RUNTIME_ROOT}" ]];then
echo "Error: iOS $1 runtime is not found in /Library/Developer/CoreSimulator/Profiles/Runtimes"
exit 1
fi

mkdir -p "${SJ_RUNTIME_ROOT}/Library/Frameworks"

git clone https://github.com/PoomSmart/substitute.git
cd substitute/
./configure --xcode-sdk=iphonesimulator --xcode-archs=x86_64 && make
mv out/libsubstitute.dylib out/CydiaSubstrate
codesign -f -s - out/CydiaSubstrate
mkdir -p ../CydiaSubstrate.framework
mv out/CydiaSubstrate ../CydiaSubstrate.framework/CydiaSubstrate
cd .. && rm -rf substitute

rm -rf "${SJ_RUNTIME_ROOT}/Library/Frameworks/CydiaSubstrate.framework"
mv CydiaSubstrate.framework "${SJ_RUNTIME_ROOT}/Library/Frameworks/CydiaSubstrate.framework"

if [ $? -eq 0 ];then
echo "Done copying"
else
echo "Error copying"
fi

0 comments on commit 6f4bfd4

Please sign in to comment.