You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This means that to write portable (macOS 10.11+ and Linux) code that uses a Foundation API introduced in macOS 10.11 we must convert the following straightforward code (2 module-level URL constants):
import Foundation
let baseURL: URL = ...
let resourceURL = URL(fileURLWithPath: "path", relativeTo: baseURL)
to this
import Foundation
let baseURL: URL = ...
let resourceURL: URL
#if !os(Linux)
resourceURL = {
guard #available(macOS 10.11, *) else {
fatalError("This program requires macOS 10.11 or greater.")
}
return URL(fileURLWithPath: "path", relativeTo: baseURL)
}()
#else
resourceURL = URL(fileURLWithPath: "path", relativeTo: baseURL)
#endif
Swift packages should be able to specify a minimum target platform version. There's also the problem of the impedance mismatch - if we were allowed to do #if os(Linux) && available(macOS 10.11, *) the resourceURL assignment line would not need to be duplicated in each block.
The text was updated successfully, but these errors were encountered:
I'd like to just use this for the ability to control the deployment target, as I'm not sure we have another bug tracking that and it is pretty important.
Additional Detail from JIRA
md5: 9a8cd848cb1275b3f7fcb018080fd12e
Issue Description:
On macOS, swift build hardcodes the swiftc flag
This means that to write portable (macOS 10.11+ and Linux) code that uses a Foundation API introduced in macOS 10.11 we must convert the following straightforward code (2 module-level URL constants):
to this
Swift packages should be able to specify a minimum target platform version. There's also the problem of the impedance mismatch - if we were allowed to do #if os(Linux) && available(macOS 10.11, *) the resourceURL assignment line would not need to be duplicated in each block.
The text was updated successfully, but these errors were encountered: