Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter - SWIFT_VERSION must be set to a supported value

Tags:

ios

flutter

Trying out the library simple_permission, fixed the pod error and this came up, no idea how to proceed. There's no setting for the swift version in Build Settings, I tried adding it, but it didn't work.

Launching lib/main.dart on iPhone X in debug mode...
Skipping compilation. Fingerprint match.
Running Xcode clean...
Starting Xcode build...
Xcode build done.
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **

Xcode's output:
↳
=== BUILD TARGET simple_permissions OF PROJECT Pods WITH CONFIGURATION             Debug ===
    The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift. This setting can be set in the build settings editor.
Could not build the application for the simulator.
Error launching application on iPhone X.
like image 882
Rosenberg Avatar asked May 22 '18 01:05

Rosenberg


3 Answers

Check this answer.

When the iOS part of a plugin is coded using Swift, you must make that change to your ios/Podfile. You must add use_frameworks! and config.build_settings['SWIFT_VERSION'] = '4.1'.

target 'Runner' do
  use_frameworks!  # required by simple_permission
  ...
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '4.1'  # required by simple_permission
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end
end

You might check which SWIFT_VERSION will be required, in that issue, the problem is solved using 3.2. In the answer I posted, 4.1 was recommended but 4.0 also worked.

like image 130
Feu Avatar answered Nov 08 '22 13:11

Feu


In the odd case that the other answers do not work for you, use pre_install like:

pre_install do |installer|
  installer.analysis_result.specifications.each do |s|
    s.swift_version = '4.2' unless s.swift_version
  end
end

A combination of the answers above and this answer will definitely sort this out.

like image 4
draysams Avatar answered Nov 08 '22 14:11

draysams


Fixed by creating an empty swift file in the project.

like image 5
Naloiko Eugene Avatar answered Nov 08 '22 15:11

Naloiko Eugene