I'm using Xcode 7.3 but my project is in Swift 2.1. I don't want to update my codes right now. So how can I choose or download older version of Swift compiler? Many thanks in advance!
-
3Don't upgrade Xcode if you don't want to upgrade Swift. – rmaddy Mar 25 '16 at 02:23
-
1@rmaddy Are there no other ways? – Lumialxk Mar 25 '16 at 02:25
-
1If you're building an app for the app store, your only choices are to use Xcode 7.2 or to update your code to Swift 2.2. – rob mayoff Mar 25 '16 at 02:28
-
4Note that you can have multiple versions of Xcode installed, so you can use Xcode 7.2 on existing projects and use Xcode 7.3 on new projects if you need to. – rob mayoff Mar 25 '16 at 02:29
-
4[You can download older versions of Xcode here](https://developer.apple.com/downloads/) if you need to. – rob mayoff Mar 25 '16 at 02:30
-
@robmayoff Many thanks for your professional comment! – Lumialxk Mar 25 '16 at 02:42
4 Answers
The following example is tested on Xcode 8.3 with swift 3.1
If you are using Xcode 8 you can download toolchains with needed Swift versions
1) Open this link: https://swift.org/download/#releases
2) Download Toolchain with swift version that you need. For example I have 3.1 version of swift and downloaded swift 3.0.2
3) Open .pkg file and install it.
4) Open Xcode and select in menu:
Xcode -> Toolchains -> Select Swift Version you need.
That is all folks

- 3,133
- 1
- 29
- 31
-
3Thanks for that. in Xcode 9-Beta though, I am getting `
:0: error: unknown argument: '-index-store-path' Command /Library/Developer/Toolchains/swift-3.1.1-RELEASE.xctoolchain/usr/bin/swiftc failed with exit code 1`. Any idea why? – Guy Daher Jun 12 '17 at 10:03 -
@Guy Daher Could you provider more information when did you get this error? do you have cocoapods or other dependencies in your project? maybe this can help? – Nikolay Shubenkov Jun 13 '17 at 07:20
-
1@GuyDaher I believe that Xcode 8.3 fix it. Try to clean your build, clean pod and run ´pod install´ again – Francis Rodrigues Jul 26 '18 at 14:28
Originally I posted this is a comment, but I should have just posted it as an answer:
If you're writing an app for the App Store, you can only use a release (non-beta) version of Xcode (see “Submitting Apps to the App Store using Xcode”) and the toolchain supplied with that version of Xcode (see “Using Downloads / Apple Platforms”). So you can either use Xcode 7.2 and continue using Swift 2.1, or you can use Xcode 7.3 and update your code to Swift 2.2.
You can have multiple versions of Xcode installed. You can keep Xcode 7.2 installed and use it for your non-updated Swift 2.1 projects, and use Xcode 7.3 on new projects. Note that you'll have to manually open each project in the appropriate version of Xcode. You can download old versions of Xcode here.
If you're not going to put your app in the App Store, then maybe you could extract the Swift 2.1 toolchain from the Xcode 7.2 bundle and turn it into a .xctoolchain
for use with Xcode 7.3, but you're really in unexplored, unsupported territory if you go that route.

- 375,296
- 67
- 796
- 848
-
These scripts are really handy for managing multiple versions of Xcode alongside one another: https://github.com/neonichu/xcode-install Personally I'd never leave it down to the Mac App Store to manage your Xcode for you. – Andrew Ebling May 25 '16 at 13:47
-
If you're following the answers involving a .xctoolchain
combined with Xcode 9 beta you'll encounter an error similar to this:
<unknown>:0: error: unknown argument: '-index-store-path' Command /Library/Developer/Toolchains/swift-3.1.1-RELEASE.xctoolchain/usr/bin/swiftc failed with exit code 1
The reason is that Apple has added a new feature/argument, which hasn't made its way to open source Swift yet. You can get around this issue by launching Xcode from the command line with the feature disabled like this:
/path/to/Xcode-beta.app/Contents/MacOS/Xcode -IDEIndexEnableBoltIndex NO
Thanks to the Swift team

- 6,582
- 2
- 24
- 40
Xcode 9 - Xcode 10
Select your target, then in your Build Settings
, search for "swift language" and then you will find Swift Language Version
.