Updating extensions for iOS 7

From iPhone Development Wiki
Revision as of 17:44, 25 December 2013 by IMokhles (talk | contribs) (Activator Listener for 64Bit)
Jump to: navigation, search

This is an informal collection of advice; feel free to add to it and rearrange. A lot of this is from #theos on irc.saurik.com - if you're working on updating your tweaks and you use Theos, join in and share what you've learned (see IRC).


WARNING

At the time of writing this MobileSubstrate has not been updated for arm64 and therefore these instructions describe a way to setup your development environment and fix arm64 related compiler bugs. Whether the resulting binary will actually work on arm64 systems is not certain.


Tweaks that do NOT need iOS 4.2.1 and below compatibility

Very easy, simply follow Kirb's advice on his blog: http://sharedinstance.net/2013/12/how-to-support-arm64/


Tweaks that do need iOS 4.2.1 and below compatibility

This is slightly more complicated. You need to compile an armv6 slice using the 5.1 SDK and another arm64 slice using the 7.0 SDK. You then stitch both together with lipo. Kirk's blog post describes how to do that manually, but rpetrich has created a theos fork, which does that automatically for you.


Setup rpetrich’s THEOS:

mbkim:iOS7-Dev-Setup Kim$ export THEOS=/opt/theos-rpetrich

mbkim:iOS7-Dev-Setup Kim$ sudo git clone https://github.com/rpetrich/theos $THEOS

mbkim:iOS7-Dev-Setup Kim$ wget http://joedj.net/ldid

mbkim:iOS7-Dev-Setup Kim$ sudo mv ldid $THEOS/bin/ldid

mbkim:iOS7-Dev-Setup Kim$ sudo chmod +x $THEOS/bin/ldid

mbkim:iOS7-Dev-Setup Kim$ wget http://cdn.hbang.ws/dl/libsubstrate_arm64.dylib

mbkim:iOS7-Dev-Setup Kim$ sudo mv libsubstrate_arm64.dylib $THEOS/lib/libsubstrate.dylib


Install headers:

mbkim:iOS7-Dev-Setup Kim$ cd $THEOS/; sudo ./git-submodule-recur.sh init; sudo git submodule update


Setup the Makefile

TARGET := iphone:clang

export THEOS_PLATFORM_SDK_ROOT_armv6 = /Applications/Xcode_4.4.1.app/Contents/Developer

export SDKVERSION_armv6 = 5.1

export TARGET_IPHONEOS_DEPLOYMENT_VERSION = 4.2.1

export TARGET_IPHONEOS_DEPLOYMENT_VERSION_arm64 = 7.0

export ARCHS = armv6 arm64

TWEAK_NAME = iLogIt

iLogIt_FILES = Tweak.xm

include theos/makefiles/common.mk

include $(THEOS_MAKE_PATH)/tweak.mk


rpetrich's theos is using objc's hooking method instead of MobileSubstrate therefore it doesn't link with MS by default. This is OK if you are only hooking objc messages, but if you need to use MSHookFunction, you have to tell theos to link to libsubstrate:

iLogIt_LIBRARIES = substrate


Example Projects: Take a look at the Makefiles of these projects:

https://dl.dropboxusercontent.com/u/15373/Other/iPhone/ilogit-tweak-ios7-example.tar

https://github.com/joedj/ExchangePolicyCleaner/blob/master/Makefile#L3

https://github.com/a3tweaks/Flipswitch

Activator Listener for 64Bit

As rpetrich's libactivator doesn't support 64-bit yet i compilied LibActivator to make it support 64-bit..

For Theos:

imokhlesmac:~ iMokhles$ wget http://imokhles.com/libactivator_64.dylib

imokhlesmac:~ iMokhles$ sudo mv libactivator_64.dylib $THEOS/lib/libactivator.dylib

For iOSOpenDev:

imokhlesmac:~ iMokhles$ wget http://imokhles.com/libactivator_64.dylib

imokhlesmac:~ iMokhles$ sudo mv libactivator_64.dylib /opt/iOSOpenDev/lib/libactivator.dylib

Example Which use iOSOpenDev:

