Swift Version NativeScript Swift Version NativeScript vue.js vue.js

Swift Version NativeScript


Just had these same errors and found out downgrading from cocoapods 1.6.0 to 1.5.3 fixed it for me.

    sudo gem uninstall cocoapods    sudo gem install cocoapods -v 1.5.3


The problem here seems to be Toaster (2.0.4), which appears to have been developed for Swift 3.

I did this in order to resolve the issue:

  1. go to the main folder for the nativescript project

  2. In your bash shell, do:

    % export SWIFT_VERSION=3

  3. Then do your usual:

    % tns build ios --bundle

  4. Then open the project in Xcode:

    % cd platforms/ios

    % Open *.workspace

You'll get a warning about a build error in the pods project and may need to set your development team, but it should work.


The problem is with Cocoapods 1.6.x which have different behavior when it comes up to SWIFT_VERSION. Previously it was possible to set the SWIFT_VERSION in post_install hook of the Podfile, but now the pod install command fails before even getting to post_install.The best solution is to use Cocoapod which already has SWIFT_VERSION set, i.e. in case you face the error, try to contact the Pod author.Meanwhile, as a workaround, you can add a pre_install script in your <path to App_Resources/iOS/Podfile file with the following content:

pre_install do |installer|    installer.analysis_result.specifications.each do |s|        if s.name == 'Socket.IO-Client-Swift' || s.name == 'Starscream' || s.name == 'StarscreamSocketIO' || s.name == 'Toaster'            s.swift_version = '4.2'        end    endend

For each of the Pods you can set different Swift version based on their requirements.