Is swift 3 not compatible with NSURL classes on iOS 9?
<p>I am migrating my Swift 2.2 code building and working fine on xcode 7 / ios 8 and ios 9.
As of <a href="https://stackoverflow.com/questions/38067678/swift-3-ios-compatibility">the answer to this question</a> Swift 3 is compatible with iOS 8 and newer. And I am also aware that I won't be able to use newer APIs.</p>

<p>In my app I am creating some https requests, downloading some files etc.</p>

<p>My assumption is that I should also be able to use the classes NSURL, URLSessionDownloadDelegate, NSMutableURLRequest, etc. all available from iOS (8.0 and later). </p>

<p>But either I (obiously) run into a crash running my migrated code on iOS 8.1 because I use the URL class (available from iOS 10) or the compiler complains 'NSURL' is not implicitly convertible to 'URL' (see also <a href="https://stackoverflow.com/questions/38931870/nsurl-is-not-implicitly-convertible-to-url-did-you-mean-to-use-as-to-expl">this question</a>).</p>

<p>Therefore I am not able to use the URL class, if I want to be compatible with iOS 9. </p>

<p>Here is some code to make things clearer:</p>

<p><strong>Swift 2:</strong></p>

<pre><code>class ServerCom: NSObject, NSURLSessionDownloadDelegate {
   private var fileURL: NSURL = NSURL()
    [...]       
           guard let urlString: NSURL =
        NSURL(string: params,
            relativeToURL: NSURL(string: dcParam.baseURL) )  else {
                let failed = "Could not generate URL from: \(dcParam.baseURL)\(params)"
                throw fetchAppXmlError.FAILED_URL_GENERATION(failed)
    }
    [...]
    let request = NSMutableURLRequest(URL: urlString)
    request.timeoutInterval = 10
    request.HTTPMethod = "GET"

}
</code></pre>

<p><strong>Swift 3</strong></p>

<pre><code>class ServerCom: NSObject, URLSessionDownloadDelegate {

 fileprivate var localFileURL: NSURL = NSURL()

 [...]

         guard let urlString: NSURL =
            NSURL(string: params,
                relativeTo: NSURL(string: dcParam.baseURL) )  else {
                    let failed = "Could not generate URL from: \(dcParam.baseURL)\(params)"
                    throw fetchAppXmlError.failed_URL_GENERATION(failed)
        }

 let request = NSMutableURLRequest(url: urlString)
 request.timeoutInterval = 10
 request.httpMethod = "GET"
 [...]

}
</code></pre>

<p>In the swift 3 code I get the following errors:</p>

<ol>
<li>At the line with: let request = ...:  'NSURL' is not implicitly convertible to 'URL'; did you mean to use 'as' to explicitly convert?</li>
<li>At the line with let urlString = ...: Cannot convert value of type 'NSURL?' to expected argument type 'URL?'</li>
</ol>

<p>I can't use localFileURL with type URL because this would be iOS 10 only.
I also can't use URLRequest instead of NSMutableURLRequest because it is also only available from iOS (10.0 and later). It seems that I always use somehow URLs of type URL rather than the "old" NSURL.</p>

<p>So my question is: Is there <em>any</em> way to use NSURL et. al. with swift 3 <strong>and</strong> iOS 9?</p>

<p>Or in more general, is there a way to do background downloads with swift 3 that will work on iOS 9 and iOS 10?</p>

<p>Does this inconsistency come from the bridging of NSURLComponents to URLComponents?</p>