fix: skip MLX BART fallback on iOS simulator#12
Open
yocontra wants to merge 6 commits into
Open
Conversation
Add optional resourceDir: URL? parameter that threads through EnglishG2P → Lexicon/EnglishFallbackNetwork → DataResourcesUtil. When provided, loads dictionaries and BART weights from the given directory instead of Bundle.module (which doesn't exist in CocoaPods). All parameters default to nil so existing SPM usage is unchanged.
Remove the SPM resource bundle declaration and all Bundle.module references. Resources are now loaded exclusively via the resourceDir parameter, which avoids CodeSign failures when used in CocoaPods projects. Also switch library type from dynamic to static.
- swift-tools-version 6.2 caused swift-collections to resolve to 1.4.x which requires experimental Lifetimes feature, breaking CocoaPods builds - Remove empty resources array (resources loaded via resourceDir param) - Switch library type from dynamic to static for CocoaPods compatibility
The EnglishFallbackNetwork uses MLX which requires Metal GPU access. On the iOS simulator there is no Metal GPU, causing MLX to crash with abort() when initializing its device. The BART fallback is only used for unknown words not in the lexicon (~5% of words). Skip fallback initialization on simulator via #if targetEnvironment(simulator). The lexicon-based phonemization still handles the vast majority of English words. Also removes unused MLXUtilsLibrary imports from EnglishG2P and Lexicon.
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
EnglishFallbackNetworkoptional inEnglishG2P— on the iOS simulator there is no Metal GPU, so MLX crashes withabort()when initializing its Metal device#if targetEnvironment(simulator)to skip fallback creation at compile time — no API changes, same init signatureMLXUtilsLibraryimports fromEnglishG2P.swiftandLexicon.swiftChanges
EnglishG2P.fallbacktype changed fromEnglishFallbackNetworktoEnglishFallbackNetwork?if let fallbacknilon simulator, created normally on deviceAlso fixes a bug with missing swift-collections dep.