From bc3503452f70e1f6917070f3a1b00d75bcd46b3f Mon Sep 17 00:00:00 2001 From: Vojtech Novak Date: Fri, 12 Sep 2025 03:41:50 -0700 Subject: [PATCH] chore: improve codegen error when native project not found (#53726) Summary: While working on a somewhat non-standard library setup I ran into: `[Codegen] TypeError [ERR_INVALID_ARG_TYPE]: The "from" argument must be of type string. Received undefined` which was caused by `xcodeproj` file not found. The issue was on the project side rather than codegen, but the error message was rather unhelpful, so this improves it. ## Changelog: [General][Changed] - improve codegen error when ios native project not found Pull Request resolved: https://github.com/facebook/react-native/pull/53726 Test Plan: tested locally, received the improved error message: `[Codegen] Error: Cannot find .xcodeproj file inside /Users/some_project. This is required to determine codegen spec paths relative to native project.` Reviewed By: cortinico Differential Revision: D82226931 Pulled By: cipolleschi fbshipit-source-id: dd851205655048fc35ed9f5266cefdbfb067d211 --- .../generateReactCodegenPodspec.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/react-native/scripts/codegen/generate-artifacts-executor/generateReactCodegenPodspec.js b/packages/react-native/scripts/codegen/generate-artifacts-executor/generateReactCodegenPodspec.js index 554dbca091f..42eeebe7604 100644 --- a/packages/react-native/scripts/codegen/generate-artifacts-executor/generateReactCodegenPodspec.js +++ b/packages/react-native/scripts/codegen/generate-artifacts-executor/generateReactCodegenPodspec.js @@ -59,6 +59,11 @@ function getInputFiles(appPath /*: string */, appPkgJson /*: $FlowFixMe */) { !projectPath.includes('/Pods/') && // exclude Pods/Pods.xcodeproj !projectPath.includes('/node_modules/'), // exclude all the xcodeproj in node_modules of libraries )[0]; + if (!xcodeproj) { + throw new Error( + `Cannot find .xcodeproj file inside ${appPath}. This is required to determine codegen spec paths relative to native project.`, + ); + } const jsFiles = '-name "Native*.js" -or -name "*NativeComponent.js"'; const tsFiles = '-name "Native*.ts" -or -name "*NativeComponent.ts"'; const findCommand = `find ${path.join(appPath, jsSrcsDir)} -type f -not -path "*/__mocks__/*" -and \\( ${jsFiles} -or ${tsFiles} \\)`;