with-disable-enriched-markdown-math.js 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. const { withDangerousMod } = require('expo/config-plugins');
  2. const fs = require('fs');
  3. const path = require('path');
  4. /**
  5. * Disable RaTeX SPM from react-native-enriched-markdown on iOS.
  6. *
  7. * Xcode 26 cannot open Pods.xcodeproj when CocoaPods injects
  8. * XCRemoteSwiftPackageReference via spm_dependency — builds fail with
  9. * `_setSavedArchiveVersion:` / "Pods project is damaged" and cascading
  10. * "no such module 'Expo'" errors. Math rendering falls back without RaTeX.
  11. *
  12. * @see https://github.com/software-mansion/react-native-enriched-markdown/blob/main/docs/LATEX_MATH.md
  13. */
  14. const ENV_LINE =
  15. "ENV['ENRICHED_MARKDOWN_ENABLE_MATH'] = '0' # Xcode 26: RaTeX SPM corrupts Pods.xcodeproj";
  16. function withDisableEnrichedMarkdownMath(config) {
  17. return withDangerousMod(config, [
  18. 'ios',
  19. async (config) => {
  20. const podfilePath = path.join(config.modRequest.platformProjectRoot, 'Podfile');
  21. let contents = await fs.promises.readFile(podfilePath, 'utf8');
  22. if (!contents.includes('ENRICHED_MARKDOWN_ENABLE_MATH')) {
  23. contents = `${ENV_LINE}\n${contents}`;
  24. await fs.promises.writeFile(podfilePath, contents);
  25. }
  26. return config;
  27. },
  28. ]);
  29. }
  30. module.exports = withDisableEnrichedMarkdownMath;