'sharedApplication()' is unavailable: Use view controller based solutions where appropriate instead
<p>This same error has happened before in different contexts. </p>

<p>I only created a new <code>NotificationServiceExtension</code> and I tried get reference to AppDelegate by </p>

<pre><code>- (AppDelegate *)appDelegate
{
    return (AppDelegate *)[[UIApplication sharedApplication] delegate];
}
</code></pre>

<p>I get following compile time error.</p>

<blockquote>
  <p>'sharedApplication()' is unavailable: Use view controller based
  solutions where appropriate instead.</p>
</blockquote>

<p>I have no cocoapod dependency etc.</p>

<p>How can I resolve this issue? Any build settings that I change?</p>