Moblize IT
Moblize IT

Reputation: 1328

ionic 4 ios fails to build due to swift version 3

After upgrading to xcode 10.2 my ionic for ios project stopped building using below command

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

i tried to upgrade [email protected] and remove and readd ios platform but no luck.

The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift. Supported values are: 4.0, 4.2, 5.0. This setting can be set in the build settings editor.
Code Signing Error: Code signing is required for product type 'Application' in SDK 'iOS 12.2'

** ARCHIVE FAILED **


The following build commands failed:
    Check dependencies
(1 failure)
xcodebuild: Command failed with exit code 65
[ERROR] An error occurred while running subprocess cordova.

        cordova build ios --buildFlag=-UseModernBuildSystem=0 exited with exit code 65.

        Re-running this command with the --verbose flag may provide more information.

Upvotes: 15

Views: 9988

Answers (3)

kunal shaktawat
kunal shaktawat

Reputation: 1520

Just add this plugin

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

Or if you already added then just remove this plugin and add again.

Upvotes: 2

Kshitij
Kshitij

Reputation: 380

You should go with below steps-

  1. Open your project in Xcode by click on workspace file in platforms >> ios >> PROJECT_NAME.xcworkspace

  2. Go for Build Settings

  3. Now search "Swift Language Version"

  4. Change the version to 4 or 5(whichever required)

  5. run below command

    Ionic cordova build ios --buildFlag="-UseModernBuildSystem=0"

Upvotes: 2

cdubs
cdubs

Reputation: 21

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.

Upvotes: 2

Related Questions