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".*$)/mg, 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\/)(React-Core)/g, 59 with: `$1${versionName}$2`, 60 }, 61 62 // React-cxxreact 63 { 64 // Fixes excluding SampleCxxModule.* files 65 paths: 'React-cxxreact.podspec', 66 replace: /\.exclude_files(\s*=\s*["'])(SampleCxxModule\.\*)(["'])/g, 67 with: `.exclude_files$1${versionName}$2$3`, 68 }, 69 70 // Yoga 71 { 72 // Unprefixes inner directory for source_files 73 paths: 'Yoga.podspec', 74 replace: /\{(Yoga),(YGEnums),(YGMacros),(YGNode),(YGStyle),(YGValue)\}/g, 75 with: `{${versionName}$1,${versionName}$2,${versionName}$3,${versionName}$4,${versionName}$5,${versionName}$6}`, 76 }, 77 78 // FBReactNativeSpec 79 { 80 // Remove codegen from build phase script 81 paths: 'FBReactNativeSpec.podspec', 82 replace: /\n use_react_native_codegen!\((.|\n)+?\n }\)\n/mg, 83 with: '', 84 }, 85 ], 86 }; 87} 88