Build error using Firebase and Geolocator (or any Swift plugin) in iOS (Flutter)

I’m trying to create a flutter app which use Firebase and the Geolocator plugin.

  • The Firebase plugins I’ll use to authenticate, use the RTDB and FCM.
  • The Geolocator is apparently a very reliable plugin for location awareness.

In Android, that’s all fine - everything works great!

In iOS however, I cannot build the app, the error:

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.

As I learned, using the Firebase plugins requires you NOT to use_frameworks! in the Podfile. And apparently, as Geolocator uses Swift code in the iOS part, it requires you TO use_frameworks! in the Podfile.

I know I could use another GPS plugin, such as Location, however as it applies for any Swift code plugin, my question is:

With Flutter, is it possible to use Firebase together with any Swift plugin?

1 Like

it looks like specifying the Swift version in your Podfile might solve the above mentioned error. You can do so by adding the following line:

config.build_settings['SWIFT_VERSION'] = '4.1' you can also check with 4.0. Sometimes it works in some cases.

It should be part of the post_install block, like this:

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

Also specify use_frameworks in runner.

target 'Runner' do
  use_frameworks! # you need to add this as well. 
  ...
end