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

Installing wrong React (0.11) while using Podfile #324

Closed
ohtangza opened this issue Aug 10, 2017 · 14 comments
Closed

Installing wrong React (0.11) while using Podfile #324

ohtangza opened this issue Aug 10, 2017 · 14 comments

Comments

@ohtangza
Copy link

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'

target 'mimiking' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for mimiking
  target 'mimikingTests' do
    inherit! :search_paths
    # Pods for testing
  end

  pod 'Firebase/Core'
  pod 'RNFirebase', :path => '../node_modules/react-native-firebase', :exclude => ['React']

  pod 'Firebase/Auth'
  pod 'Firebase/Analytics'
  # pod 'Firebase/AppIndexing'
  pod 'Firebase/Crash'
  pod 'Firebase/Database'
  pod 'Firebase/DynamicLinks'
  pod 'Firebase/Messaging'
  pod 'Firebase/RemoteConfig'
  pod 'Firebase/Storage'

  pod 'Intercom'

end

I am not using React with Pod. When I tried to run pod install, it automatically installs React (0.11) as the screenshot below says.

screen shot 2017-08-10 at 2 02 44 pm

If I include the React within Podfile, it shows an error during the archiving process. During development, it does not output the error even if I install the React twice in my project file and Podfile.

screen shot 2017-08-10 at 2 35 00 pm

