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

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.

Related

Xcode: Your target contains an unsupported Swift Version

I am getting this popup when I open my project in XCode 12, but I can compile the app fine:
It says
The target 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.
I am using Cordova so perhaps there's some legacy Swift code somewhere.
My question is how do I find out what swift files Xcode means? Any way to search for them?
I tried the logging from XCode in Console.app but found nothing there.

Module compiled with Swift 5.0 cannot be imported by the Swift 5.1 compiler:

Getting this error while import AudioKit in my new project in XCODE 11 latest version.
How to solve this issue?
Unless you need Swift 5.1 or something specific to Xcode 11, I'd recommend staying on Xcode 10.x and moving over device support files so you can debug on iOS 13 devices.
https://github.com/filsv/iPhoneOSDeviceSupport
Or, if you've already downloaded Xcode 11.x, just move everything you want from
/Applications/{XCODE11}.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/
to
/Applications/{XCODE10}.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/
This is probably better advice for someone like me stuck using a closed source module built in Swift 5.0, but you're the first SO result on Google for this error message.

How to support iPhone X in swift 1.2 project?

I have an swift 1.2 project, which can runs in Xcode 7.2.1. And now need to support iPhoneX. Xcode 9 cannot compile the project.
Is there anyway Xcode 7.2.1 can run iPhoneX simulator? or must need to upgrade the project which I don't want to.
Thanks.
You can't. You have to update your project to at least Swift 3.2, which is the last Swift Version supported by Xcode 9.
How big is the project? Xcode has Swift upgrade wizard built. If you just want to run a Simulator, you can make a copy of your project, upgrade it to current Swift supported in Xcode 9 and run it as test.

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.

Downgrade xcode project from swift 3 to swift 2.2

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.