I keep getting this errror when i'm trying to run React native app from Xcode 13.3 .
if i run it from terminal ( react-native run-ios ) it works fine.
Please find enclosed error details.
> > File /Users/Library/Developer/Xcode/DerivedData/appName-crvjvqqnpdxpwkfkxccvnxunhhkw/
Build/Products/Release-iphonesimulator/appName.app/main.jsbundle
> does not exist. This must be a bug with'
My Environment details MAC OS - 12.3.1 (M1 chip) Xcode - 13.3 command line tools - 13.3 RN version - 0.61.5
solutions i have tried upto now
npx react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios
(Xcode) -Build Phases -> Bundle React Native code and images , change to
cd $PROJECT_DIR/..
export NODE_BINARY=node
./node_modules/react-native/scripts/react-native-xcode.sh
Please let me know how i can fix this error.
I encountered this issue all of a sudden after ~1 year of development on a project, working in
RN 0.71.6
, currently onVersion 14.3.1 (14E300c)
. I tried to upgrade to the latest version ofv71
-RN 0.71.14
, but the problem persisted. It seemed intuitive that since this issue 'crept in', simply refreshing my build environment should solve it.I tried to reinstall all libraries to no avail. Cleaning the build folder also did not work.
Solution:
Delete the project state/metadata directory that contains the Build output folder.
By entirely deleting
/Users/<username>/Library/Developer/Xcode/DerivedData/<app-id>-<unique-build-hash-id>
, I was able to build a completely fresh version of the app, and the problem with the missing main.js file was resolved.Project settings/options are cached elsewhere, so there is no need to worry about losing these. You will need to re-index files though (for-example), and any other build-prep that your project would encounter with a fresh start on the repository.
Note:
When clearing the build folder via XCode, only the following directory is nuked:
/Users/<username>/Library/Developer/Xcode/DerivedData/<app-id>-<unique-build-hash-id>/Build/Product
. And some contents of/Users/<username>/Library/Developer/Xcode/DerivedData/<app-id>-<unique-build-hash-id>/Build/Intermediates.noindex
are modified.For my case, the issue seemed to result in a corrupted or incorrect state persisted in the files generated by xcode that describe the project's build setup, which are not cleared when the build folder is cleared.