3

I'm attempting to create an app using private APIs to take screenshots from the background. I found this example: Taking Screenshots in the background (iOS) - Improving Performance

In the author's code, the first line makes use of the IOSurfaceRef type. Can somebody explain to me how to include this in my code? I attempted to link IOSurfaceAPI.h (where I thought IOSurfaceRef was defined), however that hasn't worked.

Community
  • 1
  • 1

1 Answers1

2

First lets start by how to link the Frameworks

  1. go to https://github.com/kennytm/iphone-private-frameworks/tree/master/IOSurface and download the headers

  2. the IOSurfaceAPI.h files is not included with the download link "due to legal reasons" link and you have to copy it from Xcode from here

    change MacOSX10.11.sdk in the path according to the sdk included with Xcode

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/IOSurface.framework/Versions/A/Headers

  1. go to /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/PrivateFrameworks/IOSurface.framework and create a folder named Headers

replace iPhoneOS.platform with iPhoneSimulator.platform an paste the headers in simulator SDK folder too if you want to try apps on the simulator

  1. paste all files inside

Now you can use the IOSurface Framework

Community
  • 1
  • 1
Karim H
  • 1,543
  • 10
  • 24
  • Great, so does IOSurface framework work on iPhone device now? – Trident Feb 25 '17 at 18:47
  • But to link to it you need to create those .tbd files – Karim H Feb 25 '17 at 22:56
  • Can you please provide me links for these... I will really appreciate your help... – Trident Feb 25 '17 at 23:04
  • You can look at existing once: **/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/CFNetwork.framework/CFNetwork.tbd** – Karim H Feb 25 '17 at 23:09
  • I am confused... do we have to create IOSurface.tbd file? I think, they removed IOSurface.framework from above PrivateFrameworks folders long time back. Even then can we use the old IOSurface API to capture system wide screen from background? – Trident Feb 26 '17 at 01:49
  • Yes you need to create it inside **IOSurface.framework** – Karim H Feb 26 '17 at 02:50
  • How to create tbd file? Is it from old executable file? – Trident Feb 26 '17 at 03:10
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/136655/discussion-between-trident-and-karim). – Trident Feb 26 '17 at 03:42
  • Can you create a tbd file for IOMobileFramebuffer too? – Trident Mar 03 '17 at 17:25
  • No, it is still not working, none of the API's i know in IOSurface framework are working to get display capture. Please help with the API too.. – Trident Mar 03 '17 at 21:29
  • As far as i know, IOMobileFramebufferGetLayerDefaultSurface fails on iOS 10, can you make a sample tbd with this API alone? I will check it – Trident Mar 04 '17 at 01:30
  • How fails, crash? – Karim H Mar 04 '17 at 01:39
  • No, the method fails with return code -536870201. I think, Apple removed the API.? – Trident Mar 04 '17 at 01:40
  • 1
    Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/137189/discussion-between-karim-and-trident). – Karim H Mar 04 '17 at 01:41