Monday, December 30, 2013

How to install thoes under Xcode 5 (iOS 7)

(1) Installation (note : you have to install Command Line Tools (Mountain Lion/Mavericks) for Xcode 5)
install_theos.sh    Select all
# clone theos.git cd ~ git clone https://github.com/rpetrich/theos.git theos-rpetrich # clone iphoneheaders.git cd ~/theos-rpetrich/; ./git-submodule-recur.sh init; git submodule update --recursive # get dpkg-deb for Mac OS X curl -OL http://test.saurik.com/francis/dpkg-deb-fat chmod a+x dpkg-deb-fat sudo mkdir -p /usr/local/bin sudo mv dpkg-deb-fat /usr/local/bin/dpkg-deb # get ldid for Mac OS X cd ~/theos-rpetrich/bin curl -OL http://joedj.net/ldid chmod a+x ldid # get libsubstrate.dylib (multiple archs and supports arm64) cd ~/theos-rpetrich/lib curl -OL http://cdn.hbang.ws/dl/libsubstrate_arm64.dylib mv libsubstrate_arm64.dylib libsubstrate.dylib


Download Xcode_4.4.1 and Xcode_4.6.2 from https://developer.apple.com/downloads/index.action and drag them to /Applications folder Rename them as /Applications/Xcode_4.4.1.app and /Applications/Xcode_4.6.2.app Download the latest Xcode 5 and install it

(2) get ilogit for test build
mkdir -p ~/Projects
cd ~/Projects
curl -OL https://dl.dropboxusercontent.com/u/15373/Other/iPhone/ilogit-tweak-ios7-example.tar
tar -xf ilogit-tweak-ios7-example.tar

#make symlink
cd ilogit
ln -s ~/theos-rpetrich theos


(3) Modify Makefile, change to

Makefile    Select all
TARGET := iphone:clang THEOS_PLATFORM_SDK_ROOT_armv6 = /Applications/Xcode_4.4.1.app/Contents/Developer THEOS_PLATFORM_SDK_ROOT_armv7 = /Applications/Xcode_4.6.2.app/Contents/Developer THEOS_PLATFORM_SDK_ROOT_arm64 = /Applications/Xcode.app/Contents/Developer SDKVERSION_armv6 = 5.1 SDKVERSION_armv7 = 6.1 SDKVERSION_arm64 = 7.0 TARGET_IPHONEOS_DEPLOYMENT_VERSION_armv6 = 5.1 TARGET_IPHONEOS_DEPLOYMENT_VERSION_armv7 = 6.1 TARGET_IPHONEOS_DEPLOYMENT_VERSION_arm64 = 7.0 IPHONE_ARCHS = armv6 armv7 arm64 TWEAK_NAME = iLogIt iLogIt_FILES = Tweak.xm iLogIt_LIBRARIES = substrate include theos/makefiles/common.mk include $(THEOS_MAKE_PATH)/tweak.mk


(4) Make package

make package





Please refer to this for the updated iOS7 tweaks http://iphonedevwiki.net/index.php/Updating_extensions_for_iOS_7

.
.
.

Sunday, February 24, 2013

Illegal instruction: 4

Some old arm v6 binaries that compiled using iPhone-gcc and old sdk have "Illegal instruction: 4" when using devices with A6/A6X CPU such as iPhone 5 / iPad 4 as discussed in http://code.google.com/p/iphone-gcc-full/issues/detail?id=6
The is how to patch these binaries without recompiling or when source code is not available

perl -pe 's/\x{00}\x{30}\x{93}\x{e4}/\x{00}\x{30}\x{93}\x{e5}/g;s/\x{00}\x{30}\x{d3}\x{e4}/\x{00}\x{30}\x{d3}\x{e5}/g;' < old_ios_binary > old_ios_binary_patched
chmod +x old_ios_binary_patched
ldid -s old_ios_binary_patched
mv old_ios_binary old_ios_binary_original
mv old_ios_binary_patched old_ios_binary


If you have gnu sed in iOS or OS X, you can patch directly without the temp file in one step
sed -i'' 's/\x00\x30\x93\xe4/\x00\x30\x93\xe5/g;s/\x00\x30\xd3\xe4/\x00\x30\xd3\xe5/g;' old_ios_binary
ldid -s old_ios_binary


iphone-gcc patched package for iPhone 5 / iPad 4 is here
http://code.google.com/p/apiexplorer/downloads/list

Monday, February 4, 2013

swizzleMethodsForClass

swizzleMethodsForClass.m Select all
#import <objc/runtime.h> // swap a class's instance method selectors, we do this to overload existing methods in category declarations void swizzleMethodsForClass(Class c, SEL origMethodSel, SEL newMethodSel) { NSLog(@"swizzling %@ instance methods: %@ -> %@", NSStringFromClass(c), NSStringFromSelector(origMethodSel), NSStringFromSelector(newMethodSel)); Method origMethod = class_getInstanceMethod(c, origMethodSel); Method newMethod = class_getInstanceMethod(c, newMethodSel); // check if method is inherited from superclass if(class_addMethod(c, origMethodSel, method_getImplementation(newMethod), method_getTypeEncoding(newMethod))) class_replaceMethod(c, newMethodSel, method_getImplementation(origMethod), method_getTypeEncoding(origMethod)); // exchange un-subclassed method else method_exchangeImplementations(origMethod, newMethod); } @interface UIDevice (SpoofUDID) @end #define UDID_TO_SPOOF @"e0101010d38bde8e6740011211af315301010223" @implementation UIDevice (SpoofUDID) // swizzle this instance method for UIDevice class - (NSString *) spoofUniqueIdentifier { static NSString *spoofUDID = UDID_TO_SPOOF; NSLog(@"spoofing %@ instead of %@", spoofUDID, [[UIDevice currentDevice] spoofUniqueIdentifier]); return spoofUDID; } @end // call this from your app delegate - (void) initUDID { NSString *UDID = [[UIDevice currentDevice] uniqueIdentifier]; NSLog(@"this is my old udid: %@", UDID); swizzleMethodsForClass([UIDevice class], @selector(uniqueIdentifier), @selector(spoofUniqueIdentifier)); NSString *UDID2 = [[UIDevice currentDevice] uniqueIdentifier]; NSLog(@"this is my new udid: %@", UDID2); }