Feat: add Swift Package Manager (SPM) support for all iOS packages#872
Closed
arrrrny wants to merge 6 commits into
Closed
Feat: add Swift Package Manager (SPM) support for all iOS packages#872arrrrny wants to merge 6 commits into
arrrrny wants to merge 6 commits into
Conversation
Apple removed Rosetta 2 from the default iOS 26 simulator runtime, which breaks `flutter run` for any project depending on Google ML Kit on Apple Silicon Macs. The published GoogleMLKit/* CocoaPods only ship arm64-iphoneos and x86_64-iphonesimulator slices and pin EXCLUDED_ARCHS[sdk=iphonesimulator*] = arm64, so the simulator build no longer finds a matching destination and dies with "Unable to find a destination matching the provided destination specifier". Until Google publishes proper arm64-iphonesimulator slices (https://issuetracker.google.com/issues/178965151), this change ships an opt-in Podfile helper under google_mlkit_commons that: 1. Re-labels the existing arm64 device slice of every ML Kit framework binary as iOS Simulator. Only the 4-byte LC_BUILD_VERSION.platform field is changed (2 -> 7), the same approach the well-known arm64-to-sim tool uses on closed-source SDKs. Idempotent. 2. Strips EXCLUDED_ARCHS[sdk=iphonesimulator*] = arm64 from the xcconfigs CocoaPods generates from the pod's user_target_xcconfig, so the user's app target is allowed to build for arm64-iphonesimulator. The example/ios Podfile is wired to call the helper from post_install, which lets the example app build, install and run on an Apple Silicon iOS 26.3 simulator. End-to-end validated: Text Recognition on the Text-From-Widget view returned the exact widget text. Device builds and release builds are not affected. Closes flutter-ml#825
The Ruby and Python entry points already have a brief header pointing at the README. Per-function docstrings were restating what the function name already said, and the Podfile inline comments duplicated the helper's self-documenting name.
- Add Ruby helper script for Podfile integration - Add Python script to re-label arm64 device slices as iOS Simulator - Update example Podfile to use the opt-in helper - Document the solution in google_mlkit_commons/README.md This enables Google ML Kit to build on Apple Silicon iOS 26+ simulators where Rosetta 2 is no longer the default. Fixes Google internal issue #178965151.
Add Package.swift files for: - google_mlkit_commons: MLKitVision, MLImage, Common dependencies - google_mlkit_pose_detection: MLKitPoseDetection, MLKitPoseDetectionCommon, MLKitVision, MLImage, Common dependencies This resolves the Swift Package Manager migration warning and prepares the plugins for future Flutter versions that will require SPM support. Uses 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
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.
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:Packages with MLKit dependencies:
google_mlkit_barcode_scanning: MLKitBarcodeScanninggoogle_mlkit_digital_ink_recognition: MLKitDigitalInkRecognitiongoogle_mlkit_document_scanner: MLKitDocumentScannergoogle_mlkit_entity_extraction: MLKitEntityExtractiongoogle_mlkit_face_detection: MLKitFaceDetectiongoogle_mlkit_face_mesh_detection: MLKitFaceMeshgoogle_mlkit_image_labeling: MLKitImageLabeling, MLKitImageLabelingCommongoogle_mlkit_language_id: MLKitLanguageIDgoogle_mlkit_object_detection: MLKitObjectDetectiongoogle_mlkit_selfie_segmentation: MLKitSegmentationSelfiegoogle_mlkit_smart_reply: MLKitSmartReplygoogle_mlkit_text_recognition: MLKitTextRecognitiongoogle_mlkit_translation: MLKitTranslategoogle_mlkit_subject_segmentation: MLKitSegmentationSubjectgoogle_mlkit_pose_detection: MLKitPoseDetection, MLKitPoseDetectionAccurategoogle_mlkit_commons: MLKitVision, MLImage, Common (base package)GenAI packages (iOS stubs only) - no MLKit dependencies:
google_mlkit_genai_image_descriptiongoogle_mlkit_genai_promptgoogle_mlkit_genai_proofreadinggoogle_mlkit_genai_rewritinggoogle_mlkit_genai_speech_recognitiongoogle_mlkit_genai_summarizationUsage
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