Open djinely opened 10 months ago
Hi @djinely, thanks for reaching out!
This error means that your project.pbxproj
file was in an incorrect state when trying to run this step. Usually the reason for this is that a previous step altered it in a wrong way.
Could you share what changes you see in git in this file after running the wizard (git diff ios/**/project.pbxproj
)?
Thanks a lot!
Hi @louiszawadzki and thanks for the quick reply. Attached a screenshot and also text version if it makes it easier to work with.
shellScript = "export SENTRY_PROPERTIES=sentry.properties\nexport EXTRA_PACKAGER_ARGS=\"--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map\"\nif [[ -f \"$PODS_ROOT/../.xcode.env\" ]]; then\n source \"$PODS_ROOT/../.xcode.env\"\nfi\nif [[ -f \"$PODS_ROOT/../.xcode.env.local\" ]]; then\n source \"$PODS_ROOT/../.xcode.env.local\"\nfi\n\n# The project root by default is one level up from the ios directory\nexport PROJECT_ROOT=\"$PROJECT_DIR\"/..\n\nif [[ \"$CONFIGURATION\" = *Debug* ]]; then\n export SKIP_BUNDLING=1\nfi\nif [[ -z \"$ENTRY_FILE\" ]]; then\n # Set the entry JS file using the bundler's entry resolution.\n export ENTRY_FILE=\"$(\"$NODE_BINARY\" -e \"require('expo/scripts/resolveAppEntry')\" $PROJECT_ROOT ios relative | tail -n 1)\"\nfi\n\n
node --print \"require.resolve('@sentry/cli/package.json').slice(0, -13) + '/bin/sentry-cli'\"react-native xcode --force-foreground
\"$NODE_BINARY\" --print \"require('path').dirname(require.resolve('react-native/package.json')) + '/scripts/react-native-xcode.sh'\"\n\n";
shellScript = "export SENTRY_PROPERTIES=sentry.properties\nexport EXTRA_PACKAGER_ARGS=\"--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map\"\nif [[ -f \"$PODS_ROOT/../.xcode.env\" ]]; then\n source \"$PODS_ROOT/../.xcode.env\"\nfi\nif [[ -f \"$PODS_ROOT/../.xcode.env.local\" ]]; then\n source \"$PODS_ROOT/../.xcode.env.local\"\nfi\n\n# The project root by default is one level up from the ios directory\nexport PROJECT_ROOT=\"$PROJECT_DIR\"/..\n\nif [[ \"$CONFIGURATION\" = *Debug* ]]; then\n export SKIP_BUNDLING=1\nfi\nif [[ -z \"$ENTRY_FILE\" ]]; then\n # Set the entry JS file using the bundler's entry resolution.\n export ENTRY_FILE=\"$(\"$NODE_BINARY\" -e \"require('expo/scripts/resolveAppEntry')\" $PROJECT_ROOT ios relative | tail -n 1)\"\nfi\n\n
node --print \"require.resolve('@sentry/cli/package.json').slice(0, -13) + '/bin/sentry-cli'\"react-native xcode --force-foreground
\"$NODE_BINARY\" --print \"require('path').dirname(require.resolve('react-native/package.json')) + '/scripts/react-native-xcode.sh'\"\n\n";REACT_NATIVE_XCODE=\"./datadog-sourcemaps.sh\"\nexport SOURCEMAP_FILE=$DERIVED_FILE_DIR/main.jsbundle.map\nundefinedREACT_NATIVE_XCODE=\"./datadog-sourcemaps.sh\"\nexport SOURCEMAP_FILE=$DERIVED_FILE_DIR/main.jsbundle.map\nundefinedREACT_NATIVE_XCODE=\"./datadog-sourcemaps.sh\"\nexport SOURCEMAP_FILE=$DERIVED_FILE_DIR/main.jsbundle.map\nundefined
Hi @djinely, thanks for your quick answer.
From your feedback I understand your app is an expo project that you have ejected, is this correct? If you haven't ejected your expo app, you can still use Datadog with the expo dev client and expo-datadog
: https://docs.datadoghq.com/real_user_monitoring/mobile_and_tv_monitoring/setup/expo/
If you've already ejected, I will guide you through automating symbols files upload to Datadog as unfortunately the wizard does not support this scenario yet.
You need to add @datadog/datadog-ci
to your dev dependencies:
yarn add -D @datadog/datadog-ci
or
npm install --save-dev @datadog/datadog-ci
As you already upload symbols to Sentry, the easiest way to upload sourcemaps on iOS to Datadog is to run the RN bundle script twice. To do so:
xed -b ios
from your app directory)At the very end of the script, add the 2 following lines:
export SOURCEMAP_FILE=$DERIVED_FILE_DIR/main.jsbundle.map
../node_modules/.bin/datadog-ci react-native xcode `"$NODE_BINARY" --print "require('path').dirname(require.resolve('react-native/package.json')) + '/scripts/react-native-xcode.sh'"`
At this point you should check that your app is still building on iOS before moving on to the next steps.
In your android/app/build.gradle
file, add the following after the apply from: "../../node_modules/react-native/react.gradle"
line:
apply from: "../../node_modules/@datadog/mobile-react-native/datadog-sourcemaps.gradle"
In your Xcode build phases, click on the "+" to create a "New Run Script Phase":
You can rename the phase "Upload dSYMs to Datadog" and set the following code as the script:
set -e
../node_modules/.bin/datadog-ci dsyms upload $DWARF_DSYM_FOLDER_PATH --config="../datadog-ci.json"
Proguard obfuscation is not enabled by default on RN projects. To check if this is the case and to upload your mapping file you can refer to our official documentation.
For the upload to work, you need to provide your Datadog API key. Create a datadog-ci.json
file at the root of your project containing the API key:
{
"apiKey": "<YOUR_DATADOG_API_KEY>"
}
You can also specify the Datadog site (such as datadoghq.eu) as a DATADOG_SITE
environment variable, or as a datadogSite
key in your datadog-ci.json
file.
Let me know if that works for you! I will also add a task for the wizard to be able to skip some tasks in case of failure :)
@louiszawadzki we haven't ejected Expo. I followed the expo-datadog and added it as a plugin accordingly. I also initialized a build to see if it's uploading the source maps. Are those being uploaded on any type of build? only distribution builds? Is there anyway to confirm uploads on dashboard?
Thanks again for the quick reply. I think the content of your reply will be very useful as part of your documentation/readme.
Hi @djinely, if you haven't ejected Expo you should NOT use datadog-react-native-wizard
.
The expo-datadog
config plugin is already taking care of automating the upload of mapping files when the ios/
and android/
folders of your app are generated by Expo during the build.
You can refer to our documentation for testing that the mapping files upload works.
👋 I'm facing the same issue, the fix steps on this thread works for my setup too
When I run the wizard, it does generate the datadog-sourcemaps.sh
file
project.pbxproj
changes (broken)
- shellScript = "export NODE_BINARY=node\nexport SENTRY_PROPERTIES=$SENTRY_PROPERTIES_FILE_NAME.properties\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\nSENTRY_XCODE=\"../node_modules/@sentry/react-native/scripts/sentry-xcode.sh\"\nBUNDLE_REACT_NATIVE=\"/bin/sh $SENTRY_XCODE $REACT_NATIVE_XCODE\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT \\\"$BUNDLE_REACT_NATIVE\\\"\"\n";
+ shellScript = "export NODE_BINARY=node\nexport SENTRY_PROPERTIES=$SENTRY_PROPERTIES_FILE_NAME.properties\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\nSENTRY_XCODE=\"../node_modules/@sentry/react-native/scripts/sentry-xcode.sh\"\nBUNDLE_REACT_NATIVE=\"/bin/sh $SENTRY_XCODE $REACT_NATIVE_XCODE\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT \\\"$BUNDLE_REACT_NATIVE\\\"\"\n";REACT_NATIVE_XCODE=\"./datadog-sourcemaps.sh\"\nexport SOURCEMAP_FILE=$DERIVED_FILE_DIR/main.jsbundle.map\nundefined
Deps:
"react-native": "0.75.4", "expo": "51.0.38", "@datadog/mobile-react-native": "2.4.4", "@datadog/datadog-ci": "2.45.0", "@sentry/react-native": "5.33.2",
Xcode 15.4
Expo Project: No
Question:
Expo Configure Project step is part of my build phase, does this mean we have to configure the datadog/expo-config plugin?
Describe what happened running
npx datadog-react-native-wizard
got this error:Steps to reproduce the issue: 📝
Expected behaviour: 📝
Actual behaviour: 📝
Additional context
Node version: 16.19.0 / 18.13.0
react-native version: 0.70.8
@datadog/react-native-wizard version: 0.3.0
@datadog/mobile-react-native version: 2.0.1
an explanation of what might cause the bug and/or how it can be fixed