migrate iOS/macOS to correct SPM structure per Flutter 3.44 docs - #213
Open
sunitaprajapati89 wants to merge 2 commits into
Open
migrate iOS/macOS to correct SPM structure per Flutter 3.44 docs#213sunitaprajapati89 wants to merge 2 commits into
sunitaprajapati89 wants to merge 2 commits into
Conversation
added 2 commits
August 12, 2026 14:57
Add linkedFramework linker settings, use hyphenated library product name, and set static library type — matching the pattern required for Flutter's tooling to detect SPM support and avoid falling back to CocoaPods.
Rewrites the Swift Package Manager integration for iOS and macOS to follow Flutter's official plugin migration guide for Flutter 3.44+.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rewrites the Swift Package Manager integration for iOS and macOS to
follow Flutter's official plugin migration guide for Flutter 3.44+.
What changed
Directory structure
Swift sources moved from the flat
Classes/layout to the nestedSwift package structure required by Flutter 3.44's tooling:
Before:
ios/
Package.swift
Classes/*.swift
After:
ios/
segment_analytics/
Package.swift
Sources/
segment_analytics/
*.swift
Package.swift
ios/Package.swifttoios/segment_analytics/Package.swift(Flutter 3.44 looks for the manifest at
ios/{plugin_name}/Package.swift)FlutterFrameworkas a package and target dependency(required so SPM can resolve
import Flutterin Swift sources)segment_analyticstosegment-analytics(SPM convention: underscores in plugin name become hyphens in product name)
(FlutterFramework itself requires iOS 13.0 minimum)
macos/segment_analytics/Package.swiftCocoaPods (podspec)
Updated
s.source_filesin both podspecs to point to the newsource location:
Before:
Classes/**/*After:
segment_analytics/Sources/segment_analytics/**/*.swiftCocoaPods continues to work unchanged for Flutter < 3.44 users.
Pigeon
Updated
build_pigeon_plugins.shoutput path to match the newsource directory structure.
.gitignore
Added
.build/and.swiftpm/toios/andmacos/gitignoresto prevent SPM-generated build artifacts from being committed.
How it works
Flutter 3.44+ (SPM):
Flutter 3.44 enables Swift Package Manager by default. Its tooling
scans each plugin for a Package.swift at
ios/{plugin_name}/Package.swift.It generates a
FlutterGeneratedPluginSwiftPackagethat referenceseach plugin as a local SPM package and provides the
FlutterFrameworkdependency at
../FlutterFrameworkrelative to the plugin's ios/directory. With this structure,
segment_analyticsis added toFlutterGeneratedPluginSwiftPackage, removed fromPodfile.lock,and the SPM warning disappears.
Flutter < 3.44 (CocoaPods):
Older Flutter versions use CocoaPods for native dependency management.
CocoaPods reads the
.podspecfile and compiles the Swift sourcesfrom the path defined in
s.source_files. Since we updated that pathto point to the new source location, CocoaPods continues to find and
compile the plugin correctly. No SPM involvement on these versions.
Validation
Tested across two Flutter versions using fvm:
Flutter 3.44.9 — SPM:
flutter build ios --debug --simulatorproduced no SPM warningsegment_analyticsappeared inFlutterGeneratedPluginSwiftPackagesegment_analyticswas absent fromPodfile.lock(integrated via SPM)Flutter 3.29.2 — CocoaPods (
flutter config --no-enable-swift-package-manager):flutter build ios --debug --simulatorproduced no SPM warningsegment_analytics (0.0.1)present inPodfile.lockconfirmingCocoaPods integration via the updated podspec source path