diff --git a/packages/react-native-codegen/src/generators/components/ComponentsProviderUtils.js b/packages/react-native-codegen/src/generators/components/ComponentsProviderUtils.js index bb050eec7c3f6e..0ee2c4afa76aa6 100644 --- a/packages/react-native-codegen/src/generators/components/ComponentsProviderUtils.js +++ b/packages/react-native-codegen/src/generators/components/ComponentsProviderUtils.js @@ -26,6 +26,16 @@ function generateSupportedApplePlatformsMacro( return fileTemplate; } + // According to Podspec Syntax Reference, when `platform` or `deployment_target` is not specified, it defaults to all platforms. + // https://guides.cocoapods.org/syntax/podspec.html#platform + const everyPlatformIsUnsupported = Object.keys(supportedPlatformsMap).every( + platform => supportedPlatformsMap[platform] === false, + ); + + if (everyPlatformIsUnsupported) { + return fileTemplate; + } + const compilerMacroString = Object.keys(supportedPlatformsMap) .reduce((acc: string[], platform) => { if (!supportedPlatformsMap[platform]) {