https://github.com/iMokhles/WhatsAtor

Updating code for 64Bit

  1. ifdef __LP64__
   NSLog(@"64-bit\t");
  1. else
   NSLog(@"32-bit\t");
  1. endif


Dealing with 64bit

https://developer.apple.com/library/ios/documentation/General/Conceptual/CocoaTouch64BitGuide/ConvertingYourAppto64-Bit/ConvertingYourAppto64-Bit.html

20:44:45 <@sbingner> saurik said all tweaks will need to be recompiled to have a 64bit slice

20:45:10 <@sbingner> which is what I've been working on... as soon as substrate is updated I should be able to just type "make" :D

20:49:27 <@sbingner> crash-x, installing rpetrich's fork of theos and making sure it can compile for armv6 with latest xcode on it... and that arm64 will compile except for the mobilesubstrate lib being missing

20:45:32 <@Optimo> dlopen from a variety of avenues, or ...INSERT_LIBRARIES -- all for your own testing of course

20:45:54 <@Optimo> (if you have a 64bit device)

Working with Mobile Substrate

21:22:35 < Alcatraz> https://ghostbin.com/paste/zhsx9 Tutorial to Make mobilesubstrate more stable while we wait for an official update.


Install MobileSubstrate

Add the repo: rpetri.ch/repo

Install the beta Activator

Done

Some Stuff that was broken before you installed the beta activator such as SBSettings and PreferenceLoader should be working now.

If they are not,it is likely another package that still wont work. Or you rebooted your device.

Rebooting the device seems to break mobilesubstrate for whatever reason.

So each time you reboot you have to reinstall mobilesubstrate or run this command:

/usr/bin/cynject 1 /Library/Frameworks/CydiaSubstrate.framework/Libraries/SubstrateLauncher.dylib && killall backboardd && sbreload

Theos advice

21:25:55 <@DHowett> This time, you're all wrong

21:25:59 <@sbingner> oh?

21:26:01 <@DHowett> theos passes -arch flags to the compiler, after all.

21:26:07 < Maximus> ARCH=armv7 and uh

21:26:08 <@sbingner> ^^

21:26:12 < Maximus> ARCHS

21:26:18 <@DHowett> alexzielenski: by default, theos passes armv7 armv7s to the compiler on 6.0+

21:26:39 <@DHowett> alexzielenski: you can override this by setting ARCHS=armv7 arm64 before you include common.mk

21:26:48 < alexzielenski> DHowett: thanks

21:27:10 <@sbingner> DHowett, what I said was wrong because it wasn't complete? :P

21:27:26 < Maximus> i was getting there

21:27:41 <@DHowett> sbingner: well, because it doesn't have anything to do with the compiler, really: this is all a compiler driver problem once you have upgraded xcode

21:27:43 <@sbingner> have time to point me to the right place to add support for foo_FILES_arch to rpetrich's fork? I'm missing the right spot

21:27:52 <@DHowett> instance/rules.mk

21:28:29 < coolstar> screw arm64

21:28:36 < coolstar> the build tools are still not out yet

21:28:36 < coolstar> http://opensource.apple.com/

21:28:37 <@sbingner> ok thanks... I guess I was in the right spot but doing something wrong lol... I'll figure it out

21:28:44 <@DHowett> the proprietary ones are.

21:28:50 <@DHowett> why is everybody focusing on this now?



01:03:36 < therpgitbot> [theos] rpetrich pushed 1 new commit to master: http://git.io/ankV8g

01:03:36 < therpgitbot> theos/master f6ebd79 Ryan Petrich: Workaround bootstrap problems on Xcode 5.x (temporary fix for now)



22:58:21 <%joedj> here's a tip: if you aren't using low-level substrate features like MSHookFunction, you may be able to prepare arm64-ready packages using %config(generator=internal). of course, they won't actually work until substrate can load them

Theos and ldid

12:11:37 < Ge0rges> if anyone here has a tip Still having this problem when installing ldid for theos: https://pastee.org/vasuu

12:28:42 <%joedj> Ge0rges: just put the ldid binary i gave you into theos/bin/ and move on to the next step

