Pod written in Swift 4 - ios

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!

Related

Swift framework for all Xcode versions

I provide a Swift framework for my customers.
It would only work in Xcode 10.3 (Or am I doing anything wrong?)
For other Xcode, it does have Swift compatibility issues.
So I am planning to release a series of versions of my framework so that a customer with a particular Xcode version can have the respective framework version of mine.
And it is pretty complex. Because for every release or bug fix I need to generate a bunch of versions.
I just want validation if this is the right approach.
How do I simplify this?
The compatibility issue you have is not from the version of the Xcode, is from the Swift version of the Framework. There is a difference.
In every project you can set the Swift version, but unfortunately you can't have more than one swift version per project. The current accepted ones are Swift 4, Swift 4.2 or Swift 5, as you can see in Xcode > Target > Build Settings:
Xcode 10.0 was the last version to support Swift 3 and is currently obsolete. I wouldn't create a framework version for it.
So, I would recommend you to either focus only on the latest Swift version and create a new Framework version every time a new Swift version appears (the most common approach), or start with the current three Swift versions and give them maintenance until the Swift version is deprecated.

Convert from Swift 3.0 to Swift 2.3

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.

How can I compile Swift 2.3 Code in Xcode 8

I have many issues with my project Swift 2.2 in Xcode8, the pod library generates many error, I did an update of cocoapods and library but I still have those errors, I have convert syntax to Swift 2.3 but the errors are still there. I do not want to convert swift 3 for the time being.
Here is a picture of errors :
Socket Io Client Swift errors
Thank you in advance and sorry for English errors.
Okay, so the problem is that the library you are using is Swift 3. So there is no point saying "I do not want to convert to Swift 3". You have converted to Swift 3 whether you like it or not. You do not need to compile this code as Swift 2.3. You need to compile it as Swift 3.
To run Swift 2.3 in Xcode8, set Use Legacy Swift Language Version to YES within your projects, your targets and your pod framework targets Build Settings.

ReactiveCocoa, Module compiled with Swift 2.3 cannot be imported in Swift 3.0 issue. How to fix?

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.

Migrate from swift 2.2 to swift 3.0 in xcode 8

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.

Resources