Declaration is only valid at file scope (extension)
<p>i try to make my app just in portrait mode iam using navigationcontroller
i get this error iam usring <code>Xcode7</code> and <code>Swift 2</code> And Target System <code>IOS 9.3</code><br>
Declaration is only valid at file scope </p>

<pre><code>        extension UINavigationController {
            public override func supportedInterfaceOrientations() -&gt; Int {
                return visibleViewController.supportedInterfaceOrientations()
            }
            public override func shouldAutorotate() -&gt; Bool {
                return visibleViewController.shouldAutorotate()
            }
        }

        extension UITabBarController {
            public override func supportedInterfaceOrientations() -&gt; Int {
                if let selected = selectedViewController {
                    return selected.supportedInterfaceOrientations()
                }
                return super.supportedInterfaceOrientations()
            }
            public override func shouldAutorotate() -&gt; Bool {
                if let selected = selectedViewController {
                    return selected.shouldAutorotate()
                }
                return super.shouldAutorotate()
            }
        }
</code></pre>

<p>Thnx </p>