Updating extensions for iOS 11

From iPhone Development Wiki
Jump to: navigation, search

Let's collect knowledge like we did with iOS 10, iOS 9, iOS 8 and iOS 7 – paste in your notes and share what you've learned, and somebody else will organize it later. :) If you want to ask questions and share tips over chat with other developers, see How to use IRC for how to connect to #theos and #iphonedev.

Hey developer, you can add your knowledge here! Yes, you! Make an account and edit this page!

If you want to see what's been recently updated on this page, you can use the wiki's history feature to compare the revisions (to look at the diff) since the last time you visited this page.


Since iOS 9.3.3 the SBScreenshotManager has been used. This is no longer the case, it seems. The class still exists, however it doesn't appear to be used anymore. Instead, there is a new framework named "ScreenshotServices" where most of the screenshot abilities have been kicked off to.

However, if the needs are simple, the SpringBoard _class_ has gotten two new methods to kick off screenshots with as well. `takeScreenshot` will be invoked with the hardware keys, at which point you can do what you need. This method won't work when the user invokes a screenshot in another way, like with AssistiveTouch. `takeScreenshot` only calls `takeScreenshotAndEdit:(BOOL)arg1` though, which IS called by AssistiveTouch, so you can use that one instead.

If you have more complex needs, you likely will have to dig into the new services. Here is the decompiled version (Hopper) of `takeScreenshotAndEdit:` for some guidance.

   void -[SpringBoard takeScreenshotAndEdit:](void * self, void * _cmd, bool arg2) {
       r21 = arg2;
       r20 = self;
       r19 = [SSScreenCapturerPresentationOptions new];
       if ([SSScreenCapturer shouldUseScreenCapturerForScreenshots] != 0x0) {
               [r19 setPresentationMode:r21];
               [r20->_screenCapturer takeScreenshotWithPresentationOptions:r19];
       else {
               [r20->_screenshotManager saveScreenshots];

Other avenues for screenshots I found while researching were:

- `SBCombinationHardwareButtonActions`s method `-(void)performTakeScreenshotAction` which also did not work with AssistiveTouch.

- `SSScreenCaptureAbilityCheck`s method `-(bool)isAbleToTakeScreenshots` which seems to be always called. I didn't track down exactly from where it was called yet. I didn't need it.

- `SSMainScreenSnapshotter` and `SSOtherScreenSnapshotter` are highly related to taking screenshots, however I did not use these either. But worth looking into if you have multi-screen needs maybe.

SBUserAgent changes

SBUserAgent still exists, however it is no longer accessible through the previous shared instance. It has instead been moved into SpringBoard as an ivar and can be accessed through a method. So the change can look like something like this in iOS 11:

   Class SpringBoardClass = objc_getClass("SpringBoard");
   SpringBoard *springBoardInstance = [SpringBoardClass sharedApplication];
   SBUserAgent *userAgent = [springBoardInstance pluginUserAgent];
   UIDeviceOrientation orientation = [userAgent activeInterfaceOrientation];

While iOS 10 and below could look like:

   UIDeviceOrientation orientation = [[objc_getClass("SBUserAgent") sharedUserAgent] activeInterfaceOrientation];

Disabling CC, NC and Home gestures

In iOS 11 the CC moved to the top right, rather than the bottom. It also added the Home gesture for iPhone X devices. Since the code is pretty large (documentation) I'll make a new page for it with all versions in one.

See Disabling NC, CC and Home gestures for information of all versions.

Handling iPhone X

If you don't have an iPhone X handy, the tweak (paid but open sourced) 'LittleX' worked _okay_ as a substitute.