21

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?

3

2 Answers 2

33

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

Sign up to request clarification or add additional context in comments.

1 Comment

What if this is a Swift Package?
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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.