React Native fails to archive with main.jsbundle does not exist
See original GitHub issueTrying to archive (Product->Archive) a version locally on Xcode, the command is breaking returning “main.jsbundle does not exist”
Current Behavior
Expected Behavior
Xcode produces an archive build.
I’m new to nx, so I have not personally seen this work. I have to believe it has, since archiving production builds is an essential requirement. Also, #11376 implies that it has worked in the past.
Steps to Reproduce
- Create a fresh workspace with a react native app:
npx create-nx-workspace@latest rn-sept21 --preset=react-native --appName=mobile
- Ensure it runs from CLI:
nx run-ios
- Open
apps/mobile/ios/Mobile.xcworkspace
in Xcode and select "Any iOS Device (arm64) - Select Product->Archive from the menu. Wait for the error
Failure Logs
... I truncated much. Here's where I think it gets interesting
/Users/chrispruett/dev/rn-sept21/apps/mobile/ios/Pods/../.xcode.env: line 12: PROJECT_DIR: command not found
Node found at: /usr/local/bin/node
+ DEST=/Users/chrispruett/Library/Developer/Xcode/DerivedData/Mobile-fpwcdkyguzpdwiapqawuplmyupdr/Build/Intermediates.noindex/ArchiveIntermediates/Mobile/BuildProductsPath/Release-iphoneos/Mobile.app
+ [[ Release = *Debug* ]]
+ [[ -n '' ]]
+ case "$CONFIGURATION" in
+ DEV=false
+++ dirname ../node_modules/react-native/scripts/react-native-xcode.sh
++ cd ../node_modules/react-native/scripts/..
++ pwd
+ REACT_NATIVE_DIR=/Users/chrispruett/dev/rn-sept21/apps/mobile/node_modules/react-native
+ PROJECT_ROOT=/Users/chrispruett/dev/rn-sept21/apps/mobile/node_modules/react-native/../..
+ cd /Users/chrispruett/dev/rn-sept21/apps/mobile/node_modules/react-native/../..
+ [[ -n /../src/main.tsx ]]
+ :
+ source /Users/chrispruett/dev/rn-sept21/apps/mobile/node_modules/react-native/scripts/node-binary.sh
++ '[' -z /usr/local/bin/node ']'
++ type /usr/local/bin/node
+ HERMES_ENGINE_PATH=/Users/chrispruett/dev/rn-sept21/apps/mobile/ios/Pods/hermes-engine
+ '[' -z '' ']'
+ HERMES_CLI_PATH=/Users/chrispruett/dev/rn-sept21/apps/mobile/ios/Pods/hermes-engine/destroot/bin/hermesc
+ [[ -f /Users/chrispruett/dev/rn-sept21/apps/mobile/ios/Pods/hermes-engine ]]
+ '[' -z '' ']'
+ export NODE_ARGS=
+ NODE_ARGS=
+ '[' -z '' ']'
+ export CLI_PATH=/Users/chrispruett/dev/rn-sept21/apps/mobile/node_modules/react-native/cli.js
+ CLI_PATH=/Users/chrispruett/dev/rn-sept21/apps/mobile/node_modules/react-native/cli.js
+ '[' -z '' ']'
+ BUNDLE_COMMAND=bundle
+ '[' -z '' ']'
+ COMPOSE_SOURCEMAP_PATH=/Users/chrispruett/dev/rn-sept21/apps/mobile/node_modules/react-native/scripts/compose-source-maps.js
+ [[ -z '' ]]
+ CONFIG_ARG=
+ BUNDLE_FILE=/Users/chrispruett/Library/Developer/Xcode/DerivedData/Mobile-fpwcdkyguzpdwiapqawuplmyupdr/Build/Intermediates.noindex/ArchiveIntermediates/Mobile/BuildProductsPath/Release-iphoneos/main.jsbundle
+ EXTRA_ARGS=
+ case "$PLATFORM_NAME" in
+ BUNDLE_PLATFORM=ios
+ '[' '' = YES ']'
+ EMIT_SOURCEMAP=
+ [[ ! -z '' ]]
+ PACKAGER_SOURCEMAP_FILE=
+ [[ '' == true ]]
+ [[ '' == true ]]
+ /usr/local/bin/node /Users/chrispruett/dev/rn-sept21/apps/mobile/node_modules/react-native/cli.js bundle --entry-file /../src/main.tsx --platform ios --dev false --reset-cache --bundle-output /Users/chrispruett/Library/Developer/Xcode/DerivedData/Mobile-fpwcdkyguzpdwiapqawuplmyupdr/Build/Intermediates.noindex/ArchiveIntermediates/Mobile/BuildProductsPath/Release-iphoneos/main.jsbundle --assets-dest /Users/chrispruett/Library/Developer/Xcode/DerivedData/Mobile-fpwcdkyguzpdwiapqawuplmyupdr/Build/Intermediates.noindex/ArchiveIntermediates/Mobile/BuildProductsPath/Release-iphoneos/Mobile.app
warning: the transform cache was reset.
error The resource `/src/main.tsx` was not found.
Error: The resource `/src/main.tsx` was not found.
at /Users/chrispruett/dev/rn-sept21/node_modules/metro/src/IncrementalBundler.js:315:24
at gotStat (node:fs:2696:21)
at FSReqCallback.oncomplete (node:fs:204:21)
info Run CLI with --verbose flag for more details.
+ [[ '' != true ]]
+ cp /Users/chrispruett/Library/Developer/Xcode/DerivedData/Mobile-fpwcdkyguzpdwiapqawuplmyupdr/Build/Intermediates.noindex/ArchiveIntermediates/Mobile/BuildProductsPath/Release-iphoneos/main.jsbundle /Users/chrispruett/Library/Developer/Xcode/DerivedData/Mobile-fpwcdkyguzpdwiapqawuplmyupdr/Build/Intermediates.noindex/ArchiveIntermediates/Mobile/BuildProductsPath/Release-iphoneos/Mobile.app/
cp: /Users/chrispruett/Library/Developer/Xcode/DerivedData/Mobile-fpwcdkyguzpdwiapqawuplmyupdr/Build/Intermediates.noindex/ArchiveIntermediates/Mobile/BuildProductsPath/Release-iphoneos/main.jsbundle: No such file or directory
+ BUNDLE_FILE=/Users/chrispruett/Library/Developer/Xcode/DerivedData/Mobile-fpwcdkyguzpdwiapqawuplmyupdr/Build/Intermediates.noindex/ArchiveIntermediates/Mobile/BuildProductsPath/Release-iphoneos/Mobile.app/main.jsbundle
+ [[ false != true ]]
+ [[ ! -f /Users/chrispruett/Library/Developer/Xcode/DerivedData/Mobile-fpwcdkyguzpdwiapqawuplmyupdr/Build/Intermediates.noindex/ArchiveIntermediates/Mobile/BuildProductsPath/Release-iphoneos/Mobile.app/main.jsbundle ]]
+ echo 'error: File /Users/chrispruett/Library/Developer/Xcode/DerivedData/Mobile-fpwcdkyguzpdwiapqawuplmyupdr/Build/Intermediates.noindex/ArchiveIntermediates/Mobile/BuildProductsPath/Release-iphoneos/Mobile.app/main.jsbundle does not exist. This must be a bug with React Native, please report it here: https://github.com/facebook/react-native/issues'
error: File /Users/chrispruett/Library/Developer/Xcode/DerivedData/Mobile-fpwcdkyguzpdwiapqawuplmyupdr/Build/Intermediates.noindex/ArchiveIntermediates/Mobile/BuildProductsPath/Release-iphoneos/Mobile.app/main.jsbundle does not exist. This must be a bug with React Native, please report it here: https://github.com/facebook/react-native/issues
+ exit 2
/Users/chrispruett/dev/rn-sept21/apps/mobile/ios/Pods/../.xcode.env: line 12: PROJECT_DIR: command not found
Node found at: /usr/local/bin/node
+ DEST=/Users/chrispruett/Library/Developer/Xcode/DerivedData/Mobile-fpwcdkyguzpdwiapqawuplmyupdr/Build/Intermediates.noindex/ArchiveIntermediates/Mobile/BuildProductsPath/Release-iphoneos/Mobile.app
+ [[ Release = *Debug* ]]
+ [[ -n '' ]]
+ case "$CONFIGURATION" in
+ DEV=false
+++ dirname ../node_modules/react-native/scripts/react-native-xcode.sh
++ cd ../node_modules/react-native/scripts/..
++ pwd
+ REACT_NATIVE_DIR=/Users/chrispruett/dev/rn-sept21/apps/mobile/node_modules/react-native
+ PROJECT_ROOT=/Users/chrispruett/dev/rn-sept21/apps/mobile/node_modules/react-native/../..
+ cd /Users/chrispruett/dev/rn-sept21/apps/mobile/node_modules/react-native/../..
+ [[ -n /../src/main.tsx ]]
+ :
+ source /Users/chrispruett/dev/rn-sept21/apps/mobile/node_modules/react-native/scripts/node-binary.sh
++ '[' -z /usr/local/bin/node ']'
++ type /usr/local/bin/node
+ HERMES_ENGINE_PATH=/Users/chrispruett/dev/rn-sept21/apps/mobile/ios/Pods/hermes-engine
+ '[' -z '' ']'
+ HERMES_CLI_PATH=/Users/chrispruett/dev/rn-sept21/apps/mobile/ios/Pods/hermes-engine/destroot/bin/hermesc
+ [[ -f /Users/chrispruett/dev/rn-sept21/apps/mobile/ios/Pods/hermes-engine ]]
+ '[' -z '' ']'
+ export NODE_ARGS=
+ NODE_ARGS=
+ '[' -z '' ']'
+ export CLI_PATH=/Users/chrispruett/dev/rn-sept21/apps/mobile/node_modules/react-native/cli.js
+ CLI_PATH=/Users/chrispruett/dev/rn-sept21/apps/mobile/node_modules/react-native/cli.js
+ '[' -z '' ']'
+ BUNDLE_COMMAND=bundle
+ '[' -z '' ']'
+ COMPOSE_SOURCEMAP_PATH=/Users/chrispruett/dev/rn-sept21/apps/mobile/node_modules/react-native/scripts/compose-source-maps.js
+ [[ -z '' ]]
+ CONFIG_ARG=
+ BUNDLE_FILE=/Users/chrispruett/Library/Developer/Xcode/DerivedData/Mobile-fpwcdkyguzpdwiapqawuplmyupdr/Build/Intermediates.noindex/ArchiveIntermediates/Mobile/BuildProductsPath/Release-iphoneos/main.jsbundle
+ EXTRA_ARGS=
+ case "$PLATFORM_NAME" in
+ BUNDLE_PLATFORM=ios
+ '[' '' = YES ']'
+ EMIT_SOURCEMAP=
+ [[ ! -z '' ]]
+ PACKAGER_SOURCEMAP_FILE=
+ [[ '' == true ]]
+ [[ '' == true ]]
+ /usr/local/bin/node /Users/chrispruett/dev/rn-sept21/apps/mobile/node_modules/react-native/cli.js bundle --entry-file /../src/main.tsx --platform ios --dev false --reset-cache --bundle-output /Users/chrispruett/Library/Developer/Xcode/DerivedData/Mobile-fpwcdkyguzpdwiapqawuplmyupdr/Build/Intermediates.noindex/ArchiveIntermediates/Mobile/BuildProductsPath/Release-iphoneos/main.jsbundle --assets-dest /Users/chrispruett/Library/Developer/Xcode/DerivedData/Mobile-fpwcdkyguzpdwiapqawuplmyupdr/Build/Intermediates.noindex/ArchiveIntermediates/Mobile/BuildProductsPath/Release-iphoneos/Mobile.app
error The resource `/src/main.tsx` was not found.
Error: The resource `/src/main.tsx` was not found.
at /Users/chrispruett/dev/rn-sept21/node_modules/metro/src/IncrementalBundler.js:315:24
at gotStat (node:fs:2696:21)
at FSReqCallback.oncomplete (node:fs:204:21)
info Run CLI with --verbose flag for more details.
+ [[ '' != true ]]
+ cp /Users/chrispruett/Library/Developer/Xcode/DerivedData/Mobile-fpwcdkyguzpdwiapqawuplmyupdr/Build/Intermediates.noindex/ArchiveIntermediates/Mobile/BuildProductsPath/Release-iphoneos/main.jsbundle /Users/chrispruett/Library/Developer/Xcode/DerivedData/Mobile-fpwcdkyguzpdwiapqawuplmyupdr/Build/Intermediates.noindex/ArchiveIntermediates/Mobile/BuildProductsPath/Release-iphoneos/Mobile.app/
cp: /Users/chrispruett/Library/Developer/Xcode/DerivedData/Mobile-fpwcdkyguzpdwiapqawuplmyupdr/Build/Intermediates.noindex/ArchiveIntermediates/Mobile/BuildProductsPath/Release-iphoneos/main.jsbundle: No such file or directory
+ BUNDLE_FILE=/Users/chrispruett/Library/Developer/Xcode/DerivedData/Mobile-fpwcdkyguzpdwiapqawuplmyupdr/Build/Intermediates.noindex/ArchiveIntermediates/Mobile/BuildProductsPath/Release-iphoneos/Mobile.app/main.jsbundle
+ [[ false != true ]]
+ [[ ! -f /Users/chrispruett/Library/Developer/Xcode/DerivedData/Mobile-fpwcdkyguzpdwiapqawuplmyupdr/Build/Intermediates.noindex/ArchiveIntermediates/Mobile/BuildProductsPath/Release-iphoneos/Mobile.app/main.jsbundle ]]
+ echo 'error: File /Users/chrispruett/Library/Developer/Xcode/DerivedData/Mobile-fpwcdkyguzpdwiapqawuplmyupdr/Build/Intermediates.noindex/ArchiveIntermediates/Mobile/BuildProductsPath/Release-iphoneos/Mobile.app/main.jsbundle does not exist. This must be a bug with React Native, please report it here: https://github.com/facebook/react-native/issues'
the transform cache was reset.
+ exit 2
File /Users/chrispruett/Library/Developer/Xcode/DerivedData/Mobile-fpwcdkyguzpdwiapqawuplmyupdr/Build/Intermediates.noindex/ArchiveIntermediates/Mobile/BuildProductsPath/Release-iphoneos/Mobile.app/main.jsbundle does not exist. This must be a bug with React Native, please report it here: https://github.com/facebook/react-native/issues
Environment
nx report
> NX Report complete - copy this into the issue template
Node : 18.3.0
OS : darwin arm64
npm : 8.11.0
nx : 14.7.8
@nrwl/angular : Not Found
@nrwl/cypress : 14.7.8
@nrwl/detox : 14.7.8
@nrwl/devkit : 14.7.8
@nrwl/eslint-plugin-nx : 14.7.8
@nrwl/expo : Not Found
@nrwl/express : Not Found
@nrwl/jest : 14.7.8
@nrwl/js : 14.7.8
@nrwl/linter : 14.7.8
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : Not Found
@nrwl/nx-cloud : Not Found
@nrwl/nx-plugin : Not Found
@nrwl/react : 14.7.8
@nrwl/react-native : 14.7.8
@nrwl/schematics : Not Found
@nrwl/storybook : 14.7.8
@nrwl/web : 14.7.8
@nrwl/workspace : 14.7.8
typescript : 4.8.3
---------------------------------------
Local workspace plugins:
---------------------------------------
Community plugins:
Issue Analytics
- State:
- Created a year ago
- Comments:6
Top Results From Across the Web
main.jsbundle does not exist. This must be a bug with #29356
app Welcome to React Native! Learn once, write anywhere error src/services/FirebaseAnalytics.ts: Unexpected token name «_000», expected punc «)» ...
Read more >main.jsbundle does not exist. this must be a bug with + echo ...
I tried to archive my react native project using ...
Read more >main.jsbundle does not exist [fixed] | by Onexlab - Medium
Open the package.json file and add the following line · Run following command. It will generate main. · Select -> Target → Build...
Read more >React Native build failed - "Error: main.jsbundle does not exist"
The error displayed was: (As you can se it was truncated in the output but shown in its entirety below it.) Running script...
Read more >Impossible to build archive | Apple Developer Forums
Since updating xcode to 12.4, I can't produce any archives, but before that everything was ... Release-iphoneos / jdc.app / main.jsbundle does not...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In my case the problem was not in the path to the main.jsbundle file. If you attach the entire error message, maybe I can help you.
EDIT: In my case the problem was that I specified the number as 120_000 instead of 120000. Everything worked fine except the archiving in xcode.
It’s working after remove ‘_’ in number. In my case revert the code -> 10_000 to 10000
thanks @meketiuk