Repository navigation
fix(react-native-plugin): fix "module map file not found" on React Native 0.87 and 0.88 iOS - #5606
turnipdabeets wants to merge 1 commit into
Conversation
…tive 0.87 and 0.88 iOS React Native 0.87 and 0.88 build a static spm_dependency pod into the shared products dir and rewrite the app's -fmodule-map-file flags from <pod>/<pod>.modulemap to <pod>.modulemap. The plugin's module map is named after its module (posthog_react_native_plugin), not the pod, so the rewrite misses it and Expo 58 iOS builds fail. Redo the rewrite with the module name, as React Native 0.89 does (react/react-native#59182).
📝 No Changeset FoundThis PR doesn't include a changeset. A changeset is required to release a new version. How to add a changesetRun this command and follow the prompts: pnpm changesetRemember: Never use |
|
Coherence📄 0 spec file errors · ⛔ 0 broken rules · 🚪 2 unchecked inputs · 🐛 0 bugs that came back What is Coherence?Coherence compares the code with its spec files ( This check read 44 parts of the code and 7 rules. Note These findings do not make this check fail. None of these findings are in files that this pull request changes. You do not need to fix them in this pull request. 🚪 Unchecked inputs (2)
What this means and how to fix itInput from outside this code comes in at these places. The spec does not say what checks that input. 10 more places were already like this when Coherence was added. This list does not show them. To close one of these, find the place by its name in the
To get the line to add, run |
SDK performance: posthog-nodeBenchmarks completed. No changes flagged for review. Flags require at least a 5% change in the median and all six pairs agreeing on direction. This is a noise filter, not proof of a performance change or a CI gate. View all results
Values are medians of paired measurements. Not flagged does not mean unchanged. Unavailable means a measurement could not be provided, not zero. Estimated allocation measurements retain their instrumentation uncertainty. RSS measures the whole process, not just SDK allocations; observed peaks are sampled checkpoints. Paired ranges in the diagnostics describe variability, not confidence intervals. Each shard uses its own runner; compare Before PR against With PR within a row, not across shards. Compared 102 metric rows; 102 rows shown in all results. Omitted or shortened data remain in |
Problem
With plugin 3.0, iOS builds on Expo 58 (React Native 0.88.1) fail without any Podfile changes:
React Native 0.87 and 0.88 changed
scripts/cocoapods/spm.rb(react/react-native#57602). When a pod that usesspm_dependencyis a static library, RN builds it straight into the shared products dir. Thenrewrite_aggregate_modulemap_referencesrewrites the app's-fmodule-map-fileflags from${PODS_CONFIGURATION_BUILD_DIR}/<pod>/<pod>.modulemapto${PODS_CONFIGURATION_BUILD_DIR}/<pod>.modulemap. But CocoaPods names the module map after the module. Our pod isposthog-react-native-pluginand its module isposthog_react_native_plugin, so the rewrite never matches. The flags keep pointing at a file that is never created.React Native fixed this upstream in react/react-native#59182, which uses the module name. The fix ships in 0.89.0-rc.0 but hasn't been backported to 0.87 or 0.88.
@rnmapbox/mapshit the same bug and works around it the same way (ios/rnmapbox_spm.rb).Plugin 2.x on
mainisn't affected. By default it installs posthog-ios from CocoaPods. Itsposthog.useSpmpath requires dynamic frameworks, and React Native only flattens static-library pods. I checked this withpod installon Expo 58,useSpm=trueand dynamic frameworks: the pod is a framework and gets no plugin-fmodule-map-fileflag.Changes
posthog-react-native-plugin.podspec: whenSPMManager#rewrite_aggregate_modulemap_referencesexists (RN 0.87+), prepend a module that callssuperand then rewrites this pod's path usingproduct_module_name. It only touches our pod. On RN 0.89+, upstream has already rewritten the path, so the patch finds nothing to change. On RN 0.75–0.86 the method doesn't exist and nothing is patched.Podfile.lockentries, and would break any Podfile that references the pod by name. The prepend is smaller and goes away by itself once 0.89 is the floor.Testing
All builds are iOS Release on the simulator (Xcode 26.4.1, CocoaPods 1.17 on Ruby 3.3), with posthog-ios 4.0.0 from a local tag through a local URL override that isn't committed. Each app called
captureFatalExceptionthrough the plugin, and the resulting native$exceptionreached a local catcher at/i/v1/analytics/events.-fmodule-map-fileposthog-react-native-plugin/posthog_react_native_plugin.modulemap(missing)pod installoutput, matches the original report)posthog_react_native_plugin.modulemapuse_frameworks! :linkage => :staticRelease info Sub-libraries affected
Libraries affected
Checklist
If releasing new changes
pnpm changesetto generate a changeset file (not needed: fixes an unreleased 3.0 regression)🤖 Agent context
Autonomy: Human-driven (agent-assisted)
spm.rbto find out which versions are affected, found the upstream fix and the rnmapbox workaround, and ran the build matrix above.🤖 Generated with Claude Code