Skip to content

[SwiftPM] FlutterGeneratedPluginSwiftPackage uses Flutter's minimum iOS version, instead of looking at project settings #162072

@navaronbracke

Description

@navaronbracke

Steps to reproduce

  1. Create a new Flutter project with Flutter 3.27 or higher
  2. Ensure that the project uses SwiftPM
  3. Add the following dependencies to the project: (see the attached pubspec.lock for exact versions)
firebase_analytics: ^11.4.1
firebase_core: ^3.10.1
firebase_crashlytics: ^4.3.1
firebase_messaging: ^15.2.1
  1. Specify a higher minimum iOS version, per the Firebase requirement
  • IPHONEOS_DEPLOYMENT_TARGET = 13.0; in ios/Runnerxcodeproj/project.pbxproj
  • MinimumOSVersion to 13.0 in ios/Flutter/AppFrameworkInfo.plist
  • platform :ios, '13.0' in ios/Podfile
  • override the minimum ios deployment target for pods using the following in the Podfile
post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
    end
  end
end
  1. Try to build the iOS app in XCode
  2. The build fails with an error like the following: (see the screenshot)
The package product 'firebase-analytics' requires minimum platform version 13.0 for the iOS platform, but this target supports 12.0
The package product 'firebase-core' requires minimum platform version 13.0 for the iOS platform, but this target supports 12.0
The package product 'firebase-crashlytics' requires minimum platform version 13.0 for the iOS platform, but this target supports 12.0
The package product 'firebase-messaging' requires minimum platform version 13.0 for the iOS platform, but this target supports 12.0

Expected results

The used Firebase versions require iOS 13.0 or higher. Thus the project specifies this in the project settings.
The generated FlutterGeneratedPluginSwiftPackage/Package.swift file should use the project level minimum supported version, as defined in the project.

Perhaps the MinimumOSVersion in ios/Flutter/AppFrameworkInfo.plist is a good candidate for this.
And MacOS probably also needs to be considered.

Actual results

The build fails due to the minimum iOS version in the FlutterGeneratedPluginSwiftPackage/Package.swift being Flutter's minimum iOS version.

See the attached FlutterGeneratedPluginSwiftPackage/Package.swift for an example.
Note: The project where I reproduced this also used other dependencies in the FlutterGeneratedPluginSwiftPackage/Package.swift, but those do not seem to be related to the issue.

The culprit might be the hardcoded versions in

static final SwiftPackageSupportedPlatform iosSwiftPackageSupportedPlatform =
SwiftPackageSupportedPlatform(
platform: SwiftPackagePlatform.ios,
version: Version(12, 0, null),
);
static final SwiftPackageSupportedPlatform macosSwiftPackageSupportedPlatform =
SwiftPackageSupportedPlatform(
platform: SwiftPackagePlatform.macos,
version: Version(10, 14, null),
);

Code sample

pubspec_lock.txt

Package_swift.txt

Screenshots or Video

Screenshots / Video demonstration

Image

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.27.3, on macOS 14.6.1 23G93 darwin-x64, locale en-BE)
    • Flutter version 3.27.3 on channel stable at /Users/navaronbracke/Documents/flutter
    • Upstream repository git@github.com:navaronbracke/flutter.git
    • FLUTTER_GIT_URL = git@github.com:navaronbracke/flutter.git
    • Framework revision c519ee916e (2 days ago), 2025-01-21 10:32:23 -0800
    • Engine revision e672b006cb
    • Dart version 3.6.1
    • DevTools version 2.40.2

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/navaronbracke/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/navaronbracke/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16C5032a
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)

[✓] VS Code (version 1.96.4)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.102.0

[✓] Connected device (3 available)
    • iPhone van device (mobile) • 00008030-00155560213A802E • ios            • iOS 18.2.1 22C161
    • macOS (desktop)            • macos                     • darwin-x64     • macOS 14.6.1 23G93 darwin-x64
    • Chrome (web)               • chrome                    • web-javascript • Google Chrome 132.0.6834.110

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listplatform-iosiOS applications specificallyr: solvedIssue is closed as solvedt: xcode"xcodebuild" on iOS and general Xcode project managementteam-iosOwned by iOS platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-iosTriaged by iOS platform team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions