Skip to content

fix(ios): complete SPM support for Flutter 3.44+#223

Open
david-nunes-leadtech wants to merge 1 commit into
mattermoran:masterfrom
david-nunes-leadtech:added-spm-support
Open

fix(ios): complete SPM support for Flutter 3.44+#223
david-nunes-leadtech wants to merge 1 commit into
mattermoran:masterfrom
david-nunes-leadtech:added-spm-support

Conversation

@david-nunes-leadtech

Copy link
Copy Markdown

Summary

This PR completes the iOS Swift Package Manager (SPM) integration for map_launcher. SPM support was partially introduced in #205 (v4.1.0), but the plugin was still resolved via CocoaPods in SPM-enabled Flutter apps because Package.swift was missing the required FlutterFramework dependency introduced in Flutter 3.44.

This change brings the plugin in line with the official Flutter SPM migration guide for plugin authors while preserving CocoaPods compatibility for apps that have not migrated yet.

Motivation

Starting with Flutter 3.44, Swift Package Manager is the default iOS dependency manager. Plugins that do not fully support SPM:

  • May cause Flutter to fall back to CocoaPods unnecessarily
  • Can block apps from completing a CocoaPods-free migration
  • Receive lower pub.dev scores until SPM support is complete

After auditing the current setup, map_launcher had a valid Package.swift and SPM directory layout, but Flutter still installed the plugin through CocoaPods because FlutterFramework was not declared as a package dependency.

What changed

Plugin (ios/)

File Change
ios/map_launcher/Package.swift Added FlutterFramework package and target dependency (required since Flutter 3.44)
ios/map_launcher/Package.swift Enabled .process("PrivacyInfo.xcprivacy") for SPM resource bundling
ios/map_launcher.podspec Enabled resource_bundles for PrivacyInfo.xcprivacy (CocoaPods parity)
ios/.gitignore Added .build/ and .swiftpm/

Example app (example/)

File Change
example/pubspec.yaml Enabled flutter.config.enable-swift-package-manager: true
example/ios/RunnerTests/RunnerTests.swift Replaced obsolete getPlatformVersion test with isMapAvailable for Apple Maps
example/ios/Runner/AppDelegate.swift Migrated to FlutterImplicitEngineDelegate (UIScene lifecycle, Flutter 3.44)
example/ios/Runner/Info.plist Added UIApplicationSceneManifest for UIScene lifecycle
example/ios/Runner.xcodeproj/project.pbxproj Added local SPM references for map_launcher and FlutterFramework
example/ios/Flutter/AppFrameworkInfo.plist Removed deprecated MinimumOSVersion key (Flutter 3.44 template)
.fvmrc Bumped Flutter SDK to 3.44.4

Before / After

Before

  • Package.swift existed but lacked FlutterFramework
  • Flutter resolved map_launcher via CocoaPods even in SPM-enabled projects
  • FlutterGeneratedPluginSwiftPackage was generated with an empty dependencies array

After

  • Flutter detects map_launcher as a Swift Package
  • Plugin is included in FlutterGeneratedPluginSwiftPackage as map-launcher
  • Example app builds successfully with SPM-only integration (no CocoaPods required)
  • CocoaPods path remains available for legacy apps via map_launcher.podspec

Compatibility

  • SPM apps (Flutter ≥ 3.44): Plugin is resolved through FlutterGeneratedPluginSwiftPackage
  • CocoaPods apps (any supported Flutter version): Plugin continues to work via map_launcher.podspec pointing to the same ios/map_launcher/Sources/ tree
  • Minimum iOS version: Unchanged at 13.0
  • Breaking changes: None for Dart/public API consumers

Testing

Validated locally with Flutter 3.44.4:

  • flutter pub get
  • flutter build ios --config-only — plugin detected as Swift Package (no "does not support Swift Package Manager" warning)
  • flutter build ios --no-codesign --release — example app builds successfully (Runner.app, ~17 MB)
  • map_launcher appears in generated FlutterGeneratedPluginSwiftPackage/Package.swift
  • Example app runs without CocoaPods (Podfile removed after pod deintegrate)
  • CocoaPods podspec still validates structurally (pod lib lint passes with pre-existing metadata warnings unrelated to this change)

Suggested maintainer verification

cd example
flutter pub get
flutter build ios --config-only
flutter build ios --no-codesign --release

Notes for reviewers

  1. Dual package manager support is intentional. Per Flutter's guidance, plugins should support both SPM and CocoaPods during the transition period. This PR does not remove the podspec.
  2. FlutterFramework is not vendored in this repo. Flutter generates it ephemerally at build time under ios/Flutter/ephemeral/Packages/.packages/FlutterFramework. This is expected behavior in Flutter 3.44+.
  3. UIScene migration in the example app was applied automatically by the Flutter 3.44 tooling during validation and is required for current Flutter iOS templates.
  4. Privacy manifest is now bundled consistently in both SPM (.process) and CocoaPods (resource_bundles) paths.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant