Exploring private iVars
ExTBH opened this issue · comments
i have a PoC that allows reading private swift iVars and it works with technically any type
i have a fork of FLEX that uses it but for objects only now (int's, float's, double's and objects)
and i got this test video, adding a drop menu of multiple types (objects, ints, floats) to use would make it better
RPReplay_Final1680648086.mov
everything in the original comment is not needed, it was possible to be done with the Mirror API 💀
made the base PR, can be refined to auto extract the type are replace the nil
and ?
, im not that familiar with how FLEX handles that
edit: introducing the swift file breaks FLEXing, im compiling with orion branch and it errors
edit2: removing $(TWEAK_NAME)_CCFLAGS += -std=gnu++11
from libflex makefile would make it compile but the tweak wont work, idk why
it also can't be used as a Package in other xCode projects, xcode complains about mixed code
it also can't be used as a Package in other xCode projects, xcode complains about mixed code
fixed at this branch, the FLEX code has to be in a separate Target which allows compilation but then i can't import the auto generated header, so i manually interface the extension and use that 💀
got FLEXing compiling with this updated makefile. chatGPT actually got it working 💀
export ARCHS = arm64 arm64e
export TARGET = iphone:latest:13.0
include $(THEOS)/makefiles/common.mk
# FULL PATH of the FLEX repo on your own machine
FLEX_ROOT = FLEX
# Function to convert /foo/bar to -I/foo/bar
dtoim = $(foreach d,$(1),-I$(d))
# Gather FLEX sources
SOURCES = $(shell find $(FLEX_ROOT)/Classes -name '*.c')
SOURCES += $(shell find $(FLEX_ROOT)/Classes -name '*.m')
SOURCES += $(shell find $(FLEX_ROOT)/Classes -name '*.mm')
SOURCES += $(FLEX_ROOT)/FLEXSwift/NSObject+IvarReflection.swift
# Gather FLEX headers for search paths
_IMPORTS = $(shell /bin/ls -d $(FLEX_ROOT)/Classes/*/)
_IMPORTS += $(shell /bin/ls -d $(FLEX_ROOT)/Classes/*/*/)
_IMPORTS += $(shell /bin/ls -d $(FLEX_ROOT)/Classes/*/*/*/)
_IMPORTS += $(shell /bin/ls -d $(FLEX_ROOT)/Classes/*/*/*/*/)
IMPORTS = -I$(FLEX_ROOT)/Classes/ $(call dtoim, $(_IMPORTS))
TWEAK_NAME = libFLEX
$(TWEAK_NAME)_FILES = libFLEX.x $(SOURCES)
$(TWEAK_NAME)_FRAMEWORKS = CoreGraphics UIKit ImageIO QuartzCore Foundation
$(TWEAK_NAME)_LIBRARIES = sqlite3 z
$(TWEAK_NAME)_CFLAGS += -fobjc-arc -w -Wno-unsupported-availability-guard $(IMPORTS) -g
# Exclude the Swift file from the C++ flag
ifeq ($(findstring .swift,$(SOURCES)),)
$(TWEAK_NAME)_CCFLAGS += -std=gnu++11
endif
include $(THEOS_MAKE_PATH)/tweak.mk
before-stage::
find . -name ".DS_Store" -delete
# For printing variables from the makefile
print-% : ; @echo $* = $($*)
compiling this with iOS 16 SDK with theos on Linux will crash with missing symbol _$sSS10FoundationE36_unconditionallyBridgeFromObjectiveCySSSo8NSStringCSgFZ
using the iOS 15 ones is fine and works like a charm.
Trying to compile with theos on OS X with Xcode SDK(16.4) wont even compile for some reason.
but it'll compile fine if imported into an xcode project
this all was tested on the SPM fix branch
A FLEX Module of this has been made at https://github.com/ExTBH/SwiftyFlexy due to inactivity