1import { TransformPipeline } from '.'; 2 3export function podspecTransforms(versionName: string): TransformPipeline { 4 return { 5 transforms: [ 6 // Common transforms 7 { 8 // Transforms some podspec fields by adding versionName at the beginning 9 replace: /\.(name|header_dir|module_name)(\s*=\s*["'])([^"']+)(["'])/g, 10 with: `.$1$2${versionName}$3$4`, 11 }, 12 { 13 // Prefixes dependencies listed in the podspecs 14 replace: /(\.dependency\s+["'])(Yoga|React\-|ReactCommon|RCT|FB)(?!-Folly)([^"']*["'])/g, 15 with: `$1${versionName}$2$3`, 16 }, 17 { 18 // Removes source conditional 19 replace: /source\s*\=\s*\{[.\S\s]+?end/g, 20 with: '', 21 }, 22 { 23 // Points spec source at correct directory 24 replace: /(\.source\s*\=\s*)\S+\n/g, 25 with: '$1{ :path => "." }\n', 26 }, 27 28 // React-Core & ReactCommon 29 { 30 // Fixes header_subspecs for RCTBlobHeaders 31 paths: 'React-Core.podspec', 32 replace: /\{(RCTBlobManager),(RCTFileReaderModule)\}/g, 33 with: `{${versionName}$1,${versionName}$2}`, 34 }, 35 { 36 // Prefixes conflicting AccessibilityResources 37 paths: 'React-Core.podspec', 38 replace: /"AccessibilityResources"/g, 39 with: `"${versionName}AccessibilityResources"`, 40 }, 41 { 42 // Hide Hermes headers from public headers because clang modoules does not support c++ 43 // Learn more: `packages/expo-modules-autolinking/scripts/ios/cocoapods/sandbox.rb` 44 paths: 'React-Core.podspec', 45 replace: /(s.subspec\s+"Hermes".*$)/gm, 46 with: '$1\n ss.private_header_files = "ReactCommon/hermes/executor/*.h", "ReactCommon/hermes/inspector/*.h", "ReactCommon/hermes/inspector/chrome/*.h", "ReactCommon/hermes/inspector/detail/*.h"', 47 }, 48 { 49 // DEFINES_MODULE for swift integration 50 // Learn more: `packages/expo-modules-autolinking/scripts/ios/cocoapods/sandbox.rb` 51 paths: 'ReactCommon.podspec', 52 replace: /("USE_HEADERMAP" => "YES",)/g, 53 with: '$1 "DEFINES_MODULE" => "YES",', 54 }, 55 { 56 // Fixes HEADER_SEARCH_PATHS 57 paths: ['React-Core.podspec', 'ReactCommon.podspec'], 58 replace: /(Headers\/Private\/|_BUILD_DIR\)\/)(React-)(Core|bridging)/g, 59 with: `$1${versionName}$2$3`, 60 }, 61 62 // React-bridging 63 { 64 paths: 'React-bridging.podspec', 65 replace: /\bheader_mappings_dir\s*=\s*"."/, 66 with: 'header_mappings_dir = "react/bridging"', 67 }, 68 69 // React-cxxreact 70 { 71 // Fixes excluding SampleCxxModule.* files 72 paths: 'React-cxxreact.podspec', 73 replace: /\.exclude_files(\s*=\s*["'])(SampleCxxModule\.\*)(["'])/g, 74 with: `.exclude_files$1${versionName}$2$3`, 75 }, 76 77 // Yoga 78 { 79 // Unprefixes inner directory for source_files 80 paths: 'Yoga.podspec', 81 replace: /\{(Yoga),(YGEnums),(YGMacros),(YGNode),(YGStyle),(YGValue)\}/g, 82 with: `{${versionName}$1,${versionName}$2,${versionName}$3,${versionName}$4,${versionName}$5,${versionName}$6}`, 83 }, 84 85 // FBReactNativeSpec 86 { 87 // Remove codegen from build phase script 88 paths: 'FBReactNativeSpec.podspec', 89 replace: /\n use_react_native_codegen!\((.|\n)+?\n }\)\n/gm, 90 with: '', 91 }, 92 ], 93 }; 94} 95