Downgrade xcode project from swift 3 to swift 2.2 - swift

I downloaded the new xCode 8 beta. When i opened my old project(in swift 2.2), i clicked the convert to new swift syntax, and i clicked swift 3. The problem is that i use a framework downloaded with carthage (Kanna). I have tried to use the:
carthage update
but it doesn't work.
When i try to run the code on the new Xcode-beta, i get this error:
Module file was created by an older version of the compiler; rebuild 'Kanna' and try again:

Seems like i am very late to answer but there is update available for 'Kanna' framework supporting swift 3.0. You can add this to your podfile if you use CocoaPods
use_frameworks!
pod 'Kanna', '~> 2.0.0'
Or for Carthage you can install like
github "tid-kijyun/Kanna" ~> 2.0.0

First of all save a backup of your current project. Now!
Solution 1
Open your project with Xcode 7.3.1, it uses Swift 2.2 so it will signal you a bunch of errors. Since you know Swift 2.2 you should be able to fix the errors and make you project again compatible with Swift 2.2
Solution 2
In Xcode 8 beta you can choose the Swift versione (Swift 2.3 or Swift 3.0). Select Swift 2.3 (it's fully compatible with Swift 2.3 but does support the new iOS API). Then, again, fix the errors manually.
Solution 3
Open the library you are using and use Xcode 8 to upgrade that to Swift 3.0. This is a temporary solution until the developer of that library will provide the upgraded code

When you open your project with Xcode 8.0 for the first time, you will be prompted via the migration assistant to do a migration pass. The assistant can also be invoked manually from the menu
Edit -> Convert -> To Current Swift Syntax…
If you upgraded code e.g. 2.3 to 3.0 and now want downgrade to 2.3 you can use above. If any errors occur copy your code from last commit in your repository and it should work fine.

Related

Module compiled with Swift 5.1.3 cannot be imported by the Swift 5.3 compiler Xcode 12

We are creating a custom framework using CI Jenkins build which is having Xcode 12 and try to import in another project which is using Xcode 11.6 and that shows the above error.
I am getting the above error while I am importing the above framework created by Xcode 12 but not working on Xcode 11.5.
Please provide the solution.
Xcode 11.x uses different command tools which causes mentioned problem. You have to update the project to the 12.0 and then you can use your custom framework.
Or you can manually change Swift version in the project files of your framework project. However, there is no point why not update the project ¯_(ツ)_/¯.

"Not Supported by this Version of Xcode” and After Update Xcode Raises "Unsupported Swift Version"

After updating iPhone to iOS 12.2 I encountered this error in Xcode 10.1:
“This iPhone is running iOS 12.2, which may not be supported by this
version of Xcode.”
So I have to update Xcode to latest version and after updating Xcode to 10.2, when I open the project, Xcode show another error that say:
Unsupported Swift Version
“MyProject” contains source code developed with Swift 3.x. This version of Xcode does not support building or migrating Swift 3.x
targets.
Use Xcode 10.1 to migrate the code to Swift 4.
Now I couldn't run the project correctly in neither Xcode 10.1 nor 10.2!
I think I have to update my code to Swift 5 to Xcode 10.2 be able to compile the code. Am I right?
But updating the whole project is overwhelming.
Is there any other way to resolve the problem?
The situation is neither dire nor daunting. All you really have to do is open the project with Xcode 10.1, mark the code as Swift 4, and close the project again. It would be good to migrate the code to Swift 4, though you don't have to; if you do, you certainly don't have to run it on a device — all you need to do is compile it as valid Swift 4. And the migrator will help you do that.
You will then be able to open the project in Xcode 10.2 and proceed however you like. Optimally you would then migrate again, to Swift 5, but you can postpone that step if you like.
But updating the whole project is overwhelming.
That is a matter of opinion, really. And after all, you got yourself into this situation by not migrating out of Swift 3 earlier (you have had literally years to do that, but you didn't), and by updating the system on your device.
Is there any other way to resolve the problem?
Not given your specifications. If you wish to run on this device that you have updated, you must update to Xcode 10.2, and you can do that only if you migrate out of Swift 3, which you can do with Xcode 10.1.
Open Xcode and change the project's Swift version to the latest (it'll say "unspecified").
Also update your project's Build Settings Library Search Paths to include this at the top:
$(SDKROOT)/usr/lib/swift
I have same issue while migrating code from Swift 3.x to Swift 4+.x :
Try to check two main things :
Target and project setting swift version should be 4.2 or swift 5 ( in case of XCode 10.2)
change build system.

How can I update swift from 3.1 to 3.2, but not to 4.0

I have checked the question related to how to find the current Swift version by the command swift --version, but how can I upgrade my Swift version from 3.1 to 3.2? (because the Xcode 9 only supports Swift 4.0 & Swift 3.2)
To build successfully both in Xcode 8 & Xcode 9, it's better to upgrade Swift from 3.1 to 3.2. But how?
My target was to make sure build successfully both in Xcode 8 & Xcode 9, So that publish with Xcode 8 would be OK, and try out the feature of Xcode 9 is OK too. So I will not upgrade code to swift 4.0 yet until Xcode 9.0 official edition is published.
After my test, I can't convert my code from swift 3.1 to 3.2 by Xcode 8.3.3's 'edit->convert' function.
The reason why I try to convert the code to Swift 3.2 is that I will get error of "Module compiled with Swift 3.1 cannot be imported in Swift 4.0" if I build the code with Xcode 9.
You can try this:
Build Settings -> Swift Langauge Version -> Swift 3.2.
Edit -> Convert -> To Current Swift Syntax.
Noted: These step using Xcode 9
Swift 3.2 is a stopgap solution to continue using Swift 3 code under Xcode 9 without fully converting projects to Swift 4.
The Swift version included in Xcode 8.3.3 is 3.1. Converting your code to Swift 3.2 under Xcode 9 does not guarantee that it will still compile under Xcode 8.
I'm not sure compiling Swift 3.1 code as Swift 3.2 under Xcode 9 requires any conversion at all, since they both share the same syntax. You may have to fix some API calls to compensate for changes in the new SDKs.
Apple has a little more information here:
https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Compatibility.html
(updated)
Regarding your last image, if you have the source code for the Runes module, you'll have to recompile it under Xcode 9. That will make use of Swift 3.2 and allow it to be imported in Swift 4.
Dependency modules/ frameworks in swift have to be recompiled w/ xcode9 since swift is not ABI compatible/ stable. If you have included dependencies using package distribution systems like carthage or cocoa pods, the modules would be recompiled w/ xcode9 and you shouldn't see this issue. If you are linking packages built distributed in binary format, then you can run into the issue
You do not have to convert it.
Swift 3.2 is not an actual version. It is how Xcode 9 (and the Swift 4 compiler) calls Swift 3. (I guess to differentiate from Swift 3 built with Xcode 8).
https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Compatibility.html
From Option Menu: Edit -> Convert -> To Current Swift Syntax
Above steps help you to convert into current swift syntax.

Module compiled with swift X.1 cannot be imported in Swift X.0.2

Swift 3.1 came out and I'm receiving this error message in my project:
Module compiled with swift 3.1 cannot be imported in Swift 3.0.2
So how do I tell Xcode to start updating my project and migrate it to Swift 3.1?
It is likely that you are including 3rd party frameworks/libraries. Those are what need to be updated/recompiled. If you are using Carthage or Pods you should just rebuild those libraries and make them available to your app. The problem isn't your code. When you compile it, it will compile to 3.1
etayluz
Upgrade your Xcode to 8.3 and your Swift version will be 3.1
I use Carthage to update library/framework again, with option --no-use-binaries
carthage update --no-use-binaries
These steps helped me.
These things happens sometimes when your Xcode doesn't support certain version of your third party dependencies.
Try to use proper version of your third party dependencies compatible with Xcode version.
Clear your Derived data in Xcode. Xcode -> File -> Workspace settings -> Click on the grey arrow mark beside Derived data.
Check carthage version by running carthage version. It should be above 0.20.0. Run carthage update --platform iOS --no-use-binaries in your terminal. Gets rid of compatibility issues.
Clean your project. Command + Shift + K. Then build and run.

Xcode 7: Force Cocoapods to compile in Swift1.2

Xcode 7 is available, but I do not wish to migrate to Swift 2.0 just yet.
I have a problem with CococaPods. They seem to be compiled in Swift 2.0 or some new Xcode features and hence not working :)
As I use few pods that are almost abandoned and hardly maintained - it will take some time for me to migrate from them, or for them to migrate to Swift 2.0. How do I force Xcode 7 to compile them the old way ? :)
p.s. I did try changing Preferences > Locations > Command Line Tools to Xcode 6.4 (6E35b) but that does not seem to work.
Xcode 7 will only run swift 2.0. You should use either fall back to Xcode 6.4 or must upgrade to Swift 2.0.
If you decide to shift, you can integrate older libraries them directly rather than pods for now until they support swift 2.0. Even better if you fork them out, update them to Swift 2.0 and generate a pull request for admin to merge and until them use forked ones by providing url to your github like
pod 'Alamofire', :git => "https://github.com/yourgithubprofile/Alamofire.git"