Do you think we can remove React dependency in podspec (https://github.com/invertase/react-native-firebase/blob/master/RNFirebase.podspec)? I was searching if I could conditionally exclude the React dependency to be installed., but had no luck. If it's okay, I might make a pull request for it.

Environment

  1. Target Platform (e.g. iOS, Android): iOS
  2. Development Operating System (e.g. macOS Sierra, Windows 10): macOS Sierra
  3. Build tools (Xcode or Android Studio version, iOS or Android SDK version, if relevant): Xcode
  4. React Native version (e.g. 0.45.1): 0.44.1
  5. RNFirebase Version (e.g. 2.0.2): 2.1.0
@ohtangza ohtangza changed the title It keeps installing React (0.11) while using Podfile Installing wrong React (0.11) while using Podfile Aug 10, 2017
@chrisbianca
Copy link
Contributor

@ohtangza I've just tried this with a brand new project set up in the way we recommend, with React referenced in the Podfile AND linked manually in Xcode, but am not getting the duplicate symbols error that you mention. React is included in the Podfile to prevent other compilation issues that mean you wouldn't necessarily even get this far in the process so we're not in a position to remove it.

When you add React to the Podfile, which subspecs do you include? The ones we list, or some additional ones?

Xcode is notoriously bad at cleaning projects when things change outside them, e.g. a Pod is added/removed and pod install is run. I would suggest that you:

  1. Add the Pod back in as detailed in the installation instructions
  2. Run pod install
  3. Run Product > Clean in Xcode
  4. Restart Xcode
  5. Re-run Product > Clean
  6. Try to archive the project

@ohtangza
Copy link
Author

@chrisbianca Oh, in my project, I also added other subspecs which seem to be unnecessary. I'll try with more cleaner setting and keep you updated. Always thanks for your responsiveness :)

@ohtangza
Copy link
Author

With only React - Core installed, it works without any critical issue now. Don't you have any warning like below?

This warning is caused by a @providesModule declaration with the same name across two different files.
jest-haste-map: @providesModule naming collision:
  Duplicate module name: RCTEventEmitter
  Paths: /Users/ohtangza/Workspace/mimiking-rn/node_modules/react-native/Libraries/EventEmitter/RCTEventEmitter.js collides with /Users/ohtangza/Workspace/mimiking-rn/ios/Pods/React/Libraries/BatchedBridge/BatchedBridgedModules/RCTEventEmitter.js

@zoontek
Copy link
Contributor

zoontek commented Aug 10, 2017

Same here. I don't want to install React using Cocoapods. It is not suited for a react-native project (double references!), only for hybrid projects including some react-native views (http://facebook.github.io/react-native/releases/0.47/docs/integration-with-existing-apps.html#configuring-cocoapods-dependencies)

The best way to install a react-native library should be:

In a react-native project

platform :ios, '8.0'

target 'app' do
  pod 'Firebase/Core'

  # Optional Firebase libs
  pod 'Firebase/Auth'
  # ...
end

AND a react-native link react-native-firebase

In a non react-native project

platform :ios, '8.0'

target 'app' do
  pod 'Yoga', :path => '../../node_modules/react-native/ReactCommon/yoga/Yoga.podspec'
  pod 'React', path: '../../node_modules/react-native', :subspecs => [
    'Core',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket',
    'BatchedBridge'
  ]

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

  pod 'Firebase/Core'

  # Optional Firebase libs
  pod 'Firebase/Auth'
  # ...
end

So, to make this library install work correctly, it will be needed to:

  • Remove the deprecated React dependency in the Podspec
  • Fix the react-native link install

@zoontek
Copy link
Contributor

zoontek commented Aug 10, 2017

I made a pull request to start solving this problem.

@chrisbianca
Copy link
Contributor

@zoontek react-native link is not flexible enough for our needs across both iOS and Android which is why we aren't using it. Due to the way that Firebase is broken down into modules and the fact we want to support the same approach, a manual setup is favourable and causes less issues.

Fixing react-native link for RNFirebase is by no means trivial as there is no documentation for react-native link from a module developers point of view (or none that we have been able to find).

Trust me, we take the setup of the library very seriously and have experimented with each of the different approaches, but our current approach is by far the most reliable we have found so far.

We will take another look at this, but in the meantime we cannot remove the React podspec dependency as this fixes other issues that were present without the library being there.

As an aside, Cocoapods is perfectly suited to a React Native project - I am using it for both my large scale RN apps as I have found it far more reliable than react-native link, albeit with a bit more manual setup. Why Facebook didn't build RN around Cocoapods on the iOS side I have no idea.

@zoontek
Copy link
Contributor

zoontek commented Aug 10, 2017

@chrisbianca So can you please update the documentation to avoid the double React compilation? It's currently a serious problem.

@chrisbianca
Copy link
Contributor

@zoontek I'm confused. If you follow the instructions then there is no double React compilation problem. The issue here came because subspecs that weren't listed in our instructions were added?

@zoontek
Copy link
Contributor

zoontek commented Aug 10, 2017

My current setup is the following.
It result in a huge mess with double references, double logs, etc.

source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '9.2'

target 'mobile' do
  pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga/Yoga.podspec'
  pod 'React', path: '../node_modules/react-native', :subspecs => [
    'Core',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket',
    'BatchedBridge'
  ]

  # ...

  pod 'RNFirebase', :path => '../node_modules/react-native-firebase'
  pod 'Firebase/Core'
  pod 'Firebase/Auth'
  pod 'Firebase/Messaging'
  pod 'Firebase/RemoteConfig'
end

screen shot 2017-08-10 at 12 13 14

screen shot 2017-08-10 at 12 13 48

@chrisbianca
Copy link
Contributor

@zoontek Which is not the setup we recommend. You can do one of 2 things:

  1. Have all the subspecs in the Podfile, and remove the linked libraries within Xcode
  2. Just include the Core and BatchedBridge subspecs in the Podfile, remove the other, but keep the linked libraries within XCode

@zoontek
Copy link
Contributor

zoontek commented Aug 10, 2017

@chrisbianca I finally success to make it worked.

I 1) just include the Core and BatchedBridge subspecs in the Podfile, remove the other, but keep the linked libraries within XCode 2) Remove libReact.a from Linked Frameworks and Librairies\

EDIT: It still doesn't work on my iPhone, only on the simulator.

screen shot 2017-08-10 at 15 49 45

(dual instance :( )

@chrisbianca
Copy link
Contributor

Dual instance where exactly?

As an aside, I have submitted a PR to React Native to hopefully allow us to use react-native link: facebook/react-native#15451

However, based on previous records, this might not land in React Native for quite a while

@zoontek
Copy link
Contributor

zoontek commented Aug 10, 2017

My bad, it was due to something else (I had two dev menus). I close the PR :)

@ohtangza
Copy link
Author

@chrisbianca I think there is no critical issue for now. I cleaned everything again and then left only two libraries required for this library. With React installed on my Xcode project and Pod Project, it works well now. Thanks for your response!

jimmybaker added a commit to jimmybaker/react-native-blur that referenced this issue Aug 28, 2018
With this dependency present, people cannot install this using Cocoapods. It attempts to install React 0.11.0. Adding a pod line for React in the podfile is not a good idea for people who started their projects with `react-native init` because you'll get double references to the same files. See the following issues:

invertase/react-native-firebase#324
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants