title: Access Private UIKit Function Without Using Bridging Header
body: <p>Consider the private C function <a href="http://iphonedevwiki.net/index.php/UIImage#UICreateScreenUIImage" rel="nofollow"><code>_UICreateScreenUIImage</code></a>, which returns a <code>UIImage</code> snapshot of the current device screen:</p>
  
  <pre><code>OBJC_EXTERN UIImage *_UICreateScreenUIImage(void) NS_RETURNS_RETAINED;
  </code></pre>
  
  <p>I can put this in a bridging header and access it in Swift like so:</p>
  
  <p>MyApp-Bridging-Header.h</p>
  
  <pre><code>@import UIKit;
  UIImage *_UICreateScreenUIImage(void) NS_RETURNS_RETAINED;
  </code></pre>
  
  <p>MyClass.swift</p>
  
  <pre><code>let image = _UICreateScreenUIImage()
  print(image) // &lt;UIImage: 0x7fc4ba6081c0&gt;, {375, 667}
  </code></pre>
  
  <p>Is there a way I can access <code>_UICreateScreenUIImage</code> in pure Swift without using a bridging header?</p>
  
  <p>An initial thought was to create an extension on <code>UIImage</code>, but the extension is expecting me to declare the body of the function in the extension:</p>
  
  <pre><code>extension UIImage {
      public func _UICreateScreenUIImage(_: Void) -&gt; UIImage // "Expected '{' in body of function declaration"
  }
  </code></pre>
  
  <p>This implementation is flawed anyways, as <code>_UICreateScreenUIImage</code> isn't a method on <code>UIImage</code>.</p>
  
  <p>Is exposing and accessing this method possible in pure Swift?</p>
  
  <hr>
  
  <p>People seem to be confusing my question with "How do I take a screenshot?"  That's not what I'm asking.  I'm asking how do I access methods like <code>UIImage *_UICreateScreenUIImage(void);</code> in Swift.  It could be any private method, such as <code>+(UIImage *)_deviceSpecificImageNamed:(NSString *)name inBundle:(NSBundle *)bundle;</code> or <code>+(UIImage *)_pu_PhotosUIImageNamed:(NSString *)name;
  </code>.</p>