Skip to content

Commit

Permalink
Allow sharing of ObjC codegen logic in macOS
Browse files Browse the repository at this point in the history
Summary:
Having the ability to generate ObjC wrappers for TurboModules is useful in other ObjC based platforms. This unblocks for react-native-macos.

## Changelog

[Internal]

Differential Revision: D66836579
  • Loading branch information
rozele authored and facebook-github-bot committed Dec 6, 2024
1 parent c54ba09 commit dd811ab
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ RNCodegen.generate(
'modulesAndroid',
'modulesCxx',
'modulesIOS',
'modulesMacOS',
],
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export type LibraryGenerators =
| 'modulesAndroid'
| 'modulesCxx'
| 'modulesIOS'
| 'modulesMacOS'
;

export type SchemaGenerators =
Expand Down
5 changes: 4 additions & 1 deletion packages/react-native-codegen/src/generators/RNCodegen.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ type LibraryGenerators =
| 'shadow-nodes'
| 'modulesAndroid'
| 'modulesCxx'
| 'modulesIOS';
| 'modulesIOS'
| 'modulesMacOS';

type SchemasGenerators = 'providerIOS';

Expand Down Expand Up @@ -161,6 +162,7 @@ const LIBRARY_GENERATORS = {
],
modulesCxx: [generateModuleCpp.generate, generateModuleH.generate],
modulesIOS: [generateModuleObjCpp.generate],
modulesMacOS: [generateModuleObjCpp.generate],
tests: [generateTests.generate],
'shadow-nodes': [
generateShadowNodeCpp.generate,
Expand Down Expand Up @@ -261,6 +263,7 @@ module.exports = {
const outputFoldersForGenerators = {
componentsIOS: componentIOSOutput,
modulesIOS: modulesIOSOutput,
modulesMacOS: modulesIOSOutput,
descriptors: outputDirectory,
events: outputDirectory,
props: outputDirectory,
Expand Down
5 changes: 5 additions & 0 deletions packages/react-native-codegen/src/parsers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ function verifyPlatforms(
return;
}

if (name.endsWith('MacOS')) {
excludedPlatforms.add('android');
return;
}

if (name.endsWith('Cxx')) {
cxxOnly = true;
excludedPlatforms.add('iOS');
Expand Down

0 comments on commit dd811ab

Please sign in to comment.