Skip to content

feat(spm): complete iOS SPM migration — remove all podspecs, use arrrrny/google-mlkit-swiftpm#880

Closed
arrrrny wants to merge 22 commits into
flutter-ml:developfrom
arrrrny:spm-fixed
Closed

feat(spm): complete iOS SPM migration — remove all podspecs, use arrrrny/google-mlkit-swiftpm#880
arrrrny wants to merge 22 commits into
flutter-ml:developfrom
arrrrny:spm-fixed

Conversation

@arrrrny

@arrrrny arrrrny commented Jul 4, 2026

Copy link
Copy Markdown

Summary

Complete the iOS SPM migration by removing all CocoaPods podspecs and transitioning every plugin to pure Swift Package Manager, backed by arrrrny/google-mlkit-swiftpm (release 9.0.0-1).

Changes

Core migration

  • Delete all 22 .podspec files — no more CocoaPods for any plugin
  • Update 11 Package.swift files — all ML Kit plugins now reference arrrrny/google-mlkit-swiftpm instead of d-date/google-mlkit-swiftpm
  • Update Package.resolved files in example apps

Text recognition fixes (d-date/google-mlkit-swiftpm#106)

  • Replace monolithic MLKitTextRecognitionResources.bundle with 5 per-language OCR bundles: Latin, Chinese, Japanese, Korean, Devanagari
  • These bundles are included in the consuming app's Xcode project via Copy Bundle Resources build phase
  • -ObjC linker flag added to prevent Objective-C category stripping (fixes unrecognized selector crashes in MLKitCommon)

Build infrastructure

  • .gitignore updated for SPM build artifacts (**/.build/, **/.swiftpm/, per-package Package.resolved)
  • Stale artifacts cleaned: MLKitTextRecognitionCommon.full.dylib.gz, .build directories, old Package.resolved files

New example app

  • packages/text_recognition_example/ — minimal focused example that generates a test image with Latin text and runs ML Kit OCR, verifying the full pipeline end-to-end

Root causes fixed

  1. Invalid model path — MLKitTextRecognitionCommon shipped as Mach-O object file; SPM stripped model data sections. Fixed by shipping as static .a archive (via alex-pan-invos's textfix5 → now self-hosted on arrrrny)
  2. unrecognized selector crash — Objective-C categories in MLKitCommon stripped by linker. Fixed by adding -ObjC / -all_load linker flags
  3. Resource bundles not foundLatinOCRResources.bundle must be in main app bundle (since bundleForClass: returns main bundle with static linking). Fixed by adding bundles to app target's Copy Bundle Resources

Testing

  • Verified on device (iPhone, iOS 18.7.1): text recognition initializes and processes images successfully
  • Main example app builds and runs with camera + text recognition + all ML Kit modules

arrrrny and others added 21 commits June 9, 2026 19:58
…rny/google-mlkit-swiftpm

- Delete all 22 CocoaPods podspecs across all packages
- Update all 11 Package.swift files to reference arrrrny/google-mlkit-swiftpm
- Add per-language OCR resource bundles (Latin, Chinese, Japanese, Korean, Devanagari)
- Set -ObjC linker flag in example apps for ObjC category support
- Create focused text_recognition_example app
- Update Package.resolved files for SPM consistency
- Clean up stale CocoaPods artifacts and build caches
- Fixes text recognition 'Invalid model path' crash (d-date#106)
- Fixes dyld flat-namespace crash on TestFlight/Release builds
@arrrrny

arrrrny commented Jul 4, 2026

Copy link
Copy Markdown
Author

@arrrrny

arrrrny commented Jul 4, 2026

Copy link
Copy Markdown
Author

I tested text recognition on my phone and it works, and barcode scanner already works. I did not test others but since these are extremely important, this can be a good jump start and for people who need barcode and or text recognition only, this is fully spm tested.
IMG_8942

…en 9.0.0-1 tag

The 9.0.0-1 tag on arrrrny/google-mlkit-swiftpm points to an old commit
with duplicate binary target entries. Use the fixed commit directly.
@pumano

pumano commented Jul 4, 2026

Copy link
Copy Markdown

Would love to get this landed. Because after upgrading from old mac to fresh I can't use that lib anymore.

Latest error when use develop branch:

Failed to build iOS app
Swift Compiler Error (Xcode): Type 'VisionImage' has no member 'visionImage'
/Users/userhere/.pub-cache/git/google_ml_kit_flutter-8cb0e47bec1fa58704c4043284738dd25576884a/packages/google_mlkit_text_recognition/ios/Classes/GoogleMlKitTextRecognitionPlugin.swift:86:34

@fbernaly

fbernaly commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

@fbernaly

fbernaly commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

is this replaced by #881?

@arrrrny

arrrrny commented Jul 7, 2026

Copy link
Copy Markdown
Author

Yes, this PR is replaced by #881 which targets feature/spm as you requested. Closing this in favor of #881.

@fbernaly fbernaly closed this Jul 7, 2026
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.

3 participants