react-native
react-native copied to clipboard
main.jsbundle.map: No such file or directory when iOS project name includes spaces
Description
To enable React Native source maps, it is possible to include a SOURCEMAP_FILE
environment variable in the ios/.xcode.env
file. However, this method has a limitation: if the iOS project name contains a space, an issue arises. The problem stems from the fact that the react-native/scripts/react-native-xcode.sh
script utilizes the basename command without enclosing the $SOURCEMAP_FILE
argument in double quotes, leading to unintended word splitting.
Steps to reproduce
- Initialize a new react-native project.
- Change the name of the iOS project to include spaces, such as "Reproducer App".
- Insert the line
export SOURCEMAP_FILE="$DERIVED_FILE_DIR/main.jsbundle.map"
into theios/.xcode.env
file. - Compile the iOS application using Xcode on release mode.
- Examine the Xcode logs for the message "main.jsbundle.map: No such file or directory".
React Native Version
0.72.7
Affected Platforms
Runtime - iOS
Output of npx react-native info
System:
OS: macOS 14.1.2
CPU: (12) arm64 Apple M2 Pro
Memory: 292.97 MB / 32.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 18.12.0
path: ~/.local/share/rtx/installs/node/18.12.0/bin/node
Yarn:
version: 1.22.19
path: ~/.local/share/rtx/installs/yarn/1.22.19/bin/yarn
npm:
version: 8.19.2
path: ~/.local/share/rtx/installs/node/18.12.0/bin/npm
Watchman: Not Found
Managers:
CocoaPods: Not Found
SDKs:
iOS SDK:
Platforms:
- DriverKit 23.0
- iOS 17.0
- macOS 14.0
- tvOS 17.0
- watchOS 10.0
Android SDK: Not Found
IDEs:
Android Studio: Not Found
Xcode:
version: 15.0.1/15A507
path: /usr/bin/xcodebuild
Languages:
Java:
version: 11.0.20
path: /usr/bin/javac
Ruby:
version: 2.6.10
path: /usr/bin/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.72.7
wanted: 0.72.7
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: true
newArchEnabled: false
Stacktrace or Logs
+ /usr/local/bin/node /Users/maykon/Projects/@maykonmichel/reproducer-react-native/ReproducerApp/node_modules/react-native/scripts/compose-source-maps.js '/Users/maykon/Library/Developer/Xcode/DerivedData/Reproducer_App-dtldhwnsnqvrouhghzexexrpgxnc/Build/Products/Release-iphonesimulator/Reproducer
Reproducer
main.jsbundle.map' '/Users/maykon/Library/Developer/Xcode/DerivedData/Reproducer_App-dtldhwnsnqvrouhghzexexrpgxnc/Build/Products/Release-iphonesimulator/Reproducer App.app/main.jsbundle.map' -o '/Users/maykon/Library/Developer/Xcode/DerivedData/Reproducer_App-dtldhwnsnqvrouhghzexexrpgxnc/Build/Intermediates.noindex/Reproducer App.build/Release-iphonesimulator/Reproducer App.build/DerivedSources/main.jsbundle.map'
node:internal/fs/utils:348
throw err;
^
Error: ENOENT: no such file or directory, open '/Users/maykon/Library/Developer/Xcode/DerivedData/Reproducer_App-dtldhwnsnqvrouhghzexexrpgxnc/Build/Products/Release-iphonesimulator/Reproducer
Reproducer
main.jsbundle.map'
at Object.openSync (node:fs:600:3)
at Object.readFileSync (node:fs:468:35)
at Object.<anonymous> (/Users/maykon/Projects/@maykonmichel/reproducer-react-native/ReproducerApp/node_modules/react-native/scripts/compose-source-maps.js:34:8)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47 {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: '/Users/maykon/Library/Developer/Xcode/DerivedData/Reproducer_App-dtldhwnsnqvrouhghzexexrpgxnc/Build/Products/Release-iphonesimulator/Reproducer\n' +
'Reproducer\n' +
'main.jsbundle.map'
}
Reproducer
https://github.com/maykonmichel/reproducer-react-native
Screenshots and Videos
No response
Duplicates https://github.com/facebook/react-native/issues/41652
@maykonmichel I saw that your PR actually is different than this other one: https://github.com/facebook/react-native/pull/40937 Can you look into it and verify if it solves your issue instead?
Can you look into it and verify if it solves your issue instead?
It doesn't. Actually makes it worse as app is crashing for me.
*** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: Property 'Reproducer' doesn't exist
ReferenceError: Property 'Reproducer' doesn't exist
at global (address at /Users/maykon/Library/Developer/CoreSimulator/Devices/A2F4DE2D-DC69-43A7-B897-744B56C8813E/data/Containers/Bundle/Application/A87E55DB-E847-458E-A806-71BA6CA1DFAF/Reproducer App.app/main.jsbundle:1:13284)', reason: 'Unhandled JS Exception: Property 'Reproducer' doesn't exist
ReferenceError: Property 'Reproducer' doesn't exist
at global (address at /Users/maykon/Library/Developer/Core...'
*** First throw call stack:
(
0 CoreFoundation 0x0000000180491128 __exceptionPreprocess + 172
1 libobjc.A.dylib 0x000000018008412c objc_exception_throw + 56
2 Reproducer App 0x000000010078ed6c RCTFormatError + 0
3 Reproducer App 0x00000001007a4edc __28-[RCTCxxBridge handleError:]_block_invoke + 516
4 libdispatch.dylib 0x00000001010980f0 _dispatch_call_block_and_release + 24
5 libdispatch.dylib 0x000000010109993c _dispatch_client_callout + 16
6 libdispatch.dylib 0x00000001010a95e4 _dispatch_main_queue_drain + 1228
7 libdispatch.dylib 0x00000001010a9108 _dispatch_main_queue_callback_4CF + 40
8 CoreFoundation 0x00000001803f1a30 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
9 CoreFoundation 0x00000001803ec148 __CFRunLoopRun + 1936
10 CoreFoundation 0x00000001803eb5a4 CFRunLoopRunSpecific + 572
11 GraphicsServices 0x000000018e9fbae4 GSEventRunModal + 160
12 UIKitCore 0x00000001852f02e4 -[UIApplication _run] + 868
13 UIKitCore 0x00000001852f3f5c UIApplicationMain + 124
14 Reproducer App 0x0000000100746530 main + 80
15 dyld 0x0000000101011544 start_sim + 20
16 ??? 0x00000001011b60e0 0x0 + 4313538784
17 ??? 0xaf4a000000000000 0x0 + 12630908104913977344
)
libc++abi: terminating due to uncaught exception of type NSException
Reproducible example here.
Re-opening based on last comment.
I had the same issue, but it was a space in the Scheme name that caused the build failure. Removing the space resolved the issue.
This surfaced when migrating from 0.72.6 to 0.73.1. No problems before that.
I had same issue with 0.73.2. To bypass this, I edited my XCode schema name to not have spaces. This of course shouldn't be necessary.
I have spent numerous hours trying to figure out why upgrading to 0.73.2 from 0.71.X was failing. I couldn't build main.jsbundle, i couldn't build the map files either, etc.
Renaming all references of my schema name to a name without spaces resolved this issue. So much time wasted on something that used to work
Just wanted to add that I'm having this issue on 0.72.6. It seems to be the scheme name having a space that causes the issue.
Just wanted to add that I'm having this issue on 0.72.6. It seems to be the scheme name having a space that causes the issue.
I was experiencing the same thing. Renaming the schemes by replacing spaces with hyphens resolved the issue for me.
Fixed by #42220