13:14:13 <%joedj> Ge0rges: http://joedj.net/ldid

Dealing with 32-bit and 64-bit

12:38:15 <%joedj> sbingner: i did find this question (and the response 2 posts down) interesting, i'm not sure what they're talking about: https://www.mikeash.com/pyblog/friday-qa-2013-09-27-arm64-and-you.html#comment-7436311d02c5a55738d1baefa03b0d34

[09:25] <rpetrich> joedj: it's a bug with the components that communicate with the App Store

Mobile Substrate tip

14:20:58 < ganbold_> so mobilesubstrate is working partially? after reboot/restart doesn't work

14:29:03 < ac3xx> ganbold_, either just reinstall it through cydia or run this over SSH - /var/lib/dpkg/info/mobilesubstrate.extrainst_ upgrade && killall SpringBoard

Theos and ldid errors

19:02:14 < yoshbu> I've been off the jailbreak train for awhile now. Trying to reinstall theos, getting some build failures when trying to install ldid, anybody know if there's a quick fix?


19:02:52 < yoshbu> like, error: unknown type name '__darwin_intptr_t'

19:02:59 < yoshbu> and, error: unknown type name '__uint32_t'; did you mean 'uint32_t'?

19:05:27 < Alcatraz> are you trying to compile ldid on mac?

19:05:55 < yoshbu> following step 4 of http://iphonedevwiki.net/index.php/Theos/Getting_Started

19:06:10 < Alcatraz> yeah compiling it has been broken for some time

19:06:27 < Alcatraz> has to do with xcode 5

19:06:32 < Alcatraz> pretty sure anyway

19:06:50 < yoshbu> ldid is a dependency of theos though right?

19:07:01 < Alcatraz> yeah. you can ask someone on here for a copy

19:07:23 -!- mindw0rk [~mindw0rk@78.57.233.231] has joined #theos

19:08:05 < ac3xx> yoshbu, wget http://ac3xx.com/ldid -O $THEOS/bin/ldid && chmod +x $THEOS/bin/ldid

Supporting iOS 4-7 with one binary & Example project link

23:59:59 <%joedj> sbingner: i used 5.1 SDK (xcode 4.4.1) for the armv6 slice, targetting 4.0: https://github.com/joedj/ExchangePolicyCleaner/blob/master/Makefile#L3

(also rpetrich's canonical example: https://github.com/a3tweaks/Flipswitch/blob/master/Makefile#L16 )

Day changed to 24 Dec 2013

00:01:43 <+crash-x> joedj: you can make a fat binary with the armv6 slice targetting 4.0 and the arm64 part targetting ios 7 and achieve support for iOS 4-7?

00:03:53 <+crash-x> joedj: is that project on github been updated for iOS 7 and rpetrich's theos fork?

00:04:09 <%joedj> crash-x: indeed, i believe so, although i think i've only tested down to ios6

00:04:10 <%joedj> crash-x: yes

00:04:22 <+crash-x> thats amazing, thank you!

00:04:25 -!- charliebashford [~charliebash@86.173.69.10] has quit [Client exited]

00:04:53 <+crash-x> if i wanted to get this working, what would i have to do? install rpetrich's theos fork and then I could just make package it or is there anything else I would have to install or do>

00:07:36 <%joedj> crash-x: there are a few other things like setting THEOS_PLATFORM_SDK_ROOT_armv6 (see the Makefile i just linked), and possibly switching to using %config(generator=internal) in your logos files unless you have an arm64 substrate you can link against (i think theos might be able to bootstrap this for you, but haven't tried)

00:08:04 <%joedj> crash-x: %config(generator=internal) might also be the default with rpetrich's fork, but i prefer to be explicit

Accessing the device's UDID

UDID access is blocked by default on iOS7 and iOS will substitute a generated ID in UIDevice's uniqueIdentifier property. Use MGCopyAnswer(CFSTR("UniqueDeviceID")) and link to libMobileGestalt.dylib to get access to the device ID from system processes or apps installed to \Applications. Device ID is completely inaccessible from app store processes and some daemons.