react-native-enriched-markdown 0.7.3 → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,6 +29,17 @@ Pod::Spec.new do |s|
29
29
  # When math is enabled, consumers must use `use_frameworks! :linkage => :dynamic` (required for SPM interop).
30
30
  enable_math = ENV['ENRICHED_MARKDOWN_ENABLE_MATH'] != '0'
31
31
 
32
+ # RaTeX is wired in through React Native's `spm_dependency` helper (SPM interop).
33
+ # On React Native versions that don't provide it, disable math entirely so the
34
+ # RaTeX-importing sources under ios/math are excluded from the build. Otherwise
35
+ # the failure would just move from `pod install` to a build-time
36
+ # "missing module 'RaTeX'" error.
37
+ if enable_math && !defined?(spm_dependency)
38
+ Pod::UI.warn '[ReactNativeEnrichedMarkdown] `spm_dependency` is unavailable in this ' \
39
+ 'React Native version; disabling LaTeX math (RaTeX). Upgrade React Native to enable it.'
40
+ enable_math = false
41
+ end
42
+
32
43
  unless enable_math
33
44
  s.exclude_files = "ios/math/**/*.swift"
34
45
  end
@@ -36,22 +47,39 @@ Pod::Spec.new do |s|
36
47
  preprocessor_defs = '$(inherited) MD4C_USE_UTF8=1'
37
48
  if enable_math
38
49
  preprocessor_defs += ' ENRICHED_MARKDOWN_MATH=1'
39
- if defined?(:spm_dependency)
40
- spm_dependency(s,
41
- url: 'https://github.com/erweixin/RaTeX.git',
42
- requirement: {kind: 'upToNextMajorVersion', minimumVersion: '0.1.12'},
43
- products: ['RaTeX']
44
- )
45
- end
50
+ spm_dependency(s,
51
+ url: 'https://github.com/erweixin/RaTeX.git',
52
+ requirement: {kind: 'upToNextMajorVersion', minimumVersion: '0.1.12'},
53
+ products: ['RaTeX']
54
+ )
46
55
  end
47
56
 
48
- s.pod_target_xcconfig = {
57
+ pod_xcconfig = {
49
58
  'HEADER_SEARCH_PATHS' => "\"#{cpp_root}/md4c\" \"#{cpp_root}/parser\" \"$(PODS_TARGET_SRCROOT)/ios/internals\" \"$(PODS_TARGET_SRCROOT)/ios/input/internals\"",
50
59
  'GCC_PREPROCESSOR_DEFINITIONS' => preprocessor_defs,
51
60
  'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17',
52
61
  'DEFINES_MODULE' => 'YES'
53
62
  }
54
63
 
64
+ # Detect Apple Silicon on the host running `pod install`. `sysctl hw.optional.arm64`
65
+ # reports the real hardware even under a Rosetta-translated Ruby, unlike `uname -m`.
66
+ apple_silicon = `sysctl -n hw.optional.arm64 2>/dev/null`.strip == '1'
67
+
68
+ if enable_math && apple_silicon
69
+ # RaTeX's Swift wrapper is compiled from SPM source, so its RaTeX.swiftmodule
70
+ # is emitted only for the arch(es) the build requests. Under ONLY_ACTIVE_ARCH
71
+ # on Apple Silicon that is arm64 only, but universal simulator builds (archive,
72
+ # "Any iOS Simulator Device", Release) also compile this pod for x86_64 and then
73
+ # fail with "could not find module 'RaTeX' for target 'x86_64-apple-ios-simulator'".
74
+ # Excluding x86_64 for the simulator keeps the pod and the app target arch sets in
75
+ # sync. Guarded to Apple Silicon so Intel Macs (which build x86_64 simulator slices)
76
+ # are unaffected; `$(inherited)` preserves exclusions from the user project / other pods.
77
+ pod_xcconfig['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = '$(inherited) x86_64'
78
+ s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => '$(inherited) x86_64' }
79
+ end
80
+
81
+ s.pod_target_xcconfig = pod_xcconfig
82
+
55
83
  if enable_math
56
84
  # React Native's spm_dependency generates a module.modulemap at
57
85
  # ${BUILT_PRODUCTS_DIR}/include/ that re-declares RaTeXFFI, but the RaTeX
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-enriched-markdown",
3
- "version": "0.7.3",
3
+ "version": "0.7.4",
4
4
  "description": "Markdown Text component for React Native",
5
5
  "main": "./lib/module/index",
6
6
  "module": "./lib/module/index",