How to fix "SWIFT_VERSION '3.0' is unsupported, supported versions are: 4.0, 4.2, 5.0" error in Xcode 10.2?
Asked Answered
A

18

151

I'm trying to run downloaded from app, try to open in Xcode and have an error:

" Showing Recent Messages
:-1: SWIFT_VERSION '3.0' is unsupported, supported versions are: 4.0, 4.2, 5.0. (in target 'SimpleWeather')"

Screenshot added

Albumen answered 26/3, 2019 at 20:53 Comment(10)
Update the stuff. 3.0 is pretty old in terms of Swift evolution speedScald
i'm use Xcode 10.2 and try open old 3.0, but can't run program coz i have errors.Albumen
Open and update the project in Xcode 10.1. It's possible to have multiple different versions of Xcode on disk.Scald
updated version of Xcode ;(Albumen
Restore the previous version from the backupScald
same problem...Albumen
OMG!!! I took me three hours of my time to download XCode 10.2 only to find out I cannot build my apps anymore. I have no backup of XCode 10.1 ! This is just madness Apple should pay me for.Mohsen
I have even more funnier case: error: SWIFT_VERSION '5.0' is unsupported, supported versions are: 3.0, 4.0, 4.2. (in target 'Starscream')Phocaea
For people wondering, you can download old versions of Xcode here: developer.apple.com/download/moreVedda
I think this was answered similarly here: #43227247Meggie
W
138

Select the target 'SimpleWeather' in the project and change language version Target->build setting -> Swift compiler language -> select 5, 4.2 etc

image of build setting for changing compiler language

Whetstone answered 27/3, 2019 at 9:33 Comment(1)
No one here to comment on how this is a life saver. I had been reinstalling old versions of Xcode to the tune of many hours of unzip, etc. .....you knowTerceira
R
86

******** Easiest way: **********

1.Click on PODs in the left column.

2.In the centre column select the pod you want, then navigate to "build settings" in the top right panel.

3.Then search "Swift Language Version" and change to a known version.

enter image description here enter image description here

Riverside answered 31/3, 2019 at 0:49 Comment(0)
L
57

For Xcode 10.1, select your Pods File

enter image description here

-> Go to Build Settings -> Choose your Pod -> Search "Swift" -> Navigate to "Swift Language version" -> Set to desired language version.

enter image description here

Lighterage answered 12/4, 2019 at 11:14 Comment(1)
This solution does not work if the Swift version is 3.x and you have a greater Xcode version than 10.2Dorthadorthea
S
19

I followed the instructions on this page and the error didn't resolve. Finally, went into

$ vim MyProject.xcodeproj/project.pbxproj

and found two instances where

SWIFT_VERSION = 3.0;

was still being referenced. I changed those to 5.0 and the error was gone. Not sure why those two were still there.

Safekeeping answered 13/7, 2019 at 17:55 Comment(6)
I used Apple's guide for migration from Swift 3.0 to 5.0, however the assistant wasn't showing any suggestions. As soon as I modified these two lines in the answer above, it prompted me to migrate right away. Thanks for sharing this solution @Forrest!Resonator
This worked for me as well. Doing a class on it and the example project was in the wrong version.Lovato
Plus one, it works! I had only one warning in my code after making this change.Paddy
Spot on! Mine was under /* Release */ and /* Debug */Hartsock
This is awesome!Deidradeidre
Unearthing a project from 2016, did NOT want to install xCode from 8 years ago! Thank you so much!!!Nucleus
T
15
  1. Select project
  2. Select Build SettingTab
  3. Select Swift Compiler language Option

enter image description here

Taxicab answered 20/10, 2019 at 13:49 Comment(0)
A
11

enter image description hereselect pod like as per image and change swift language version this can save you one day

enter image description here

Absonant answered 29/4, 2019 at 11:1 Comment(0)
M
10

Search for Swift and double click, then change each offending version.

enter image description here

Meggie answered 4/4, 2020 at 1:10 Comment(1)
Nice tip! Or why not just type swift_version to get a neater list :)Doubleminded
I
7

It seems that the app might have an old Swift version code like Swift 3.0 in your case. In the release of Xcode version 10.2 has launched Swift 5.0 version. Xcode 10.2 does not support compiler for Swift 3.0 version. You can change compiler from Build Settings -> Swift Compiler - Language -> Swift Language Version -> Change it to Swift 5. If your code is compatible with that language version then it will run the code without error.

