Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.
like image 492
Moblize IT Avatar asked Mar 27 '19 16:03

Moblize IT


2 Answers

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.

like image 194
Christopher Whitney Avatar answered Sep 23 '22 04:09

Christopher Whitney


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"

like image 45
Kshitij Avatar answered Sep 24 '22 04:09

Kshitij