@@ -71,7 +71,7 @@ const {
7171 MIN_IOS_VERSION_SUPPORTED ,
7272 sanitizeIosDeploymentTarget,
7373} = require ( './ios-deployment-target' ) ;
74- const { findPodspecs, readPodspecCached } = require ( './read-podspec' ) ;
74+ const { findPodspecs} = require ( './read-podspec' ) ;
7575const {
7676 AUTOLINKED_PACKAGE_NAME ,
7777 CXX_API_DEFINES ,
@@ -831,49 +831,6 @@ function expandSpmSourceGlobs(
831831 * `spm.name`). Every name this function emits comes from there — see
832832 * requireSwiftName.
833833 */
834- /**
835- * Read the dep's podspec (if any) and extract its declared
836- * `pod_target_xcconfig` HEADER_SEARCH_PATHS, substituted relative to the dep
837- * source dir. Returns paths suitable for an SPM `.headerSearchPath()`
838- * directive whose target.path is the dep root (entries are NOT yet prefixed
839- * with the synth wrapper's `root/` — the emission site adds that prefix
840- * because the wrapper's target.path is `.`, not the source dir).
841- *
842- * Without these, path-style angle includes like
843- * `<react/renderer/components/safeareacontext/X.h>` (used by
844- * react-native-safe-area-context, reanimated, screens, etc.) fail to resolve
845- * because the headers live under the dep's `common/cpp/` rather than under
846- * the framework-imported xcframework headers.
847- */
848- function extractPodspecHeaderSearchPaths (
849- sourceDir /*: string */ ,
850- ) /*: Array<string> */ {
851- const podspecPath /*: ?string */ = findPodspecs ( sourceDir ) [ 0 ] ;
852- if ( podspecPath == null ) return [ ] ;
853-
854- let model ;
855- try {
856- model = readPodspecCached ( podspecPath ) ;
857- } catch {
858- return [ ] ;
859- }
860-
861- const out /*: Array<string> */ = [ ] ;
862- for ( const raw of model . headerSearchPaths ) {
863- const substituted = raw
864- . replace ( / \$ \( P O D S _ T A R G E T _ S R C R O O T \) / g, '.' )
865- . replace ( / \$ \{ P O D S _ T A R G E T _ S R C R O O T \} / g, '.' ) ;
866- // Drop entries still containing unresolved Xcode tokens — emitting them
867- // verbatim would surface as clang "no such file" failures.
868- if ( / \$ [ ( { ] / . test ( substituted ) ) continue ;
869- const cleaned = substituted . replace ( / ^ \. \/ / , '' ) . replace ( / ^ \/ / , '' ) ;
870- if ( cleaned . length > 0 && ! out . includes ( cleaned ) ) {
871- out . push ( cleaned ) ;
872- }
873- }
874- return out ;
875- }
876-
877834/**
878835 * The Swift name expandSpmDependencies resolved for `npmName`, or a hard error:
879836 * re-deriving one here would emit a reference nothing in the graph matches.
@@ -924,17 +881,13 @@ function autolinkingDepToSpmTarget(
924881 ? spmDeps . map ( n => requireSwiftName ( n , swiftNameByNpm . get ( n ) ) )
925882 : undefined ;
926883
927- const headerSearchPaths = extractPodspecHeaderSearchPaths ( sourceDir ) ;
928-
929884 return {
930885 name : targetName ,
931886 path : relSourcePath ,
932887 exclude : [ ] ,
933888 publicHeadersPath : inferPublicHeadersPath ( sourceDir ) ,
934889 resources,
935890 spmTargetDependencies,
936- headerSearchPaths :
937- headerSearchPaths . length > 0 ? headerSearchPaths : undefined ,
938891 } ;
939892}
940893
@@ -1144,12 +1097,6 @@ function generateSynthPackageSwift(spec /*: SynthPackageSpec */) /*: string */ {
11441097 const exclude /*: Array<string> */ = spec . exclude ?? [ ] ;
11451098 const sources /*: ?Array<string> */ = spec . sources ;
11461099 const publicHeadersPath /*: ?string */ = spec . publicHeadersPath ?? null ;
1147- // Per-dep header search paths from the podspec's
1148- // pod_target_xcconfig HEADER_SEARCH_PATHS — already prefixed by the caller
1149- // with the synth wrapper's `root/` so they resolve relative to target.path.
1150- // Emitted as `.headerSearchPath()` directives, which SPM accepts on
1151- // cSettings / cxxSettings without needing absolute paths.
1152- const headerSearchPaths /*: Array<string> */ = spec . headerSearchPaths ?? [ ] ;
11531100 const spmDependencies /*: Array<{swiftName: string}> */ =
11541101 spec . spmDependencies ?? [ ] ;
11551102 const hasReactDep /*: boolean */ = spec . hasReactDep !== false ;
@@ -1233,25 +1180,11 @@ function generateSynthPackageSwift(spec /*: SynthPackageSpec */) /*: string */ {
12331180 packageDeps . length > 0
12341181 ? ` dependencies: [\n ${ packageDeps . join ( ',\n ' ) } ,\n ],\n`
12351182 : '' ;
1236- // `.headerSearchPath(...)` entries from the podspec — first-class
1237- // directives keep SPM's diagnostics meaningful (clang reports the
1238- // dep-relative path on miss). React headers need no paths at all.
1239- const headerSearchPathList = headerSearchPaths . map (
1240- p => `.headerSearchPath("${ p } ")` ,
1241- ) ;
1242- const cSettingsLine =
1243- headerSearchPathList . length > 0
1244- ? `\n cSettings: [${ headerSearchPathList . join ( ', ' ) } ],`
1245- : '' ;
1246- // ALWAYS emit the config-gated C++ defines (even with no header paths): a
1247- // Fabric C++ target must compile with the same NDEBUG state as the prebuilt
1248- // React.framework, else DebugStringConvertible's vtable / ShadowNode layout
1249- // diverges and a Release build fails to link. Mirrors Package.swift.
1250- const cxxEntries = [
1251- ...reactCxxDefines ( spec . cxxApiDefines ) ,
1252- ...headerSearchPathList ,
1253- ] ;
1254- const cxxSettingsLine = `\n cxxSettings: [${ cxxEntries . join ( ', ' ) } ],` ;
1183+ // ALWAYS emit the config-gated C++ defines: a Fabric C++ target must
1184+ // compile with the same NDEBUG state as the prebuilt React.framework, else
1185+ // DebugStringConvertible's vtable / ShadowNode layout diverges and a
1186+ // Release build fails to link. Mirrors Package.swift.
1187+ const cxxSettingsLine = `\n cxxSettings: [${ reactCxxDefines ( spec . cxxApiDefines ) . join ( ', ' ) } ],` ;
12551188
12561189 return `// swift-tools-version: 6.0
12571190// AUTO-GENERATED by scripts/generate-spm-autolinking.js – do not edit manually.
@@ -1269,7 +1202,7 @@ ${packageDepsBlock} targets: [
12691202 .target(
12701203 name: "${ swiftName } ",
12711204 dependencies: [${ targetDeps . join ( ', ' ) } ],
1272- path: "${ targetPath } ",${ excludeLine } ${ sourcesLine } ${ publicHeadersLine } ${ resourcesLine } ${ cSettingsLine } ${ cxxSettingsLine }
1205+ path: "${ targetPath } ",${ excludeLine } ${ sourcesLine } ${ publicHeadersLine } ${ resourcesLine } ${ cxxSettingsLine }
12731206 linkerSettings: [.linkedFramework("UIKit"), .linkedFramework("Foundation"), .linkedFramework("CoreGraphics")]
12741207 ),
12751208 ],
@@ -1729,15 +1662,6 @@ function main(argv /*:: ?: Array<string> */) /*: void */ {
17291662 const prefixedSources /*: ?Array<string> */ =
17301663 rawSources . length > 0 ? rawSources . map ( withRoot ) : null ;
17311664
1732- // Podspec HEADER_SEARCH_PATHS were captured relative to the dep's source
1733- // dir. The wrapper exposes the source dir under `root/` (target.path is
1734- // `.`, the wrapper dir), so each entry must be prefixed with `root/` so
1735- // clang sees the real subtree.
1736- const prefixedHeaderSearchPaths /*: ?Array<string> */ =
1737- target . headerSearchPaths != null && target . headerSearchPaths . length > 0
1738- ? target . headerSearchPaths . map ( withRoot )
1739- : null ;
1740-
17411665 const synthContent = generateSynthPackageSwift ( {
17421666 swiftName : target . name ,
17431667 iosDeploymentTarget : args . iosDeploymentTarget ,
@@ -1749,7 +1673,6 @@ function main(argv /*:: ?: Array<string> */) /*: void */ {
17491673 // header farm at <outputDir>/headers is folded into it).
17501674 publicHeadersPath : 'include' ,
17511675 resources : prefixedResources ,
1752- headerSearchPaths : prefixedHeaderSearchPaths ,
17531676 spmDependencies : ( target . spmTargetDependencies ?? [ ] ) . map ( swiftName => ( {
17541677 swiftName,
17551678 } ) ) ,
0 commit comments