From 4c9490c702b9fb2eed44d17815627837101430ee Mon Sep 17 00:00:00 2001 From: Gabriel Donadel Date: Wed, 4 Jun 2025 10:46:49 -0700 Subject: [PATCH] generate-artifacts-executor: fix parsing .class in complex classes (#51813) Summary: There is an edge case in the codegen `findRCTComponentViewProtocolClass` function where the parsing of the Component Class will fail if there is another `.class` call in the same file after the `Class` function. This ends up resulting in a `RCTThirdPartyComponentsProvider.mm` file that looks like the image bellow image You can reproduce this with the following ``` Class XYZCls(void) { return XYZ.class; } // this comment breaks codegen .class ``` ## Changelog: [IOS] [FIXED] - Fix codegen extracting `.class` from complex component classes Pull Request resolved: https://github.com/facebook/react-native/pull/51813 Test Plan: Run codegen locally, use this patch in the expo/expo repo and CI should be green Reviewed By: cipolleschi Differential Revision: D75964424 Pulled By: cortinico fbshipit-source-id: 50e45aa2ac6e43c75ee6fdd76791c591d81d4df7 --- .../generateRCTThirdPartyComponents.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-native/scripts/codegen/generate-artifacts-executor/generateRCTThirdPartyComponents.js b/packages/react-native/scripts/codegen/generate-artifacts-executor/generateRCTThirdPartyComponents.js index 53669facbd7..baadd3eddc9 100644 --- a/packages/react-native/scripts/codegen/generate-artifacts-executor/generateRCTThirdPartyComponents.js +++ b/packages/react-native/scripts/codegen/generate-artifacts-executor/generateRCTThirdPartyComponents.js @@ -186,7 +186,7 @@ function findRCTComponentViewProtocolClass(filepath) { const lines = fileContent.split('\n'); const signatureIndex = lines.findIndex(line => regex.test(line)); const returnRegex = /return (.*)\.class/; - const classNameMatch = String(lines.slice(signatureIndex)).match( + const classNameMatch = String(lines.slice(signatureIndex).join('\n')).match( returnRegex, ); if (classNameMatch) {