Several Improvements, see comment (#59)

* Remove reliance on Prefix.pch

Prefix.pch was deprecated with iOS 13 and the functionality was removed with iOS 14 in theos.

* Remove Prefix.pch Reliance

This feature of theos was deprecated and removed with iOS 14.

* Several large changes, see comment

* Update resim/Makefile

Co-authored-by: Karen/あけみ <karen@akemi.ai>

* Update simject/Makefile

Co-authored-by: Karen/あけみ <karen@akemi.ai>

* Update Makefile

Co-authored-by: Karen/あけみ <karen@akemi.ai>

* Update simject/Makefile

Co-authored-by: Karen/あけみ <karen@akemi.ai>

* Update resim/Makefile

Co-authored-by: Karen/あけみ <karen@akemi.ai>

Co-authored-by: Karen/あけみ <karen@akemi.ai>
This commit is contained in:
Kritanta
2020-07-24 23:21:38 -05:00
committed by GitHub
parent 2deb7734d2
commit d59893eb46
9 changed files with 104 additions and 50 deletions
+1 -3
View File
@@ -1,7 +1,5 @@
*.o
.theos/*
*/.theos/*
**/.theos/*
*/out/*
debs/*
*.deb
*.dylib
+36 -14
View File
@@ -1,22 +1,44 @@
ARCHS = x86_64
DEBUG = 0
export PREFIX = \033[1;36m>>\033[0m
export SUB_PREFIX = \033[1;36m>>>\033[0m
export DONE_PREFIX = \033[1;32m>>\033[0m
ifndef DYLIB_DIR
DYLIB_DIR = /opt/simject
endif
PARENT = $(shell dirname $(DYLIB_DIR))
DD_NOT_EXISTS = $(shell test -d $(DYLIB_DIR); echo $$?)
DD_NOT_WRITABLE = $(shell test -w $(PARENT); echo $$?)
ifeq '$(DD_NOT_WRITABLE)' '1'
NEED_ROOT = sudo
NEED_ROOT_ASK = \033[1;32m>>\033[0m $(PARENT) is not writable. Using sudo.
endif
ifndef SYSROOT
SYSROOT = $(shell xcode-select -p)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk
endif
ifndef TRIPLE
TRIPLE = $(shell clang -print-target-triple)
endif
all::
@make -C resim
@make -C simject
@make -C resim build
@make -C simject build
clean::
@rm -rfv bin
@make -C resim clean
@make -C simject clean
setup:: clean all
@sudo mkdir -p /opt/simject
@sudo chown -Rv $(USER) /opt/simject
# simjectUIKit has been deprecated.
@rm -fv /opt/simject/simjectUIKit.dylib
@rm -fv /opt/simject/simjectUIKit.plist
@cp -v bin/simject.dylib /opt/simject
@cp -v simject/simject.plist /opt/simject
@codesign -f -s - /opt/simject/simject.dylib
@echo "Done. Place your tweak's dynamic libraries and accompanying property lists inside /opt/simject to load them in the iOS Simulator."
setup:: all
@test -w $(PARENT) || echo "$(NEED_ROOT_ASK)"
@$(NEED_ROOT) mkdir -p $(DYLIB_DIR)
@$(NEED_ROOT) chown -R $(USER) $(DYLIB_DIR)
@echo "$(PREFIX) Copying Tweak Loader to $(DYLIB_DIR)"
@cp bin/simject.dylib $(DYLIB_DIR)
@cp simject/simject.plist $(DYLIB_DIR)
@echo "$(PREFIX) Installing resim"
@cp bin/resim /usr/local/bin/resim
@echo "$(DONE_PREFIX) Done. Place your tweak's dynamic libraries and accompanying property lists inside $(DYLIB_DIR) to load them in the iOS Simulator."
@echo "$(DONE_PREFIX) To load/reload tweaks, run 'resim' in your terminal"
+4 -4
View File
@@ -5,16 +5,16 @@ simject is a command-line tool and iOS dynamic library that allows iOS tweak dev
simject is BSD-licensed. See `LICENSE` for more information.
### Setting up the simject environment
1. Ensure that you have the latest version of [Theos](https://github.com/theos/theos).
2. Ensure that you have added your developer account in Xcode > Preferences > Accounts tab. This is required for code-signing some binaries used in simject.
3. Ensure that there is "iOS Development" certificate listed once you clicked on "Manage Certificates", create one if there is not.
4. Run these commands in a Terminal instance:
1. Ensure that you have added your developer account in Xcode > Preferences > Accounts tab. This is required for code-signing some binaries used in simject.
2. Ensure that there is "iOS Development" certificate listed once you clicked on "Manage Certificates", create one if there is not.
3. Run these commands in a Terminal instance:
```
git clone https://github.com/angelXwind/simject.git
cd simject/
make setup
```
**Note:** During the process, you will be asked by `sudo` to enter your login password. Please note that it is normal for nothing to be displayed as you type your password.
Now, we need to create a version of `CydiaSubstrate.framework` that has support for the `x86_64` (64-bit) and/or `i386` (32-bit) architectures.
+22 -10
View File
@@ -1,15 +1,27 @@
TARGET = macosx:clang::10.9
ARCHS = x86_64
ifndef DYLIB_DIR
DYLIB_DIR = /opt/simject
endif
include $(THEOS)/makefiles/common.mk
ifndef ARCH
ARCHFLAG =
else
ARCHFLAG = -arch $(ARCH)
endif
TOOL_NAME = resim
resim_FILES = resim.mm
resim_CFLAGS = -Wno-deprecated-declarations
ifdef SYSROOT
SYSROOTFLAG = -isysroot $(SYSROOT)
endif
include $(THEOS_MAKE_PATH)/tool.mk
clean::
-@rm -r out/
after-all::
@echo "Copying binaries..."
build : resim.mm
@mkdir -p out
@echo "$(PREFIX) Compiling resim for $(shell clang -print-target-triple)"
@echo "$(SUB_PREFIX) Target directory is $(DYLIB_DIR)"
@$(CXX) resim.mm $(ARCHFLAG) $(SYSROOTFLAG) -framework Foundation -DDYLIB_DIR=@\"$(DYLIB_DIR)\" -o out/resim
@echo "$(SUB_PREFIX) Signing..."
@codesign -f -s - out/resim
@echo "$(SUB_PREFIX) Copying library..."
@mkdir -p ../bin
@cp -v $(THEOS_OBJ_DIR)/resim ../bin/
@cp out/resim ../bin
View File
+6 -5
View File
@@ -7,6 +7,7 @@
#include <string>
#include <array>
#include <regex>
#include <Foundation/Foundation.h>
using namespace std;
@@ -70,7 +71,7 @@ string exec(const char *cmd) {
void injectHeader() {
globalHeader();
printf("Injecting appropriate dynamic libraries from /opt/simject...\n");
printf("Injecting appropriate dynamic libraries from %s...\n", [DYLIB_DIR UTF8String]);
}
void inject(const char *uuid, const char *device, const char *version, BOOL _exit, BOOL keepRunning) {
@@ -95,12 +96,12 @@ void inject(const char *uuid, const char *device, const char *version, BOOL _exi
}
uuid = strdup(suuid.c_str());
}
safe_system([[NSString stringWithFormat:@"plutil -replace bootstrap.child.DYLD_INSERT_LIBRARIES -string /opt/simject/simject.dylib %@/Library/Developer/CoreSimulator/Devices/%@/data/var/run/launchd_bootstrap.plist -s", NSHomeDirectory(), @(uuid)] UTF8String]);
safe_system([[NSString stringWithFormat:@"plutil -replace bootstrap.child.DYLD_INSERT_LIBRARIES -string %@/simject.dylib %@/Library/Developer/CoreSimulator/Devices/%@/data/var/run/launchd_bootstrap.plist -s", DYLIB_DIR, NSHomeDirectory(), @(uuid)] UTF8String]);
safe_system("killall launchd_sim");
} else {
safe_system([[NSString stringWithFormat:@"xcrun simctl spawn %s launchctl setenv DYLD_INSERT_LIBRARIES /opt/simject/simject.dylib", uuid] UTF8String]);
safe_system([[NSString stringWithFormat:@"xcrun simctl spawn %s launchctl setenv __XPC_DYLD_INSERT_LIBRARIES /opt/simject/simject.dylib", uuid] UTF8String]);
safe_system([[NSString stringWithFormat:@"export SIMCTL_CHILD_DYLD_INSERT_LIBRARIES=/opt/simject/simject.dylib; xcrun simctl spawn %s launchctl stop com.apple.backboardd", uuid] UTF8String]);
safe_system([[NSString stringWithFormat:@"xcrun simctl spawn %s launchctl setenv DYLD_INSERT_LIBRARIES %@/simject.dylib", uuid, DYLIB_DIR] UTF8String]);
safe_system([[NSString stringWithFormat:@"xcrun simctl spawn %s launchctl setenv __XPC_DYLD_INSERT_LIBRARIES %@/simject.dylib", uuid, DYLIB_DIR] UTF8String]);
safe_system([[NSString stringWithFormat:@"export SIMCTL_CHILD_DYLD_INSERT_LIBRARIES=%@/simject.dylib; xcrun simctl spawn %s launchctl stop com.apple.backboardd", DYLIB_DIR, uuid] UTF8String]);
}
exit(EXIT_SUCCESS);
} else {
-1
View File
@@ -1 +0,0 @@
#define dylibDir @"/opt/simject"
+28 -9
View File
@@ -1,14 +1,33 @@
TARGET = simulator:clang::7.0
ARCHS = x86_64 i386
ifndef DYLIB_DIR
DYLIB_DIR = /opt/simject
endif
# shouldn't need more than one unless it's being packaged
include $(THEOS)/makefiles/common.mk
ifndef ARCH
ARCHFLAG =
else
ARCHFLAG = -arch $(ARCH)
endif
TWEAK_NAME = simject
simject_FILES = simject.xm
ifndef SYSROOT
SYSROOT = $(shell xcode-select -p)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk
endif
include $(THEOS_MAKE_PATH)/tweak.mk
ifndef TRIPLE
TRIPLE = $(shell clang -print-target-triple)
endif
after-all::
@echo "Copying binaries..."
clean::
-@rm -r out/
build : simject.m
@mkdir -p out
@echo "$(PREFIX) Compiling simject for $(TRIPLE)"
@echo "$(SUB_PREFIX) Using SDK at $(SYSROOT)"
@echo "$(SUB_PREFIX) Target directory is $(DYLIB_DIR)"
@$(CC) simject.m $(ARCHFLAG) -framework Foundation -isysroot $(SYSROOT) -target $(TRIPLE) -DDYLIB_DIR=@\"$(DYLIB_DIR)\" -dynamiclib -o out/simject.dylib
@echo "$(SUB_PREFIX) Signing..."
@codesign -f -s - out/simject.dylib
@echo "$(SUB_PREFIX) Copying library..."
@mkdir -p ../bin
@cp -v $(THEOS_OBJ_DIR)/simject.dylib ../bin/
@cp out/simject.dylib ../bin
+7 -4
View File
@@ -1,5 +1,8 @@
#import "../simject.h"
#import <Foundation/Foundation.h>
#import <dlfcn.h>
#import <os/log.h>
#define dylibDir DYLIB_DIR
static NSArray *blackListForFLEX;
@@ -90,7 +93,7 @@ NSArray *simjectGenerateDylibList() {
return dylibsToInject;
}
%ctor {
static __attribute__((constructor)) void SimjectInit (int argc, char **argv, char **envp) {
// Since many iOS tweak developers use FLEXible (or some variant of that tweak) to inspect the iOS Simulator...
// There are some processes that can crash when FLEXible is injected into them, significantly decreasing overall performance.
// These processes do indeed load UIKit as a library, but they do not actually present a GUI so there is no point in injecting FLEXible into them.
@@ -98,7 +101,7 @@ NSArray *simjectGenerateDylibList() {
// Inject any dylib meant to be run for this application
for (NSString *dylib in simjectGenerateDylibList()) {
BOOL success = dlopen([dylib UTF8String], RTLD_LAZY | RTLD_GLOBAL) != NULL;
HBLogDebug(@"Injecting %@ into %@: %d.", dylib, NSBundle.mainBundle.bundleIdentifier, success);
if (!success) HBLogError(@"Couldn't inject %@ into %@:\n%s.", dylib, NSBundle.mainBundle.bundleIdentifier, dlerror());
os_log_info(OS_LOG_DEFAULT, "Injecting %s into %s: %d.", [dylib UTF8String], [NSBundle.mainBundle.bundleIdentifier UTF8String], success);
if (!success) os_log_error(OS_LOG_DEFAULT, "Couldn't inject %s into %s:\n%s.", [dylib UTF8String], [NSBundle.mainBundle.bundleIdentifier UTF8String], dlerror());
}
}