SWIFT_VERSION '5.0' is unsupported, supported versions are: 3.0, 4.0, 4.2. (in target 'SwiftyJSON')

I found it. I am not familiar with XCode so it was not very straightforward for me. I clicked "Pods" on the project tree on the left, then clicked the dropdown to select SwiftyJSON from the list at the top left corner. Then changed the Swift version which was set to 5.0. See the image.

enter image description here

Cheers


For anyone who's build continues to fail despite following the previous solution:

  1. Find SWIFT_VERSION literal in whole project files using IDE or editor – I turned on sublimetext, open project root directory, [Find] - [Find in Files.] – Search SWIFT_VERSION

  2. In my case some constants in projectfile was SWIFT_VERSION = 5.0 in proj.pbxproj file despite I changed swift_version on Xcode

    <code>SWIFT_VERSION = 5.0</code> in proj.pbxproj

  3. Change value you want and save file

  4. Restart Xcode

  5. Try Build


"Normally this error comes from the pods(dependencies like Alamofire, SwiftyJSON ets) you have installed."

To solve the problem, follow these steps:

(See the image below for illustration)

  1. Select 'Pods' on the project tree
  2. Select a dependency from TARGETS: select one dependecy at a time then do step 3 and step 4 for each targets
  3. Make sure 'Build Settings' tab selected
  4. Scroll up and down and find out 'Swift Language Version'. Select a version, for example 'Swift 4.2'

If you have multiple dependency installed, you have to set 'Swift Language Version' for each of them. (look at the image, this project have 2 dependencies: Alamofire and SwiftyJSON, so I have done 2 times step 2 to step 4)

Restart Xcode then build

hope the error gone.

Shown steps to follow, marked sequentially