Theos on MAC OS

From Hawk Wiki
Jump to: navigation, search

Install theos

This procedure works on Mac OS Yosemite.
First, set the os path.

export THEOS=/git/theos

In mac, you can do "vim ~/.bash_profile" and add "export THEOS=/git/theos"
Download from git, you can choose your own folder

cd /git
git clone https://github.com/DHowett/theos.git

Generate substrate

sudo $THEOS/bin/bootstrap.sh substrate

There is a bug. Need to copy from iOS device /Library/Frameworks/CydiaSubstrate.framework/CydiaSubstrate to $THEOS/lib/libsubstrate.dylib

Install dkpg, download from
http://www.macports.org/install.php
restart terminal after install

sudo port selfupdate
sudo port install dpkg

Additional templates (optional)
https://github.com/DHowett/theos-nic-templates
copy and paste to $THEOS/templates/iphone
Now you can create tweaks from templates

$THEOS/bin/nic.pl

choose the tweak type.

After edit you tweak
add THEOS_DEVICE_IP = 10.101.66.113 <your device ip> into makefile
also add ARCHS = armv7 arm64 into makefile

make package install
// enter your ssh password

sample tweak.xm

@interface NSString (MD5)
- (id)Md5String;
@end

%hook NSString
// log string before and after md5
- (id)Md5String {
  %log(@"HW: -------------------------Tweak: Md5String-------------------------\n");
  %log(self);
  id ret = %orig;
  %log(ret);
  return ret;
}
%end

How to watch syslog in ios 8

apt-get install socat
socat - UNIX-CONNECT:/var/run/lockdown/syslog.sock
watch

Logify

$THEOS/bin/logify.pl SomeClassHeader.h > tweak.xm

see http://iphonedevwiki.net/index.php/Logify
It can automatic generate tweak.xm file to log all functions provided in a header.

theos installation path

/Library/MobileSubstrate/DynamicLibraries/

Application Path

ios 8

/var/mobile/Containers/Bundle/Application/

ios9

/private/var/containers/Bundle/Application/

Application Document Path

ios8 and ios9

/var/mobile/Containers/Data/Application