Unsupported Swift Version - ios

I am following this tutorial and am trying to get the starter project to run. When I open the project, I see these warnings:
Unsupported Swift Version
The target “SocketChat” contains source code developed with Swift 2.x. Xcode 9 does not support building or migrating Swift 2.x targets.
Use Xcode 8.x to migrate the code to Swift 3.
On running this program stops executions and I get this error
Dependency Analysis Error Group
The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift. This setting can be set in the build settings editor.
I am using Xcode 9 beta. How can I resolve this issue and get the project running?

Your project possibly has swift 2.0, swift 2.1 or swift 2.2 version so Xcode 9 or later does not support that versions. and neither it can convert the swift 2.x's syntax to swift 4
Remember that xcode 9 or later has swift 4 version by default.
Open this project in Xcode 8 8.1, 8.2, or 8.3 your project will run successfully.

Related

I compiling Swift 2.3 project and have this issue on Xcode 8.1

I compiling Swift 2.3 project and have this issue on Xcode 8.1:
“Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.
After conversion still have issue
I have faced same issue with some of my pods,
You can resolve issue by setting Use Legacy Swift Language Version to true in your project setting.
repeat this step for every pod which throws this error.

Building frameworks for iOS 8 and above in XCode 8

I have recently updated to Xcode 8. Previously I was using Xcode 7 with Swift 2.2.
I have a framework that I built in with deployment target iOS 9.3. Now that I have moved to Xcode 8 I cannot use this framework.
Is there a way I can build a framework that will work for iOS sdks 8 and above?
I want to set the minimum deployment target of my app to iOS 8+.
Also
Alamofire for Swift 3 has been updated and I have updated my pod file.
Will I be able to run the app in iOS versions above 8?
Any help will be appreciated.
Yes it is possible to build frameworks for iOS 8 with Xcode 8. But if you try to support iOS 8 you could also use Swift 3, put If you use other frameworks like Alamofire, you have to be careful, because the latest version of Alamofire (4.x) requires a minimum iOS target version of iOS 9. So you have to use Alamofire (3.x). With Alamofire 3.5 you have to use Swift 2.3
So first you have to decide what's more important for you:
iOS 8 support: So you have to switch to Swift 2.3 and Alamofire 3.x
Swift 3 support: So you have to drop iOS 8 support, because Alamofire 4.x requires iOS 9
As you know that Xcode 8 supports only Swift 2.2 and Swift 3. Your framework is built on top of Swift 2.2. So there is no way that you can run or build the project in Xcode 8, you will get an error like "The project has an older version of Swift, Please build it with newer version of Xcode".
You can use Xcode 8 and you can set minimum deployment target to iOS 8. But you can't use any of the new Swift 3 features in there, I mean you can use it but it will not execute in iOS 8. For that you have to write code with class or API availability checking for each snippet you write.
If you use new version of Alamofire there is no chance that you can use it in iOS 8.0. You need an older version of it. Because Alamofire new version is Swift 3 and have minimum deployment target of iOS 10 I think.
So it is better to convert your project into Swift 3 or to Swift 2.3. That is the best way to solve this situation. Otherwise you will see more lot of problems eventually.

XCode 8 compatibility with swift 2.2

I'm getting tons of errors opening a project which was working under 7.3 in XCode 8 GM.
I want to keep my project swift 2.2 compatible and it should be able to work with xcode7.3 for the time being.
In XCode 8 GM I've set the flag
Use Legacy Swift Language Version
But still getting tons of errors from API's which have changed.
For example NSURL.absoluteString in XCode 7.3 defined as:
but in XCode 8 defined as an optional type:
I've tried changing the base SDK to ios9.3 but wasn't able to do it (also tried copying the SDK from xcode7.3 to xcode 8):

How can I choose Swift compiler version

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.xctoolchai‌​n/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.

Upgrading a Swift 1.1/1.2 project from Xcode 6 to Swift 2 project on Xcode 7

I have a project that I've been working on with my friend on Swift 1.1/1.2.
Unfortunately, when I upgraded my Xcode to the latest version, I noticed that the app will no longer compile and there are lots of errors.
Is there a way for Xcode 7 to compile for Swift 1.2?
If not, how do I get the old version of Xcode which does not use Swift 2?
Is Swift 2 app backward compatible with Swift 1 apps?
Can Swift 1.2 app run on iOS 9?
Are most developers using the Swift 2 now or not?
In Xcode start with Edit->Convert->To Latest Swift Syntax...
You may still have errors that you will have to resolve manually. Read the Xcode Release Notes to see what changed in Swift 2.

Resources