diff --git a/packages/react-native/scripts/codegen/__tests__/__snapshots__/generate-artifacts-executor-test.js.snap b/packages/react-native/scripts/codegen/__tests__/__snapshots__/generate-artifacts-executor-test.js.snap index 72417e5e0f655d..5d6fce2dac5fe8 100644 --- a/packages/react-native/scripts/codegen/__tests__/__snapshots__/generate-artifacts-executor-test.js.snap +++ b/packages/react-native/scripts/codegen/__tests__/__snapshots__/generate-artifacts-executor-test.js.snap @@ -361,7 +361,7 @@ exports[`execute test-app "ReactAppDependencyProvider.podspec" should match snap # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. -version = \\"0.81.0-rc0\\" +version = \\"0.81.0\\" source = { :git => 'https://github.com/facebook/react-native.git' } if version == '1000.0.0' # This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in. @@ -399,7 +399,7 @@ exports[`execute test-app "ReactCodegen.podspec" should match snapshot 1`] = ` # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. -version = \\"0.81.0-rc0\\" +version = \\"0.81.0\\" source = { :git => 'https://github.com/facebook/react-native.git' } if version == '1000.0.0' # This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in. @@ -840,7 +840,7 @@ exports[`execute test-app-legacy "ReactAppDependencyProvider.podspec" should mat # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. -version = \\"0.81.0-rc0\\" +version = \\"0.81.0\\" source = { :git => 'https://github.com/facebook/react-native.git' } if version == '1000.0.0' # This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in. @@ -878,7 +878,7 @@ exports[`execute test-app-legacy "ReactCodegen.podspec" should match snapshot 1` # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. -version = \\"0.81.0-rc0\\" +version = \\"0.81.0\\" source = { :git => 'https://github.com/facebook/react-native.git' } if version == '1000.0.0' # This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in. diff --git a/packages/react-native/scripts/codegen/generate-artifacts-executor/utils.js b/packages/react-native/scripts/codegen/generate-artifacts-executor/utils.js index 7aefca2f12f835..298a8e5d28a460 100644 --- a/packages/react-native/scripts/codegen/generate-artifacts-executor/utils.js +++ b/packages/react-native/scripts/codegen/generate-artifacts-executor/utils.js @@ -372,7 +372,7 @@ function parseiOSAnnotations( ) /*: {[string]: $FlowFixMe} */ { const mLibraryMap = {} /*:: as {[string]: $FlowFixMe} */; const cLibraryMap = {} /*:: as {[string]: $FlowFixMe} */; - const map = {}; + const map = {} /*:: as {[string]: $FlowFixMe} */; // [macOS] for (const library of libraries) { const iosConfig = library?.config?.ios; @@ -406,6 +406,40 @@ function parseiOSAnnotations( } } } + // [macOS + // Allow react-native-macos to override react-native modules/components + const isAllowedOverride = (libraryNames /*: Set */) => { + const names = Array.from(libraryNames); + return ( + names.length === 2 && + names.includes('react-native') && + names.includes('react-native-macos') + ); + }; + + // Merge entries with react-native-macos taking precedence over react-native + for (const [moduleName, libraryNames] of Object.entries(mLibraryMap)) { + if (isAllowedOverride(libraryNames)) { + // Remove the module from react-native, keep only react-native-macos + if (map['react-native']?.modules?.[moduleName]) { + delete map['react-native'].modules[moduleName]; + } + // Update the library map to only contain react-native-macos + mLibraryMap[moduleName] = new Set(['react-native-macos']); + } + } + + for (const [componentName, libraryNames] of Object.entries(cLibraryMap)) { + if (isAllowedOverride(libraryNames)) { + // Remove the component from react-native, keep only react-native-macos + if (map['react-native']?.components?.[componentName]) { + delete map['react-native'].components[componentName]; + } + // Update the library map to only contain react-native-macos + cLibraryMap[componentName] = new Set(['react-native-macos']); + } + } + // macOS] const moduleConflicts = Object.entries(mLibraryMap) .filter(([_, libraryNames]) => libraryNames.size > 1)