DataDog / expo-datadog

Datadog SDK for Expo
Apache License 2.0
9 stars 5 forks source link

[iOS] "No bundle URL present." #31

Closed enlightenL closed 8 months ago

enlightenL commented 8 months ago

Describe what happened When you add expo-datadog to plugins of app.json and then do a development build, the following error appears. It works normally in the iPhone simulator and this only happens on the device.

Steps to reproduce the issue:

  1. Install @datadog/mobile-react-native and expo-datadog as dependencies.
  2. Install @datadog/datadog-ci as devDependencies.
  3. Declare DATADOG_APP_KEY and DATADOG_SITE as environment variables, or place a datadog-ci.json file containing appKey and datadogSite properties in the project root.
  4. Add expo-datadog to plugins in app.json and run npx expo run:ios to build.
  5. After a successful build, the app will be installed. And immediately the app opens and an error occurs.

Describe what you expected:

A percent number appears as shown below, and bundling should proceed.

Additional context

app.json

{
  "expo": {
    "name": "expo-datadog-test",
    "slug": "expo-datadog-test",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/images/icon.png",
    "scheme": "myapp",
    "userInterfaceStyle": "automatic",
    "splash": {
      "image": "./assets/images/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "supportsTablet": true,
      "bundleIdentifier": "com.hello.expo-datadog-test"
    },
    "android": {
      "adaptiveIcon": {
        "foregroundImage": "./assets/images/adaptive-icon.png",
        "backgroundColor": "#ffffff"
      }
    },
    "web": {
      "bundler": "metro",
      "output": "static",
      "favicon": "./assets/images/favicon.png"
    },
    "plugins": [
      "expo-router",
      "expo-datadog"
    ],
    "experiments": {
      "typedRoutes": true
    }
  }
}
louiszawadzki commented 8 months ago

Hi @enlightenL,

This issue seems unrelated to our Expo plugin, could you check if the error is solved when you remove "expo-datadog" from the list of expo plugins? Let us know if this is the case.

If not, this might be related to the conditions needed to be able to run the development app on your device. If you are using the same wi-fi network on your device and your computer, restrictions might prevent your device from accessing the bundler. You can see how to bypass this here.

enlightenL commented 8 months ago

@louiszawadzki

If you remove the expo-datadog expo plugin and do a development build, it will be bundled successfully. This issue appears to occur on all iPhones and all network environments. (Actually tested with iPhone 14 and iPhone SE in two network environments.)

Thank you.

+) I ran the command npx expo start --tunnel but it had no effect. 😭

louiszawadzki commented 8 months ago

Hi @enlightenL,

Thanks a lot for your report, I've been able to reproduce the issue and identify a fix.

It might take a few days for it to be released, so in the meantime you can use this patch for @datadog/datadog-ci using patch-package to get unblocked:

diff --git a/node_modules/@datadog/datadog-ci/dist/commands/react-native/xcode.js b/node_modules/@datadog/datadog-ci/dist/commands/react-native/xcode.js
index 95876f7..623d3ef 100644
--- a/node_modules/@datadog/datadog-ci/dist/commands/react-native/xcode.js
+++ b/node_modules/@datadog/datadog-ci/dist/commands/react-native/xcode.js
@@ -236,6 +236,7 @@ class XCodeCommand extends clipanion_1.Command {
             return !!podfileLockContent.match('hermes-engine');
         };
         this.shouldUploadSourcemaps = () => process.env.CONFIGURATION === 'Release' || this.force;
+        this.shouldBundle = () => process.env.CONFIGURATION === 'Release' || this.force || !process.env.PLATFORM_NAME?.match('simulator');
     }
     execute() {
         return __awaiter(this, void 0, void 0, function* () {
@@ -273,13 +274,17 @@ class XCodeCommand extends clipanion_1.Command {
             if (releaseVersion === null || buildVersion === null) {
                 return 1;
             }
-            if (!this.shouldUploadSourcemaps()) {
-                this.context.stdout.write(`Build configuration ${process.env.CONFIGURATION} is not Release, skipping sourcemaps upload`);
-                return 0;
-            }
+
             // Run bundle script
             try {
-                yield this.bundleReactNativeCodeAndImages();
+                if (this.shouldBundle()) {
+                    yield this.bundleReactNativeCodeAndImages();
+                }
+
+                if (!this.shouldUploadSourcemaps()) {
+                    this.context.stdout.write(`Build configuration ${process.env.CONFIGURATION} is not Release, skipping sourcemaps upload`);
+                    return 0;
+                }
                 /**
                  * Because of a bug in React Native (https://github.com/facebook/react-native/issues/34212), the composition
                  * of the 2 Hermes sourcemaps is not done correctly. Therefore we need to do the composition ourselves to

I will let you know in this issue once the release is out.

enlightenL commented 8 months ago

Thank you so much!! @louiszawadzki

The application will run and bundling will proceed successfully.

louiszawadzki commented 8 months ago

Hi @enlightenL,

This has now been fixed in the 2.32.2 release of @datadog/datadog-ci.

I'll close this issue, feel free to reopen it if the issue persists.

enlightenL commented 5 months ago

Hi @louiszawadzki,

It seems like the issue has come back again. This seems to happen in almost all versions of @datadog/datadog-ci (2.32.2 to 2.37.0).

expo: ^51 expo-datadog: ^51.0.0 @datadog/mobile-react-native: ^2.3.5 @datadog/datadog-ci: 2.32.2 to 2.37.0

louiszawadzki commented 5 months ago

cc @marco-saia-datadog