feat: add Swift Package Manager (SPM) support for iOS#870
Conversation
This extends PR flutter-ml#870 to cover all ML Kit packages that need Swift Package Manager support for Flutter 3.44+ iOS builds. Packages with MLKit dependencies: - google_mlkit_barcode_scanning: MLKitBarcodeScanning - google_mlkit_digital_ink_recognition: MLKitDigitalInkRecognition - google_mlkit_document_scanner: MLKitDocumentScanner - google_mlkit_entity_extraction: MLKitEntityExtraction - google_mlkit_face_detection: MLKitFaceDetection - google_mlkit_face_mesh_detection: MLKitFaceMesh - google_mlkit_image_labeling: MLKitImageLabeling, MLKitImageLabelingCommon - google_mlkit_language_id: MLKitLanguageID - google_mlkit_object_detection: MLKitObjectDetection - google_mlkit_selfie_segmentation: MLKitSegmentationSelfie - google_mlkit_smart_reply: MLKitSmartReply - google_mlkit_text_recognition: MLKitTextRecognition - google_mlkit_translation: MLKitTranslate - google_mlkit_subject_segmentation: MLKitSegmentationSubject GenAI packages (iOS stubs only) - no MLKit dependencies: - google_mlkit_genai_image_description - google_mlkit_genai_prompt - google_mlkit_genai_proofreading - google_mlkit_genai_rewriting - google_mlkit_genai_speech_recognition - google_mlkit_genai_summarization All packages now support Swift Package Manager using d-date/google-mlkit-swiftpm as the MLKit binary distribution. Fixes issue flutter-ml#868
This extends PR flutter-ml#870 to cover all ML Kit packages that need Swift Package Manager support for Flutter 3.44+ iOS builds. Packages with MLKit dependencies: - google_mlkit_barcode_scanning: MLKitBarcodeScanning - google_mlkit_digital_ink_recognition: MLKitDigitalInkRecognition - google_mlkit_document_scanner: MLKitDocumentScanner - google_mlkit_entity_extraction: MLKitEntityExtraction - google_mlkit_face_detection: MLKitFaceDetection - google_mlkit_face_mesh_detection: MLKitFaceMesh - google_mlkit_image_labeling: MLKitImageLabeling, MLKitImageLabelingCommon - google_mlkit_language_id: MLKitLanguageID - google_mlkit_object_detection: MLKitObjectDetection - google_mlkit_selfie_segmentation: MLKitSegmentationSelfie - google_mlkit_smart_reply: MLKitSmartReply - google_mlkit_text_recognition: MLKitTextRecognition - google_mlkit_translation: MLKitTranslate - google_mlkit_subject_segmentation: MLKitSegmentationSubject GenAI packages (iOS stubs only) - no MLKit dependencies: - google_mlkit_genai_image_description - google_mlkit_genai_prompt - google_mlkit_genai_proofreading - google_mlkit_genai_rewriting - google_mlkit_genai_speech_recognition - google_mlkit_genai_summarization All packages now support Swift Package Manager using d-date/google-mlkit-swiftpm as the MLKit binary distribution. Fixes issue flutter-ml#868
5bde8cd to
9457d85
Compare
…lkit_pose_detection
Flutter expects Package.swift at ios/<package_name>/Package.swift, not ios/Package.swift. Changes: - Move all 22 Package.swift files to ios/<package_name>/ subdirectories - Update path from 'Classes' to '../Classes' for correct relative path resolution This fixes Swift Package Manager detection for all ML Kit plugins.
Swift Package Manager uses the URL-derived package name, not the @objc product name. Changed all package references from 'GoogleMLKitSwiftPM' to 'google-mlkit-swiftpm'. Also fixed GenAI packages (empty dependencies) to have valid SPM format.
There was a problem hiding this comment.
Pull request overview
This PR adds Swift Package Manager (SPM) manifests to the repository’s iOS Flutter plugins so Flutter 3.44+ can resolve them as Swift Packages (avoiding the “plugins do not support Swift Package Manager for ios” warning that will become an error). It also adjusts the example iOS project to move away from CocoaPods integration and updates the example lockfile.
Changes:
- Added
ios/<plugin_name>/Package.swiftmanifests for multiple ML Kit plugins, pointing tod-date/google-mlkit-swiftpmproducts. - Updated the example iOS Xcode project to remove CocoaPods build phases / linkage and removed the Pods xcconfig include from the Profile configuration.
- Regenerated
packages/example/pubspec.lock(dependency versions + SDK constraint metadata).
Reviewed changes
Copilot reviewed 24 out of 25 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/google_mlkit_translation/ios/google_mlkit_translation/Package.swift | Adds SPM manifest for the translation plugin and declares ML Kit Translate-related products. |
| packages/google_mlkit_text_recognition/ios/google_mlkit_text_recognition/Package.swift | Adds SPM manifest for text recognition plugin with ML Kit Text Recognition products. |
| packages/google_mlkit_subject_segmentation/ios/google_mlkit_subject_segmentation/Package.swift | Adds SPM manifest for subject segmentation plugin with segmentation products. |
| packages/google_mlkit_smart_reply/ios/google_mlkit_smart_reply/Package.swift | Adds SPM manifest for smart reply plugin with Natural Language-related products. |
| packages/google_mlkit_selfie_segmentation/ios/google_mlkit_selfie_segmentation/Package.swift | Adds SPM manifest for selfie segmentation plugin with segmentation products. |
| packages/google_mlkit_pose_detection/ios/google_mlkit_pose_detection/Package.swift | Adds SPM manifest for pose detection plugin with pose detection products. |
| packages/google_mlkit_object_detection/ios/google_mlkit_object_detection/Package.swift | Adds SPM manifest for object detection plugin with object detection products. |
| packages/google_mlkit_language_id/ios/google_mlkit_language_id/Package.swift | Adds SPM manifest for language ID plugin with Natural Language-related products. |
| packages/google_mlkit_image_labeling/ios/google_mlkit_image_labeling/Package.swift | Adds SPM manifest for image labeling plugin with image labeling products. |
| packages/google_mlkit_genai_summarization/ios/google_mlkit_genai_summarization/Package.swift | Adds SPM manifest for genai summarization iOS stub target (no ML Kit deps). |
| packages/google_mlkit_genai_speech_recognition/ios/google_mlkit_genai_speech_recognition/Package.swift | Adds SPM manifest for genai speech recognition iOS stub target (no ML Kit deps). |
| packages/google_mlkit_genai_rewriting/ios/google_mlkit_genai_rewriting/Package.swift | Adds SPM manifest for genai rewriting iOS stub target (no ML Kit deps). |
| packages/google_mlkit_genai_proofreading/ios/google_mlkit_genai_proofreading/Package.swift | Adds SPM manifest for genai proofreading iOS stub target (no ML Kit deps). |
| packages/google_mlkit_genai_prompt/ios/google_mlkit_genai_prompt/Package.swift | Adds SPM manifest for genai prompt iOS stub target (no ML Kit deps). |
| packages/google_mlkit_genai_image_description/ios/google_mlkit_genai_image_description/Package.swift | Adds SPM manifest for genai image description iOS stub target (no ML Kit deps). |
| packages/google_mlkit_face_mesh_detection/ios/google_mlkit_face_mesh_detection/Package.swift | Adds SPM manifest for face mesh detection plugin with face mesh products. |
| packages/google_mlkit_face_detection/ios/google_mlkit_face_detection/Package.swift | Adds SPM manifest for face detection plugin with face detection products. |
| packages/google_mlkit_entity_extraction/ios/google_mlkit_entity_extraction/Package.swift | Adds SPM manifest for entity extraction plugin with entity extraction products. |
| packages/google_mlkit_document_scanner/ios/google_mlkit_document_scanner/Package.swift | Adds SPM manifest for document scanner plugin with document scanner products. |
| packages/google_mlkit_digital_ink_recognition/ios/google_mlkit_digital_ink_recognition/Package.swift | Adds SPM manifest for digital ink recognition plugin with digital ink products. |
| packages/google_mlkit_commons/ios/google_mlkit_commons/Package.swift | Adds SPM manifest for shared iOS commons plugin with core vision/common products. |
| packages/google_mlkit_barcode_scanning/ios/google_mlkit_barcode_scanning/Package.swift | Adds SPM manifest for barcode scanning plugin with barcode scanning products. |
| packages/example/pubspec.lock | Updates locked dependency versions and SDK metadata for the example app. |
| packages/example/ios/Runner.xcodeproj/project.pbxproj | Removes CocoaPods build phases and the Pods static lib from the example iOS project. |
| packages/example/ios/Flutter/Profile.xcconfig | Drops Profile configuration include of the Pods xcconfig. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
* feat: add Swift Package Manager support for all ML Kit packages This extends PR #870 to cover all ML Kit packages that need Swift Package Manager support for Flutter 3.44+ iOS builds. Packages with MLKit dependencies: - google_mlkit_barcode_scanning: MLKitBarcodeScanning - google_mlkit_digital_ink_recognition: MLKitDigitalInkRecognition - google_mlkit_document_scanner: MLKitDocumentScanner - google_mlkit_entity_extraction: MLKitEntityExtraction - google_mlkit_face_detection: MLKitFaceDetection - google_mlkit_face_mesh_detection: MLKitFaceMesh - google_mlkit_image_labeling: MLKitImageLabeling, MLKitImageLabelingCommon - google_mlkit_language_id: MLKitLanguageID - google_mlkit_object_detection: MLKitObjectDetection - google_mlkit_selfie_segmentation: MLKitSegmentationSelfie - google_mlkit_smart_reply: MLKitSmartReply - google_mlkit_text_recognition: MLKitTextRecognition - google_mlkit_translation: MLKitTranslate - google_mlkit_subject_segmentation: MLKitSegmentationSubject GenAI packages (iOS stubs only) - no MLKit dependencies: - google_mlkit_genai_image_description - google_mlkit_genai_prompt - google_mlkit_genai_proofreading - google_mlkit_genai_rewriting - google_mlkit_genai_speech_recognition - google_mlkit_genai_summarization All packages now support Swift Package Manager using d-date/google-mlkit-swiftpm as the MLKit binary distribution. Fixes issue #868 * feat: add missing Package.swift for google_mlkit_commons and google_mlkit_pose_detection * fix: move Package.swift to correct Swift Package Manager path Flutter expects Package.swift at ios/<package_name>/Package.swift, not ios/Package.swift. Changes: - Move all 22 Package.swift files to ios/<package_name>/ subdirectories - Update path from 'Classes' to '../Classes' for correct relative path resolution This fixes Swift Package Manager detection for all ML Kit plugins. * fix: correct Swift Package Manager package reference name Swift Package Manager uses the URL-derived package name, not the @objc product name. Changed all package references from 'GoogleMLKitSwiftPM' to 'google-mlkit-swiftpm'. Also fixed GenAI packages (empty dependencies) to have valid SPM format.
|
@arrrrny: I forgot to ask if you test this with the example app and ran on an actual device? I ran the code and got multiple errors: I reverted the change and move it to the |
|
@arrrrny can you look into the last report when you're chanced. Thanks |
Summary
This PR adds Swift Package Manager (SPM) support for iOS, resolving issue #868.
Problem
All ML Kit plugins trigger a warning when building for iOS with Flutter 3.44+:
CocoaPods is now in maintenance mode and Swift Package Manager will be required for Flutter iOS builds.
Solution
Added
Package.swiftmanifests for 22 ML Kit packages with iOS implementations.Important: Package.swift must be placed at
ios/<package_name>/Package.swift, NOT atios/Package.swift.Important: The package reference must use the URL-derived name
google-mlkit-swiftpm, notGoogleMLKitSwiftPM.Verification
Usage
No additional configuration needed - Flutter 3.44+ automatically detects and uses
Package.swiftfiles when building for iOS.Uses the community-maintained d-date/google-mlkit-swiftpm package for ML Kit binary dependencies.
For more information, see: https://docs.flutter.dev/packages-and-plugins/swift-package-manager/for-plugin-authors