How to set the swift compiler version? - ios

I am new at developing with Swift so I guess I am missing something...
I have an iOS app built in Swift 3, which is no longer supported in xCode. So I guess I need to migrate to a newer version of swift. Xcode (10.1) suggests Swift 4.2.
But ... There is a dependency which uses Swift 3. I tried recompiling this library (using Xcode 12.1 because I get some built errors in Xcode 10.1). In that project the Swift version is set on Swift 4.2. I compiled the and added the package to the original app.
Now I get an error: Module compiled with Swift 5.3 cannot be imported by the Swift 4.2 compiler.
How can is get the package compiled with Swift 4.2?
Thanks

Related

Module compiled with Swift 5.0 cannot be imported by the Swift 4.2.1 compiler

There are many questions similar to this, but they are mostly talking about this in the context of using cocoapods/carthage. I am not using either and have imported all my frameworks manually.
I am using Xcode 10.1. I just update one of my frameworks to their latest version (we need a feature only available on this version), and am now getting this error message. I also have Xcode 10.2, but the project has 3 other frameworks compiled in Swift 4.2.1 already, and when trying to build with Xcode 10.2 those throw the analogous error (module compiled with swift 4.2.1 cannot be imported by swift 5.0).
Most answers to this question revolve around setting the Swift language version to 4.2.1 for each target. However, since I am not using cocoa pods, I do not see any option in Xcode to change the swift language version of this individual framework. Any ideas? Thanks
This error kept showing for me on Xcode version 10.3, even though I had my Swift version in the project set to 4.2. I tried deleting the DerivedData and everything, but to no avail. I installed Xcode 10.1, and it worked perfectly without any issues.

Swift- Reusable Framwork not working in higher version xcode

I have create a simple reusable framwork and run that on XCode 9.4.1 and and seprate the .framwork file
When I am using this framwork with XCode 10.1 there is an error coming like
Module compiled with Swift 4.1.2 cannot be imported by the Swift 4.2.1 compiler: /Users/apple/Desktop/projectName/demo.framework/Modules/Demo.swiftmodule/arm64.swiftmodule
Is there any way to use that previous framwork in my latest code, or any other suggestion.
Should I need to compile that framwork on latest XCode 10.1, If yes, does this work on XCode 9.4.1 or lower version.

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.

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