However, the Swift 3 compatibility mode will not be supported in the Swift 5 compiler. Swift 4.2 is the last release of Swift to support Swift 3 mode. There are important changes to both the surface of the language and the interior of its implementation in the releases following Swift 3 that will be the basis of future (and lasting) source and binary stability.

Refer below link for more details. https://developer.apple.com/documentation/xcode_release_notes/xcode_10_2_release_notes/swift_5_release_notes_for_xcode_10_2

If you really wish to run the app which has older Swift version code than you must have to use an older version of Xcode. You can use Xcode version 10.1, it's compiler having support for Swift 3.0 version.

Another alternative way is to migrate your old Swift code to the new version of the Swift version. You can migrate you Swift 3.0 to Swift 4.0 in Xcode 10.1 version.

For migration guide refer to this https://swift.org/migration-guide-swift4/

Inspirit answered 4/4, 2019 at 14:55 Comment(0)
C
6
  1. Check this out:
    1. Click on Project name
    2. Click target
    3. Click on Build setting
    4. At the Swift Language Version: Choose Swift 4

enter image description here

enter image description here

Congest answered 1/10, 2019 at 23:43 Comment(0)
M
6

I opened up the file MyProject.xcodeproj (using VSCode editor)

and I found some lines where

SWIFT_VERSION = 3.0;

(at about line 400 where it says /* Begin XCBuildConfiguration section */)

Modify to SWIFT_VERSION = 5.0 or others. After that I was able build and run the project.

Menthol answered 20/3, 2020 at 10:7 Comment(0)
G
5

I came across this issue while developing a Cocoapod. I had an old .swift-version file in my repo that specified Swift 3.0.

Running pod lib lint --verbose led me to this helpful response:

Please remove the .swift-version file which is now deprecated and only use the swift_version attribute within your podspec.

I deleted the file and added spec.swift_version = '5.0' to my podspec file to fix the problem.

Ghee answered 14/5, 2019 at 18:10 Comment(0)
N
1

If you multiple pod files like I did and you're having trouble finding the pod with SWIFT_Version = 3.0 try the search bar

Nubia answered 10/3, 2020 at 5:35 Comment(0)
A
1

Its very simple. Just follow this 2 steps to resolve this issue.

In Step 1:

  • Resolve Build Failed issue.
  • Covert Swift 3.0 to Swift 4.0 enter image description here

In Step 2:

  • Resolve all other warnings
  • Then Covert Swift 4.0 to Swift 5.0

enter image description here

Accompanyist answered 4/8, 2021 at 23:42 Comment(0)
S
0

1) change pod's version on podfile (because library wrote old swift version )

2) "pod install" on terminal

Seeseebeck answered 22/9, 2019 at 18:32 Comment(0)
Z
0

I am new to iOS development. After I followed all of the above answers, I still got the same error. I was using Xcode 11 and I downloaded the "FoodTracker" sample from Apple Developer web site and I got the same error after trying to build it. I found that the project has several settings referring to Swift language version after VIM the project file content. So, I resolved this by first setting the "Project > FoodTracker", and also "TARGETS > FoodTracker" and "TARGETS > FoodTrackerTests" the Swift Language Version to 5.0. Hope it helps.

Setting Swift Language Version on Project and ALL Targets

Zea answered 21/1, 2020 at 2:55 Comment(0)
N
0
  1. open MyProject.xcodeproj/project.pbxproj in the editor (e.q. Sublime)

example Calculator.xcodeproj

  1. Rename all SWIFT_VERSION = 3.0; Rename all SWIFT_VERSION = 5.0;

enter image description here

Necolenecro answered 9/6, 2020 at 19:29 Comment(0)
E
0

PLease make sure that the your pod's version is compatiable with your swift's version. I have faced this issue when I had installed wrong version of pod (swift 2.3), But I was using swift 4

Elgin answered 6/4, 2021 at 11:46 Comment(0)
P
0

We can automate this using a post-install hook installing Cocoapods.

Add this to your Podfile:

    ..
    pod 'Alamofire' # Just an example for the last pod in list.
    post_install do |installer|
        installer.pods_project.targets.each do |target|
            target.build_configurations.each do |config|
                config.build_settings['SWIFT_VERSION'] = '5.0'
            end
        end
    end
end

This hook is helpful if you have lots of Pods as dependencies because we don't need to manually change the Build Settings for each pod. However, be sure to manually change some pods to 4.0 or 4.2 as outlined in the earlier answers if they don't support Swift 5 yet.

Punctuate answered 17/9, 2021 at 16:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.