fix(ios): vendor RaTeX as a prebuilt static XCFramework (drop spm_dependency) - #652
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR switches the iOS LaTeX math integration (RaTeX) from React Native’s spm_dependency-based build-time SPM wiring to a vendored, prebuilt static RaTeX.xcframework plus the minimal required RaTeX Swift sources and KaTeX fonts, restored on demand and bundled into the published npm tarball.
Changes:
- Add a vendor restore script + pin file to fetch/verify/extract the prebuilt RaTeX XCFramework and required assets into
ios/vendor/. - Update the iOS CocoaPods integration to link the vendored XCFramework/resources under default static linkage (no
use_frameworks!, nospm_dependency). - Update docs and example apps to reflect the new static-linking workflow and remove the old SPM pin.
Reviewed changes
Copilot reviewed 10 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
vendor/vendor-ratex.mjs |
New restore script to fetch/verify and populate the gitignored RaTeX vendor tree. |
vendor/ratex-version.json |
New pin manifest for the RaTeX tag plus sha256s and required source/font paths. |
scripts/prepare-npm-publish.sh |
Runs the RaTeX vendor restore during prepack so the npm tarball includes iOS math assets. |
packages/react-native-enriched-markdown/ReactNativeEnrichedMarkdown.podspec |
Replaces spm_dependency integration with vendored_frameworks + resource bundle and updated exclusions. |
packages/react-native-enriched-markdown/package.json |
Adds vendor-ratex script and runs it as part of prepare. |
packages/react-native-enriched-markdown/ios/math/ENRMRaTeXBridge.swift |
Removes import RaTeX and documents that vendored sources now compile into the pod’s module. |
packages/core/EnrichedMarkdownCore.podspec |
Defines a module (DEFINES_MODULE=YES) to support Swift dependency under static linkage in the monorepo. |
docs/LATEX_MATH.md |
Updates setup/upgrade guidance to reflect the new static XCFramework approach. |
apps/react-native-macos-example/macos/Podfile |
Updates comment explaining macOS math remains disabled despite the old use_frameworks! blocker being removed. |
apps/react-native-example/ios/Podfile.lock |
Updates lockfile after Pod configuration changes. |
apps/react-native-example/ios/Podfile |
Removes dynamic frameworks env wiring; notes static vendored RaTeX approach. |
apps/react-native-example/ios/EnrichedMarkdownExample.xcworkspace/xcshareddata/swiftpm/Package.resolved |
Removes the RaTeX SPM resolution file now that SPM is no longer used. |
apps/react-native-example/ios/EnrichedMarkdownExample.xcodeproj/project.pbxproj |
Updates example project linkage from Pods framework to static Pods archive. |
.gitignore |
Ignores the generated packages/react-native-enriched-markdown/ios/vendor/ directory. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
eszlamczyk
force-pushed
the
fix/ios-ratex-vendored-xcframework
branch
from
August 11, 2026 13:46
efacbe0 to
13c38dc
Compare
hryhoriiK97
approved these changes
Aug 11, 2026
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.
What / Why?
iOS LaTeX math (RaTeX) was integrated via React Native's
spm_dependency, i.e. RaTeX was consumed as a Swift Package inside a CocoaPods target. That interop is the root cause of a cluster of iOS build failures - several of which persist despite earlier workarounds:rmworkaround only removesRaTeX.xcframework-ios.signature, not theRaTeX.xcframework-ios-simulator.signaturevariant that simulator archives produce - still reported on 0.7.4 this week.iOS RaTeX mathdependency breaks x86_64 simulator builds in react-native-enriched-markdown >= 0.7 #527 - SPM compiles RaTeX's Swift wrapper only for the arch the build requests, so universal simulator builds lack anx86_64slice.redefinition of module 'RaTeXFFI',RaTeX_RaTeXcode-signing failures, a build-time GitHub clone + Rust build, and a forceduse_frameworks! :linkage => :dynamic(which flips linkage for the whole dependency graph).This PR replaces
spm_dependencywith a vendored, prebuilt, already-signed static RaTeX XCFramework, removing the mechanism behind all of the above. It mirrors the existing tree-sitter vendoring pattern (pinned + sha256-verified, gitignored, restored onprepare/prepack).Root cause and fix
ios-arm64_x86_64-simulatorsliceredefinition of module 'RaTeXFFI'spm_dependencygenerates a duplicate modulemapChanges
vendor/ratex-version.json+vendor/vendor-ratex.mjs- pin RaTeXv0.1.14and restore (sha256-verified) the XCFramework + RaTeX core Swift + KaTeX fonts into gitignoredpackages/react-native-enriched-markdown/ios/vendor/. Wired into the packageprepareandprepackhooks.ReactNativeEnrichedMarkdown.podspec- addsvendored_frameworks+ theRaTeXCoreFontsresource bundle; deletes theEXCLUDED_ARCHS, theFix RaTeXFFI Module Redefinition(sed), and theDedupe RaTeX XCFramework Signature(rm) workarounds, and thespm_dependencycall.ENRMRaTeXBridge.swift- dropsimport RaTeX(RaTeX core is now same-module).EnrichedMarkdownCore.podspec-DEFINES_MODULE = YESso the Swift-containing pod links under default static linkage with no consumer Podfile changes.Podfile- removes the forced dynamic frameworks. Docs updated (docs/LATEX_MATH.md).Testing
Reproduced the failure on
main, then verified the fix (Apple Silicon, Xcode 26.6):rc=70onRaTeX.xcframework-ios-simulator.signature. After - archive assembles, no collision.iOS RaTeX mathdependency breaks x86_64 simulator builds in react-native-enriched-markdown >= 0.7 #527 (verified without an Intel Mac):liposhowsx86_64 arm64in the vendored simulator slice, and the example app links forx86_64(-target x86_64-apple-ios-simulator … -lratex_ffi).pod installsucceeds with nouse_frameworks!and nouse_modular_headers!; the app linkslibReactNativeEnrichedMarkdown.a(static) instead ofPods_EnrichedMarkdownExample.framework(dynamic).run-iospath, fresh DerivedData) succeeds.ENRICHED_MARKDOWN_ENABLE_MATH=0): RaTeX fully excluded, installs clean.RaTeXCoreFontsbundle under static linkage).Note
Upgrading from a version that used
use_frameworks! :linkage => :dynamicformath requires a one-time clean build (Product → Clean Build Folder / delete
DerivedData). Switching the pod from a dynamic framework to a static library
leaves stale module artifacts; a stale build otherwise fails with
ReactNativeEnrichedMarkdown.framework/Modules/module.modulemap not found.Fresh installs are unaffected. This is documented in
docs/LATEX_MATH.md.PR Checklist