XCode 8 compatibility with swift 2.2 - ios

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):

Related

Xcode9 cannot read swift2. Xcode 8.2 cannot run on ios10.3. Now what?

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.

Unsupported Swift Version

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.

No such module "UserNotifications" in Swift 2.3

I'm using Swift 2.3 on Xcode 7.3.1 and when in AppDelegate I'm trying to import
import UserNotifications
it gives me the error that "No such module UserNotifications". What is the problem and how can I fix that?
I've tried to run it on Xcode 8 with defined SWIFT_VERSION = 2.3, but I get a lot of errors in Alamofire framework, but I set inside of Alamofire swift version, too. So I decided to continue working on Xcode 7.
So, is it because of Xcode versions or I can fix that on Xcode 7, too? My target iOS is 10. I copied inside of supported platforms 10.2 folder, so I can run on iOS 10 device from Xcode 7
You can't simply mix swift2.3 and swift3 in a single project within single target and this is also not a recommended approach.
The error which you are getting is due to UserNotifications framework. This framework has been added in xcode8 so you can't use this framework in xcode7.3.1 .
Also if you are planning to use swift2.3 in Xcode 8 then you have to use Legacy Swift Version if you made it yes then you will be able to run your project which is in swift2.3, but you will be not able to use syntax of swift3.
TO open swift 2.3 project in xcode 8, you have to on legacy form build setting for target and alamofire both.

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.

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