Unsupported Swift version on Ionic3 with xcode 10.2

After updating to Mojave and XCode 10.2 in order to run the app on ios 12.2, I get an unsupported Swift version error in XCode.

error: SWIFT_VERSION '3.0' is unsupported, supported versions are: 4.0, 4.2, 5.0.

How can I update the Swift version for my Ionic app?

Ionic Info:

cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.0.0 

local packages:

    @ionic/app-scripts : 3.2.3
    Cordova Platforms  : android 7.1.4 browser 5.0.4 ios 5.0.0
    Ionic Framework    : ionic-angular 3.9.4


    ios-deploy : 1.9.2 
    ios-sim    : 6.1.3 
    Node       : v8.11.1
    npm        : 5.6.0 
    OS         : macOS
    Xcode      : Xcode 10.2 Build version 10E125 

Environment Variables:

    ANDROID_HOME : not set


    backend : pro

Solved by updating (removing/adding) the cordova-plugin-add-swift-support, plugin :slightly_smiling_face:


I have the same error when building my app and installed the plugin with the command

cordova plugin add cordova-plugin-add-swift-support --save

but the error still remains. Did you do anything else besides installing the plugin?

I can’t say if this would help you, but I manually set the swift version in config.xml.

<platform name="ios">
   <preference name="UseSwiftLanguageVersion" value="4.2" />

Great! Works fine. Thank you very much.

I am hitting the same problem after having updated to the latest version of xcode.

I added / removed cordova-plugin-add-swift-support (it’s version 2.0.2 now) and added the preference line.

But I am still getting the error. Also tried removing the directories platforms and plugins and reinstalled all plugins. I am starting to get desperate. :sleepy:

My config.xml and package.json:

thank you bro, you saved my day :wink:

1 Like

Works like a charm. Thank you!

I ran into the same error. I first tried to switch the Swift Language version in the Xcode build setting and quickly realized that some plugins written in Swift broke. Thankfully the plugin which broke for me was QR Scanner which is well maintained and has been updated for Swift 5.

So what I did to fix it was first run the following node commands to find and update the outdated node packages.

npm outdated
npm update
Then I identified the outdated/broken cordova plugins, removed them, then reinstalled the latest versions. Using

cordova plugin list

to make sure everything was updating correctly, cross referencing with the version numbers with the plugins repo. Then finally I added this to the config.xml

<preference name="UseSwiftLanguageVersion" value="5" />

and everything built successfully when running,

ionic cordova build ios – --buildFlag="-UseModernBuildSystem=0"

Unfortunately, if you’re using a cordova plugin that is written in Swift and is not well maintained you’re out of luck. You can try to update the plugin yourself if you’re brave.

Hopefully this was helpful and doesn’t require you to role back your Xcode, losing the ability to build for the latest version of iOs.