invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.71k stars 2.22k forks source link

Installing wrong React (0.11) while using Podfile #324

Closed ohtangza closed 7 years ago

ohtangza commented 7 years ago
# 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
chrisbianca commented 7 years ago

@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 commented 7 years ago

@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 commented 7 years ago

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 commented 7 years ago

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:

zoontek commented 7 years ago

I made a pull request to start solving this problem.

chrisbianca commented 7 years ago

@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 commented 7 years ago

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

chrisbianca commented 7 years ago

@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 commented 7 years ago

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 commented 7 years ago

@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 commented 7 years ago

@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 commented 7 years ago

Dual instance where exactly?

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

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

zoontek commented 7 years ago

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

ohtangza commented 7 years ago

@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!