How to migrate from swift 2.2 to swift 3.0 on Xcode 8.0.
Do i need to update all the 3rd party libraries also ?
Please help !!!
Swift 2.2 unfortunately doesn't work with Xcode 8. But Apple made a good move still supporting Swift 2.3, which is basically almost the same as 2.2.
The problem is with 3rd party libraries, which must be in the same version of Swift as your project.
So, if you're using Swift 2.3, you can't use libraries, that are written in Swift 3.0.
Related
I have a question,
can I write a library like Cocoapods pod in Swift 4 and Xcode 9 and then use it in older projects, written in Swift 3 or earlier?
E.g. it would have a class that uses the new Codable protocol. Would that class be working in older projects?
Thanks for your help.
As a rule, no. Xcode 9 will let you go back to Swift 3.2, but not 3.1. If you need earlier Swift compatibility, you'll have to re-download Xcode 8.3.3 which is available at https://developer.apple.com/download/
Good luck!
I am using Swift 2.2. But as per requirement of Charts library, I need to upgrade Charts to version 3. Should I migrate to Swift version 3 or I can use this library of version 3 in my Swift 2.2.
Charts v3 is strictly compatible for Swift 3+. (Charts v2 is for Swift 2.3)
And no, you can't mix Swift 2.x and Swift 3.x in the same project. So yes, you should migrate to Swift 3.1 (latest stable).
Note: in the future (Xcode 9), you'll be able to mix Swift 3.2 with Swift 4.0, so it will be easier to transition for this kind of situations.
I have a static library that I converter from old Swift to Swift 2.3 and later to Swift 3.0.
Now I need both version (2.3 and 3.0) of the library, but I forgot to take a backup of version 2.3. And I only have 3.0.
Is there a simple way to convert back from Swift 3.0 to Swift 2.3?
Simple, not really, but this will work.
If you don't have it, download XCode 7.3.1 from Apple
Open your library in the 7.3.1 version and correct whatever errors appear
Migrate the corrected code from step 2 into XCode 8.2 or lower (8.3 will not support Swift 2.3)
As mentioned in the comments, maintaining your code in a version control system will spare you problems like this in the future, and is generally just a good idea.
You don't even need to set up your own system, since git is part of MacOS, and XCode can handle simple git features for you.
I have 2 Xcodes in my Mac(7.3.1 & 8.1). I want to work with ReactiveCocoa so I installed it via Cocoapods and later with Carthage. And when I import later in my ViewController import ReactiveCocoa I get the next error:
Module compiled with Swift 2.3 cannot be imported in Swift 3.0: /Users/myUser/Library/Developer/Xcode/DerivedData/RAC-grddczfrbaumbtglfcuzhxyzoodk/Build/Products/Debug-iphonesimulator/ReactiveCocoa.framework/Modules/ReactiveCocoa.swiftmodule/x86_64.swiftmodule
How can I fix that? I'm already working over it over 3-4 hours and nothing
Referring to the latest documentation (github):
"This documents the RAC 5 which targets Swift 3.0.x ..."
I assume that should not install 4.x version. try to "pod 'ReactiveCocoa'" -for installing the latest version-, version 5 for targeting Swift 3.
Also, check the section "Objective-C and Swift".
Hope that helped.
If you are looking for ReactiveCocoa that supports Swift 3.0, ReactiveCocoa 5.0 alpha 1 and the master branch does not support CocoaPods yet. But the support is WIP.
In the meantime, you may try the rex-modulemap branch.
When I open my iOS project built before the iOS 10 was released, I find it has an error about the ReactiveCocoa because of the version of swift. I try to use the method provided by Github, but it seems I failed. There are at least 18 errors when I try to convert to current swift.
There's RAC Releases for each Swift version, so if you're updating an old(er) codebase to a new version of swift, you will need to update RAC to the appropriate version.
RAC 4.x is for Xcode 7.3.x/Swift 2.2.x or Xcode 8.0.x/Swift 2.3.x
RAC 5.x is compatible with Swift 3.0 and 3.1.
RAC 6.x (not yet released) will be for Swift 3.1 with preliminary support of Swift 3.2 and Swift 4.0.