Search code examples
iosnativescript

How can I choose which Swift Compiler version I want to use in Nativescript?


I'm having an issue as the library nativescript-toast is using a version of iOS Toaster in Swift 3 and not in v4. And this is making my build failed when I run tns run ios.

After reading some posts I found the solution which is to open xcode, go to Build Settings and for Toaster target choose Swift 3 in Swift Language Version, In this way I can build my app using xCode... but this is a problem also, as It's not reflecting the changes I'm doing in real time in VS Code, and the changes that I'm doing in xCode is only impacting iOS and not Android as I'm in platform/ios folder.


Solution

  • Give this a try,

    post_install do |installer|
      installer.pods_project.targets.each do |target|
        if target.name == 'Toaster'
          target.build_configurations.each do |config|
            config.build_settings['SWIFT_VERSION'] = '3.0'
          end
        end
      end
    end
    

    Credits to nStudio, based on nativescript-camera-plus plugin