Skip to content

fix: complete SPM migration — runtime crash fixes, use arrrrny/google-mlkit-swiftpm 9.0.0-1#881

Closed
arrrrny wants to merge 25 commits into
flutter-ml:feature/spmfrom
arrrrny:spm-fixed
Closed

fix: complete SPM migration — runtime crash fixes, use arrrrny/google-mlkit-swiftpm 9.0.0-1#881
arrrrny wants to merge 25 commits into
flutter-ml:feature/spmfrom
arrrrny:spm-fixed

Conversation

@arrrrny

@arrrrny arrrrny commented Jul 5, 2026

Copy link
Copy Markdown

Description

This PR builds on the SPM migration in feature/spm and adds critical runtime fixes that were discovered after the original PR (#874) was merged and reverted.

What's Fixed

Runtime Crashes Resolved

  1. MLKTextRecognizerInternalErrorCreationFailure: Invalid model path — ML Kit Text Recognition model bundles weren't being found in SPM static-link builds. Fixed by switching to arrrrny/google-mlkit-swiftpm release 9.0.0-1 which properly packages resource bundles.

  2. [MLKITx_GMVUtility grayPixelData:...] unrecognized selector sent to class — ObjC category methods not loaded. Fixed by adding -ObjC and -all_load linker flags to all plugin targets.

  3. dyld flat-namespace crash on TestFlight/Release builds — Resolved by ensuring proper Mach-O linking for ML Kit static frameworks.

Changes Included

  • All 11 Package.swift files updated to reference arrrrny/google-mlkit-swiftpm (with revision pinning to the fixed commit)
  • Removed all 22 CocoaPods podspecs — pure SPM
  • Added -ObjC + -all_load linker flags in xcconfig files for all plugin targets
  • Per-language OCR resource bundles (Latin, Chinese, Japanese, Korean, Devanagari) properly embedded
  • Build phase scripts for MLKitTextRecognitionCommon dylib replacement with model data
  • Focused text_recognition_example app that validates text recognition end-to-end
  • Cleanup: removed CocoaPods artifacts (Podfile, Podfile.lock, Pods/), stale build caches, package.resolved files for library targets
  • Gitignore updated for SPM artifacts

Testing

  • Text recognition tested and working on physical iOS device
  • Barcode scanning verified working
  • Face detection expected to work (needs device testing)
  • The main example app runs with camera-based text recognition

Related

arrrrny and others added 22 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
…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.
@fbernaly

fbernaly commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

review if these files are needed?
image

Those are not os targets in the project

@fbernaly

fbernaly commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

why do we need these?
image

@fbernaly

fbernaly commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

resolve these:
image

@arrrrny

arrrrny commented Jul 7, 2026

Copy link
Copy Markdown
Author

Addressing your comments:

1. linux/, macos/, web/, RunnerTests files — You're right, these are NOT needed. They were accidentally included when the example app's iOS configuration was regenerated. They should be removed from the PR. I'll push a cleanup.

2. OCR resource bundle files — These ARE needed. They contain the TFLite model files (.bincfg, .tflite, .class_lst, .conv_model, .lstm_model) that ML Kit's text recognition engine requires at runtime. ML Kit uses [NSBundle mainBundle] to find these .bundle directories — they must be in the app's main bundle via the Xcode project's "Copy Bundle Resources" phase. Without them, text recognition crashes with MLKTextRecognizerInternalErrorCreationFailure: Invalid model path.

3. Merge conflicts — I'll resolve them by rebasing spm-fixed onto the latest feature/spm and removing the unnecessary platform files. Will push an updated branch shortly.

…te files

These files were accidentally generated by flutter create when the
example app's iOS configuration was regenerated. They are not part
of the iOS SPM migration and add noise to the PR.
@arrrrny

arrrrny commented Jul 7, 2026

Copy link
Copy Markdown
Author

✅ Cleaned up — pushed commit ad99da4 to spm-fixed which removes linux/, macos/, web/, RunnerTests, and SceneDelegate files. These were accidentally generated during flutter create and are not needed for the iOS SPM migration.

The remaining new files are:

  • OCR resource bundles (.bundle directories with TFLite model files) — required for text recognition
  • iOS-specific changes (Package.swift, pbxproj, xcconfig, Package.resolved) — the actual SPM migration

The PR now only contains iOS-relevant changes.

@arrrrny arrrrny 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.

2 participants