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

React (0.11.0) is being added as a dependency for ios, creating conflicts. #925

Closed
5 of 11 tasks
eyaydin opened this issue Jun 10, 2020 · 13 comments
Closed
5 of 11 tasks
Labels
dependencies Pull requests that update a dependency file Platform: Cocoa

Comments

@eyaydin
Copy link

eyaydin commented Jun 10, 2020

OS:

  • Windows
  • MacOS
  • Linux

Platform:

  • iOS
  • Android

SDK:

  • @sentry/react-native (>= 1.0.0)
  • react-native-sentry (<= 0.43.2)

SDK version: 1.4.5

react-native version: 0.59.10

Are you using Expo?

  • Yes
  • No

Are you using sentry.io or on-premise?

  • sentry.io (SaaS)
  • on-premise

If you are using sentry.io, please post a link to your issue so we can take a look:

none

Configuration:

(@sentry/react-native)

Sentry.init({
  dsn: 'https://[email protected]/...'
  // no other options
});

I have following issue:

After running react-native link @sentry/react-native and cd ios && pod install, Podfile.lock has this content:

PODS:
  - React (0.11.0):
    - React/Core (= 0.11.0)
  - React/Core (0.11.0)
  - RNSentry (1.4.5):
    - React
    - Sentry (~> 5.1.4)
  - Sentry (5.1.4):
    - Sentry/Core (= 5.1.4)
  - Sentry/Core (5.1.4)

Which is problematic since React 0.11.0 is too old to be supported. This creates a build error which is explained in #895 .

Steps to reproduce:

  • react-native init AwesomeProject --version 0.59.10
  • npm install @sentry/react-native --save
  • cd ios && pod init
  • cd .. && react-native link @sentry/react-native
  • cd ios && pod install
  • react-native run-ios

Actual result:

info /Users/.../.../.../rn_testing/AwesomeProject/node_modules/@sentry/react-native/ios/RNSentry.m:64:38: error: too many arguments to block call, expected 1, have 3

info         reject(@"SentryReactNative", error.localizedDescription, error);
        ~~~~~~                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

info /Users/.../.../.../rn_testing/AwesomeProject/node_modules/@sentry/react-native/ios/RNSentry.m:143:38: error: too many arguments to block call, expected 1, have 3
        reject(@"SentryReactNative", @"Cannot serialize event", nil);
        ~~~~~~                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

info 2 errors generated.

And at the same time, metro gives this error:

UnhandledPromiseRejectionWarning: Error: jest-haste-map: Haste module naming collision: Duplicate module name: react-native Paths: /Users/.../.../.../.../ios/Pods/React/package.json collides with /Users/.../.../.../.../node_modules/react-native/package.json

Expected result:

The app should work on Simulator.

What I have tried:
I wrote comments in #895 but since its a closed issue I am going to copy-paste here as well.

I changed RNSentry.podspec in @sentry/react-native to look for specifically my installed version of React. i.e:
s.dependency 'React' to s.dependency 'React', '0.59.10'. When I do this the Podfile.lock sees React and React related dependencies as 0.59.10. This approach successfully builds but fails when I try to run because of duplicate resources. i.e:

Class RCTWebSocketModule is implemented in both /Users/.../Library/Developer/CoreSimulator/Devices/90D0534D-6CED-42AC-9B6E-218E2B603ABC/data/Containers/Bundle/Application/290ADA55-F4BB-4D47-86DD-D4352C218625/APPNAME/Frameworks/React.framework/React (0x102c44a30) and /Users/.../Library/Developer/CoreSimulator/Devices/90D0534D-6CED-42AC-9B6E-218E2B603ABC/data/Containers/Bundle/Application/290ADA55-F4BB-4D47-86DD-D4352C218625/APPNAME/APP (0x1025daab8). One of the two will be used. Which one is undefined.

I also tried some of the old versions of @sentry/react-native.

@jennmueng
Copy link
Member

Hmm that is interesting, I can't seem to reproduce this issue.

But I'm on React Native version 0.61.3 where you would just use the sentry-wizard and not call react-native link. I tried calling react-native link manually and then pod-install but the correct version of React is there in the Podfile.lock

@benanderman
Copy link

benanderman commented Jun 11, 2020

I'm also experiencing this, upgrading from react-native-sentry to @sentry/react-native. My only changes to Podfile were the addition of this line (added by react-native link @sentry/react-native):
pod 'RNSentry', :path => '../node_modules/@sentry/react-native'

But then when I do pod install, I get these new lines:

Installing RNSentry (1.4.5)
Installing React (0.11.0)
Installing Sentry (5.1.4)

And at the end, [!] React has been deprecated.

One interesting thing is that I successfully upgraded back in I think January, but then downgraded again because of the issue with native crashes not getting any context added. So it seems like this is probably a recently added issue, somehow. EDIT: I take back the part about it probably being recent, given that the dependency on React in the Sentry podspec has never changed.

This only changes to my package.json are:

-      "<rootDir>/node_modules/(?!(react-native.*|@react-native-community.*|react-navigation.*|@react-navigation.*)/)"
+      "<rootDir>/node_modules/(?!(react-native.*|@react-native-community.*|react-navigation.*|@react-navigation.*|@sentry/react-native)/)"

