DataDog / dd-sdk-reactnative

Datadog SDK for ReactNative
Apache License 2.0
111 stars 39 forks source link

Hybrid [iOS-with-ReactNative] Redefinition of module 'DatadogCore' #683

Open kesavarao-EB opened 1 week ago

kesavarao-EB commented 1 week ago
Screenshot 2024-07-01 at 11 03 09 AM

Describe the issue

We have react-native project and ios project in a seperate repo. iOS already exsists and we have newly created RN repo - All RN code resides in this repo.

iOS app is the main app in which very few screens are based on react-native. These two are integrated using bundle and other.

In iOS repo - DataDog RUM is already instrumented and working fine. In react-native repo - Newly instrumented datadogRUM by installing below

"@datadog/mobile-react-native": "^2.3.5",
        "@datadog/mobile-react-native-navigation": "^2.3.5",
        "@datadog/mobile-react-navigation": "^2.3.5",

Now in iOS repo, we run pod install and opened Xcode

bundle exec pod install
open AttendeeApp.xcworkspace

Issue -

In xocde when building the App, we are getting below error and build is failed. Redefinition of module 'DatadogCore' Redefinition of module 'DatadogRUM' Redefinition of module 'DatadogLogs' Redefinition of module 'DatadogTrace'

![Uploading image.png…]()

Any help pls ?

Thanks

Reproduction steps

In iOS repo - DataDog RUM is already instrumented and working fine. In react-native repo - Newly instrumented datadogRUM by installing below

"@datadog/mobile-react-native": "^2.3.5",
        "@datadog/mobile-react-native-navigation": "^2.3.5",
        "@datadog/mobile-react-navigation": "^2.3.5",

Now in iOS repo, we run pod install and opened Xcode

bundle exec pod install
open AttendeeApp.xcworkspace

SDK logs

No response

Device Information

No response

SDK version

"@datadog/mobile-react-native": "^2.3.5"

Integration Methods

NPM

React Native Version

^0.73.4

Package.json Contents

In react-native repo, part of package.json is

"dependencies": { "@datadog/mobile-react-native": "^2.3.5", "@datadog/mobile-react-native-navigation": "^2.3.5", "@datadog/mobile-react-navigation": "^2.3.5", "@types/react-native": "^0.73.0", "react": "18.2.0", "react-native": "^0.73.4", "react-native-code-push": "^8.2.1", }

iOS Setup

In pod file, included

pod 'DatadogSDKObjc', '~> 2.5.0'

Android Setup

No response

Other relevant information

No response

marco-saia-datadog commented 1 week ago

Hello @kesavarao-EB 👋 thank you for reaching out!

I believe the errors are caused by two different versions of the iOS Datadog SDK being installed on the same project.

React Native SDK v2.3.5 is shipped with iOS v2.7.1.

I would try to update the iOS pod to exactly v2.7.1 and see if the issues are resolved, by updating your podfile:

pod 'DatadogSDKObjc', '2.5.0'
kesavarao-EB commented 1 week ago

Thankyou for checking @marco-saia-datadog

yes i have updated podfile

pod 'DatadogSDKObjc', '2.7.1'

and executed the below

bundle exec pod install
open AttendeeApp.xcworkspace

But still the same error i see in the simulator. Build is failing

image

@marco-saia-datadog Why we need to added pod 'DatadogSDKObjc', '2.7.1' in iOS repo when We already have defined "@datadog/mobile-react-native": "^2.3.5", in react-native repo ?

marco-saia-datadog commented 1 week ago

The dependency has to be added in order to use the iOS SDK functionalities from your iOS layer.

Please:

kesavarao-EB commented 6 days ago

@marco-saia-datadog I tried in the new setup, still the same error

yes , version is 2.7.1in node_modules/@datadog/mobile-react-native/DatadogSDKReactNative.podspec

image

Also executed these steps

image

Would you mind confirming if any steps are missing in this doc (Native app with RN screens) which i am following https://github.com/DataDog/dd-sdk-reactnative/blob/main/docs/hybrid_applications.md#:~:text=Native%20apps%20with%20React%20Native%20screens%3A%20Initialize%20the%20SDK%20on%20the%20native%20side

Also in the example repo, i dont see addition of this line in podfile

pod 'DatadogSDKObjc', '2.5.0'

https://github.com/DataDog/dd-sdk-reactnative-examples/blob/931ce96fde92cb3093c518049450ff81850550ef/ios-app-with-rn/ios/Podfile

Any help on this ?

marco-saia-datadog commented 6 days ago

@kesavarao-EB thank you for your patience 🙏

I believe our documentation might be outdated, we will verify that the instructions are still relevant to this day.

In the meantime, have you tried removing the pod from your Podfile?

If you can access Datadog SDK classes from your codebase, without manually adding the pod to your Podfile, the setup is correct and the SDK will function properly.

kesavarao-EB commented 5 days ago

@marco-saia-datadog Still the same. In the clean setup just added the following

Step 1) iOS Repo :

yarn add @datadog/mobile-react-native

Clarification : I doubt if this will be required. Because we already have DataDog iOS sdk installed . After running @datadog/mobile-react-native and pod installing will install the below.

Installing DatadogCore 2.7.1 
Installing DatadogCrashReporting (2.7.1)
Installing DatadogInternal 2.7.1 
Installing DatadogLogs 2.7.1
Installing DatadogRUM 2.7.1
Installing DatadogSDKReactNative 
Installing DatadogTrace 2.7.1
Installing DatadogWebViewTracking 
Installing PLCrashReporter 

This may have possibility to get conflict with the exsiting DatadogCore and other which got installed with DataDogiOS-sdk.

Step 2 - cd to ios

bundle exec pod install
open AttendeeApp.xcworkspace

Still the same issue. Sorry, is this working in your environment . Or am i missing any steps ?

image

Can you provide the working steps ?

marco-saia-datadog commented 3 days ago

If I understand correctly, you have Datadog iOS SDK installed in your native project already.

Have you checked that the native version of the iOS SDK matches the version defined in node_modules/@datadog/mobile-react-native/DatadogSDKReactNative.podspec?

If it does, and you encounter the same issue, you might then have to patch the SDK, with our support.

This issue could be currently blocking https://github.com/DataDog/dd-sdk-reactnative/issues/682.