10

For instance, I would play around Swift 4.2, but I don't want to use Xcode 10 beta version, I have Xcode 9.4.1.

I wonder if there is any way do it, is it possible?

Ahmad F
  • 30,560
  • 17
  • 97
  • 143

2 Answers2

18

I figured it out that Yes it is possible. You can achieve it by installing the latest Snapshot:

Development Snapshots are prebuilt binaries that are automatically created from mainline development branches.

https://swift.org/download/#snapshots

Snapshot is a toolchain that you can install into Xcode which contains the latest compiler, leading to let you able to build your app on the latest tools.


How to setup a snapshot into Xcode?

1- Download the latest snapshot (Xcode) from Swift website.

2- Install the downloaded snapshot .pkg file.

3- Run Xcode and then go to: Xcode -> Toolchains -> Manage toolchains.

4- After selecting "Components" - "Toolchains" options, you should see:

enter image description here

Select "Swift Developer Snapshot" and thats it! You might need to reset Xcode after doing the above steps.

Reminder: You should reselect "Xcode 8.3.3" option after done playing around Swift 4, as mentioned in Swift - Using Downloads section:

To submit to the App Store you must build your app using the version of Swift that comes included within Xcode.

Ahmad F
  • 30,560
  • 17
  • 97
  • 143
  • 1
    Just to double check, you can do this with ANY Xcode8 version or there is a certain requirement? – mfaani Sep 21 '17 at 15:21
  • @Honey I'm using Xcode 8.3 and it works for me, I assume it should work for any Xcode 8 version... – Ahmad F Sep 21 '17 at 15:23
  • And your last line kinda translates to: "No Swift4--Xcode8 apps in appstore". It's available for local development right? – mfaani Nov 19 '17 at 20:00
  • In doing so did you run into any issues? I guess you have to switch this everytime you want to go back to Swift3 and also delete all your derived data...anything else I would need to do? – mfaani Nov 21 '17 at 23:39
  • Funny! I first went to Xcode >> preferences >> Components but **didn't** see the Toolchains. I went back and first installed the package and now I do see it! Should have followed the exact sequence. Additionally Xcode 8.x doesn't know about iOS 11, so you would have to put some effort in so you can download its simulator. See [here](https://stackoverflow.com/questions/44381860/use-xcode-8-with-ios-11) – mfaani Nov 22 '17 at 00:08
  • 1
    I tried this solution, however I am still facing a strange issue. My question is posted here https://stackoverflow.com/questions/48073482/running-swift-4-code-on-xcode-8-3-issue-with-xcode-snapshot . Please help – Shradha Jan 03 '18 at 09:40
  • **Xcode 12.4 gives error**, something like "`Xcode's SDK has Swift 5.3.1, but Toolchain has 5.3.2, which maybe uses features not available in 5.3.1`" – Top-Master Dec 21 '22 at 07:04
2

Although it is not directly from the Xcode, you could also use the Iswift which should has the latest swift version (latest snapshot).

a.masri
  • 2,439
  • 1
  • 14
  • 32