Skip to content

Commit bc35034

Browse files
vonovakfacebook-github-bot
authored andcommitted
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: #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
1 parent c4d2ac6 commit bc35034

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

packages/react-native/scripts/codegen/generate-artifacts-executor/generateReactCodegenPodspec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ function getInputFiles(appPath /*: string */, appPkgJson /*: $FlowFixMe */) {
5959
!projectPath.includes('/Pods/') && // exclude Pods/Pods.xcodeproj
6060
!projectPath.includes('/node_modules/'), // exclude all the xcodeproj in node_modules of libraries
6161
)[0];
62+
if (!xcodeproj) {
63+
throw new Error(
64+
`Cannot find .xcodeproj file inside ${appPath}. This is required to determine codegen spec paths relative to native project.`,
65+
);
66+
}
6267
const jsFiles = '-name "Native*.js" -or -name "*NativeComponent.js"';
6368
const tsFiles = '-name "Native*.ts" -or -name "*NativeComponent.ts"';
6469
const findCommand = `find ${path.join(appPath, jsSrcsDir)} -type f -not -path "*/__mocks__/*" -and \\( ${jsFiles} -or ${tsFiles} \\)`;

0 commit comments

Comments
 (0)