and

-    "react-native-sentry": "^0.43.2",
+    "@sentry/react-native": "^1.4.5",

EDIT: My conclusion here, is that, being on React Native 0.59.9, I don't want to use React* through CocoaPods, which means not using Sentry through CocoaPods (since it depends on React Native). However, sentry-react-native no longer appears to work when linked manually, because this commit removed the Sentry submodule inside ios/ (the first change here):
6c3d4cf

@marandaneto marandaneto added Platform: Cocoa dependencies Pull requests that update a dependency file labels Jun 14, 2020
@eyaydin
Copy link
Author

eyaydin commented Jun 17, 2020

Any updates on this issue? This is a huge block on our way to integrate sentry to our product.

@pedroferreira1
Copy link

I was having the same problem with React Native 0.59.9. My Podfile had only Sentry and it was installing exactly as @benanderman described:

Installing RNSentry (1.4.5)
Installing React (0.11.0)
Installing Sentry (5.1.4)

Podfile

target 'Target' do
  pod 'RNSentry', :path => '../node_modules/@sentry/react-native'
end

I had to manually add some lines in this podfile (for react and some dependencies) and everything worked fine. My Podfile now is:

target 'Target' do
  pod 'RNSentry', :path => '../node_modules/@sentry/react-native'

  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'CxxBridge',
    'DevSupport',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTBlob',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket'
  ]

  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

end

Even though things are working fine now with this change I don't think Sentry should be installing React 0.11.

@eyaydin
Copy link
Author

eyaydin commented Jul 2, 2020

@pedroferreira1 I've already done that and unfortunately this doesn't work quite right. It builds and runs successfully but on start I am getting a popup that says "Warning, could not connect to Sentry native SDK...".
Sentry catches JS errors and I can see them on dashboard but native errors are not being handled obviously.

@eyaydin
Copy link
Author

eyaydin commented Jul 2, 2020

This is what it looks like on Xcode when I open .xcworkspace:

Screen Shot 2020-07-02 at 16 34 07

@pedroferreira1
Copy link

@eyaydin do you see this popup here?
image

Did you try this solution here #670 (comment)? It looks like a linking problem with your lib.

My Podfile has some differences from yours. I've removed the use_frameworks! line and I don't add DoubleConversion and glog in my Podfile. I don't know if this could change anything but you could try to change and pod deintegrate and pod install.

@eyaydin
Copy link
Author

eyaydin commented Jul 3, 2020

Yes I've tried everything including #670 (comment) but didn't work.

My podfile includes DoubleConversion and glog because I am using react-native version 0.59.10. I get build errors if I don't add them.

use_frameworks! is required for our main project but I am going to remove it in my test project to see if it works.

@jennmueng
Copy link
Member

Have you tried running

pod repo update
# then
pod install

?

This just looks like you guys have outdated repos because I've been investigating this and I don't see anything that could cause this on our side.

@hash9
Copy link

hash9 commented Jul 4, 2020

@jennmueng Tried removing and reinstalling for pods, node modules, lock files multiple times but the issue persists. Its a huge blocker for months now. Also tried with latest sentry version for react native i.e 1.4.5. Please try creating and integrating sentry on react native 59.9 and below

@jennmueng
Copy link
Member

jennmueng commented Jul 7, 2020

@jennmueng Tried removing and reinstalling for pods, node modules, lock files multiple times but the issue persists. Its a huge blocker for months now. Also tried with latest sentry version for react native i.e 1.4.5. Please try creating and integrating sentry on react native 59.9 and below

I have and haven't run into this issue before.

It's definitely not an issue with the @sentry/react-native package as other react-native packages also have the same React dependency as we do.

Here:

s.dependency 'React'

Examples of this in Other Packages:
https://github.com/react-native-community/react-native-maps/blob/26b5d06f950385e921ea828642db964d8db5216e/react-native-maps.podspec#L18
https://github.com/react-native-community/lottie-react-native/blob/09afe4fa82797fe85a2155186a0cfa1fa48b082a/lottie-react-native.podspec#L18

I understand the frustration though, you can try manually setting the React dependency in the pod specs to the exact React Native version you're using, either by forking the repo or using a package patching library like patch-package.

@eyaydin
Copy link
Author

eyaydin commented Jul 7, 2020

@jennmueng

pod repo update
# then
pod install

does not work.

But I can confirm that adding React and related packages to podfile (which I shared here) and then removing the !use_frameworks successfully runs as @pedroferreira1 suggested.

@jennmueng
Copy link
Member

jennmueng commented Jul 18, 2020

Ok I actually finally replicated this issue.

This is caused by cocoa pods being unable to find the correct source for the React package. As the React package isn't hosted on cocoapods, you would need to explicitly state that this pod to be taken from your local react-native installation in your node_modules by adding this line to your Podfile:

 pod 'React', :path => '../node_modules/react-native/'

Also note that this line needs to be before any library (like Sentry) that depends on React.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file Platform: Cocoa
Projects
None yet
Development

No branches or pull requests

6 participants