Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-2535] [SwiftPM] Ability to control deployment target #5222

Closed
kevints mannequin opened this issue Sep 1, 2016 · 5 comments
Closed

[SR-2535] [SwiftPM] Ability to control deployment target #5222

kevints mannequin opened this issue Sep 1, 2016 · 5 comments
Labels

Comments

@kevints
Copy link
Mannequin

kevints mannequin commented Sep 1, 2016

Previous ID SR-2535
Radar rdar://problem/28253354
Original Reporter @kevints
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Package Manager
Labels Bug
Assignee None
Priority Medium

md5: 9a8cd848cb1275b3f7fcb018080fd12e

Issue Description:

On macOS, swift build hardcodes the swiftc flag

-target x86_64-apple-macosx10.10

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.

@belkadan
Copy link

belkadan commented Sep 1, 2016

The * in #available(macOS 10.11, *) means "all other platforms".

@belkadan
Copy link

belkadan commented Sep 1, 2016

Arguably Swift packages should still let you set the minimum deployment target on certain platforms, but this limitation isn't it.

@ddunbar
Copy link
Member

ddunbar commented Sep 1, 2016

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.

@belkadan
Copy link

belkadan commented Sep 1, 2016

Okay, fair enough. Sorry for jumping the gun.

@keith
Copy link
Collaborator

keith commented Oct 9, 2016

You can now pass the target flags mentioned in order to override the hard coded 10.10 value. #715

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants