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!
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
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.
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
Xcode 9 - Xcode 10
Select your target, then in your Build Settings, search for "swift language" and then you will find Swift Language Version.
Related
I have just upgraded from xcode 10.1 to xcode 11.2.1. Now whenever I open my existing project in xcode 11.2.1 which was built in swift 3.0 it shows me "Unsupported Swift Version".
Please anyone can give me a brief description about it.
You cannot run swift 3 on Xcode 11. Download a version of XCode 10.1,You can run both.There will be option to migrate code to swift 4.
here you can download XCode 10.1:
XCode 10.1
Please check this link below. You can upgrade to swift 4.
https://medium.com/#hanif.awan2007/tips-upgrading-your-code-from-swift-3-to-swift-4-dbcba128b48b
You have a guide on official documentation:
https://swift.org/migration-guide-swift4/
First check you build settings:
You have an option "Swift language version" change this to swift4.
Then, try to compile and fix your warns / errors. Most of them can be automatically fixed by xcode.
If you got some pod dependencies, update it.
Go to project navigator> Build Settings. search for swift Compiler - Language and change this to desired version.
I recently had to update to Xcode 10.2 since my iPhone automatically updated to iOS 12.2 and I have to use it for some in-app purchase testing.
The project uses Swift 4.2 and Realm.
I knew I had to update Realm so here is what I did...
Downloaded realm-swift-3.14.1
In Xcode, I replaced the frameworks with the latest from the download in my case the ones inside folder, swift-10.2.
"In the past the Realm folders used to be labeled as the Swift version now they are labeled per the Xcode version"
Compiled and then I got the following error.
Module compiled with Swift 4.2 cannot be imported by the Swift 5.0 compiler: /Users/userName/MyApp/RealmSwift.framework/Modules/RealmSwift.swiftmodule/i386.swiftmodule
What am I missing?
What do I need to do to be able to use my Swift 4.2 project inside Xcode 10.2 and RealmSwift?
Is RealmSwift ready for Xcode 10.2?
On Xcode, click on your xcodeproj file.
Then on the left bar, choose the target.
Now click to the build setting tab and look for the Swift language version.
Here you can change the swift version to select the 4.2 again.
That error should only show if you were using a version built in older versions of Xcode (for instance, if you using Realm from swift-10.1 directory). Try to remove any Realm frameworks you have from the project, clean the project, delete project's derived data directory, restart Xcode and then make sure to add both Realm and RealmSwift from the swift-10.2 directory.
So, today I updated the ios on my iphone to ios10.3.
Then I clicked to run my project in xcode, and... xcode8.2 responded that it does not support devices running ios greater than 10.2, and that I should update xcode.
So then I updated xcode to the current version which is xcode9.0.
So then Xcode says that it cannot read swift2.3 projects, and that I must use a lower version to convert to swift3.
Now I read here on stackoverflow that only xcode 8.2 is able to convert my project to swift 3.
But then if I do so, my project won't compile on my phone.
What am I supposed to do?
What to say about old projects I have around?
Why would Apple make Xcode stupid that it cannot read any version of swift?!
How am I supposed to convert and compile any old projects now and in the future?
Update Xcode 8.2 to 8.3 to support iOS 10.3. Use Xcode 8.3 to update your Swift 2 code to Swift 3. Then use Xcode 9 to migrate to Swift 4.
You can find different versions of Xcode at https://developer.apple.com/download/more/
Apple is always moving forward. If you wish to be an iOS/macOS developer you need to keep up.
I've downloaded Xcode 9 Beta 4 to fix a problem I have on my app in iOS 11.
However now Xcode won't let my build my app because Realm (and RealmSwift) are in Swift 3.1 and not 3.2.
Here is the message :
Module compiled with Swift 3.1 cannot be imported in Swift 3.2
I don't use CocoaPods or Carthage. Do you know how can I solve this issue ?
Make you selected command line tools for Xcode 9. You can find it Preferences -> Locations -> Command Line Tools.
Then clean your project and build again. Should work.
I developed my project in SWIFT 2.3, but there is one issue:
MPMoviePlayerController iOS fullscreen function has wrong icon in iOS10 you can also see this in developer forums..
https://forums.developer.apple.com/thread/69735
I download new Xcode 8.3 beta for check this problem, but I am not able to run my project in Xcode 8.3 beta version, because there is no option in build setting Use Legacy Swift Language Version
And I read release note of Xcode8.3 beta version, here apple mention that :
Xcode 8.3 no longer supports Swift 2.3. Please migrate your projects containing Swift 2.3 code to Swift 3 syntax by opening the project and choosing Edit > Convert > To Current Swift Syntax.
My question is now on word is it compulsory to convert code in Swift 3.0?
I am trying to convert that project in new Swift 3.0 but I am getting more then 700 error.
Can any one help me how can I convert easily?
Thanks in advance.