I have just discovered following behaviour of NSURLComponents and I'm looking for confirmation if it is in fact a bug.
var components = NSURLComponents(string: "apple.com")!
components.scheme = "http"
print(components.scheme) // prints "Optional("http")\n"
print(components.URL?.absoluteURL) // prints ""Optional(http:apple.com)\n", I'd expect http://apple.com
When trying to set scheme as "http://" I get an error which is in line with what documentation says. So it seems there is no way of setting the scheme after URLComponents initialisation and getting correct URL as a result.