Closed ohtangza closed 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
@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 :)
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
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:
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
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:
React
dependency in the Podspecreact-native link
installI made a pull request to start solving this problem.
@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.
@chrisbianca So can you please update the documentation to avoid the double React compilation? It's currently a serious problem.
@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?
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
@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
@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.
(dual instance :( )
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
My bad, it was due to something else (I had two dev menus). I close the PR :)
@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!
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.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.
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