How to change Swift version from 5 to 4 in Xcode?
Asked Answered
W

2

19

I am programming with Swift in Xcode (MacBook Air 2015) and I want to change my Swift version from 5 to 4. How to do that?

Windjammer answered 4/7, 2019 at 20:48 Comment(3)
Perhaps this answer in the Apple exchange will help: apple.stackexchange.com/questions/181472/…Slapdash
See How do I see which version of Swift I'm usingEliason
@Eliason thanks man, that worked!Windjammer
W
28

Project ► (Select Your Project Target) ► Build Settings ► (Type
'swift_version' in the Search bar) Swift Compiler Language ► Swift
Language Version ► Click on Language list

Here you can change your version.

An example screenshot

Windjammer answered 5/12, 2020 at 15:3 Comment(1)
What if this is a Swift Package?Boltonia
L
2

For SPMs you can do as follows:

let package = Package(
    name: "Foo",
    products: [
        .library(
            name: "Foo",
            targets: ["Foo"])
    ],
    dependencies: [
    ],
    targets: [
        .target(
            name: "Foo",
            dependencies: [])
    ],
    swiftLanguageVersions: [.version("5.7"))]
)

swiftLanguageVersions is the version of the Swift language to use for compiling Swift sources in the package. The value is passed as-is to the Swift compiler's -swift-version flag.

Lilian answered 2/2, 2023 at 23:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.