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?
Asked
Active
Viewed 2.2k times
15
-
1Perhaps this answer in the Apple exchange will help: https://apple.stackexchange.com/questions/181472/is-it-possible-to-select-which-version-of-swift-to-use-in-xcode – blurfus Jul 04 '19 at 21:00
-
5See [How do I see which version of Swift I'm using](https://stackoverflow.com/questions/30790188/how-do-i-see-which-version-of-swift-im-using) – rmaddy Jul 04 '19 at 21:20
-
2@rmaddy thanks man, that worked! – surftijmen Jul 04 '19 at 22:07
2 Answers
23
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.

surftijmen
- 743
- 1
- 10
- 27
0
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.

Kwnstantinos Nikoloutsos
- 1,832
- 4
- 18
- 34