Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kesavarao-EB opened this issue Jul 1, 2024 · 9 comments
Open
Labels

Comments

@kesavarao-EB
Copy link

kesavarao-EB commented Jul 1, 2024

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
Copy link
Member

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
Copy link
Author

kesavarao-EB commented Jul 1, 2024

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
Copy link
Member

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

Please:

  • Double check that 2.7.1 is also the version you see in node_modules/@datadog/mobile-react-native/DatadogSDKReactNative.podspec
  • Clean-up iOS project (cd ios && rm -rf Pods && rm Podfile.lock && pod install --repo-update)
  • Re-build your project and try again

@kesavarao-EB
Copy link
Author

kesavarao-EB commented Jul 2, 2024

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

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

Also executed these steps

  • Clean-up iOS project (cd ios && rm -rf Pods && rm Podfile.lock && pod install --repo-update)
  • Re-build your project and try again
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
Copy link
Member

@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
Copy link
Author

kesavarao-EB commented Jul 3, 2024

@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
Copy link
Member

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 #682.

@kesavarao-EB
Copy link
Author

Both has same version 2.7.1
Still can see same error.
Can you confirm if this example project is working ?
https://github.com/DataDog/dd-sdk-reactnative-examples/tree/931ce96fde92cb3093c518049450ff81850550ef/ios-app-with-rn as we have closely followed this for initialization.

@marco-saia-datadog
Copy link
Member

@kesavarao-EB I am updating the example project and verifying that everything is working properly. I will get back to you soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants