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

Too much reliance on Cocoapods, currently problematic with RN #195

Closed
SamMatthewsIsACommonName opened this issue Jun 22, 2017 · 22 comments
Closed

Comments

@SamMatthewsIsACommonName
Copy link
Contributor

SamMatthewsIsACommonName commented Jun 22, 2017

OK so I see the appeal of using cocoapods, but I think having spend 11 hours dealing with this and still unable to get the project to build, that I kind of liked the old way that used cocoapods minimally to install the firebase dependencies (and not having to install any React related pods), and then importing the library and linking it. I understand there were problems using react-native link and the podfile not being generated correctly, but using the completely manual method this seemed quite solid and didn't seem to be affected by cocoapods versions, caches etc...

Basically from a fresh RN install (0.45.1) I'm trying to add the React pods:

pod "Yoga", :path => "../node_modules/react-native/ReactCommon/yoga"

pod 'React', :path => '../node_modules/react-native', :subspecs => [
'Core',
'BatchedBridge',
]

which quickly turns into this problem:

facebook/react-native#13010

So then I try using CxxBridge as well, like this:

pod "Yoga", :path => "../node_modules/react-native/ReactCommon/yoga"

pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'GLog', :podspec => '../node_modules/react-native/third-party-podspecs/GLog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

pod 'React', :path => '../node_modules/react-native', :subspecs => [
'Core',
'BatchedBridge',
'CxxBridge',
]

Which leads down another path of build errors, this time something to do with Math.h:

screen shot 2017-06-22 at 23 19 59

I guess my point is RN and Cocoapods don't seem to be an entirely stable combination, whereas the old way of manually installing the library (not react-native link, but actually importing the library etc) seemed very solid.

Would be interested to hear thoughts on this. Cheers

@D1no
Copy link
Contributor

D1no commented Jun 23, 2017

Well, I have a different view. I think it is very important to not touch much of the native side of react-native. Especially linking and adding libraries manually to the xcode workspace/project. The react-native packager has quite a lot of hardcoded magic behind the scenes that can get you quickly into trouble.

I am not sure what you do there with your pod file. DoubleConversion and stuff like that are sub projects of the core & batchedbridge. The error message you have there also leads to the assumption that you messed quite in the xcode project around. Or even start the project not from the yourapp.xcworkspace file but instead still try to run the *.xcodeproj. Which is a big NO-NO with Cocoa Pods.

I.e. our pod file looks like this, which works just fine with react native 0.45.1

platform :ios, '9.0'

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

  pod "Yoga", :path => "../node_modules/react-native/ReactCommon/yoga"
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'BatchedBridge', # Required For React Native 0.45.0+
    'Core',
    # Add any other subspecs you want to use in your project
  ]

  # Required by RNFirebase
  pod 'Firebase/Core'
  pod 'RNFirebase', :path => '../node_modules/react-native-firebase'

  # [OPTIONAL PODS] - comment out pods for firebase products you won't be using.
  # pod 'Firebase/AdMob'
  pod 'Firebase/Analytics'
  pod 'Firebase/Auth'
  pod 'Firebase/Crash'
  pod 'Firebase/Database'
  pod 'Firebase/DynamicLinks'
  pod 'Firebase/Messaging'
  pod 'Firebase/RemoteConfig'
  pod 'Firebase/Storage'

  # Required by Code-Push
  pod 'CodePush', :path => '../node_modules/react-native-code-push'
end

I'd advice you to init a fresh react-native project, copy the ios folder and copy it over to work towards a clean setup. I often see engineers new to react-native to try to fix xcode error messages shorthand; googling their way to stack overflow answers that suggest to add library/file xyz manually to get over that error. In fact its often better to take a step back and see why it's not automatically done. Their is often a more simple mistake up in the chain that lead to that particular error message.

Anything else will just lead you to dig yourself a hole. Therefore, i.e. pods are the right way take this risk away.

@SamMatthewsIsACommonName
Copy link
Contributor Author

SamMatthewsIsACommonName commented Jun 23, 2017

Hi @D1no , I've been working with init and clean setups as I said for over a day now and within the workspace files (I'm very familiar with cocoapods as I worked on native before starting RN, I'm also familiar with how flaky it can be based on versions etc), however encountering many known issues. The build of version 0.45.0 + is unstable with init:
facebook/react-native#14447
facebook/react-native#14461

And the solution in most cases was to init at version 0.44.x

This then led to problems with the pods. Once I did manage to get to version 0.45.+ I then encountered this issue:
facebook/react-native#13010
Which for me persisted even when I added 'BatchedBridge'.
I then tried adding 'CxxBridge', which due to yet another issue doesn't have the podspecs it needs, hence the lines like:
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'

Obviously in an ideal world I would love to just init a fresh project and have it work as you say, but I think there's grounds to say that the specifically react cocoapods are unstable and problematic right now and I don't like having to rely on them.

For example, I just did a fresh init and added the podfile essentially the same as yours, plus npm installed RN firebase, and straight away had these errors:

screen shot 2017-06-23 at 10 29 22

screen shot 2017-06-23 at 10 29 05

screen shot 2017-06-23 at 10 26 31

This is what I'm talking about of trying to add CxxBridge as only including BatchedBridge doesn't solve the problem for me (keep in mind this is a completely fresh install)

These react pods have essentially crippled my ability to proceed as no combination works for me.

Also I'm using cocoapods 1.2.1

@D1no
Copy link
Contributor

D1no commented Jun 23, 2017

Give me a screenshot of your "Linked Frameworks and libraries"
image

  • Maybe your libPods-myapp.a is missing.
    Delete it and drag it into the linked Frameworks and Libraries
    drag libpods

  • Make sure you build React from pods
    react from pods

  • Before you do all that, and since you know the kinks of xcode, make sure all deriveddata and caches are deleted before compiling again. We have a few scripts in our package json. But basically close xcode and run
    rm -rf ~/Library/Developer/Xcode/DerivedData
    git clean -fdx -e .vscode // deletes all unstaged changes and everything listed in the gitignore file — which includes build folder etc. Exclude anything you want to keep with the -e flag. I.e. for us .vscode
    than re-install
    yarn install
    cd ios && pod install

@D1no
Copy link
Contributor

D1no commented Jun 23, 2017

If this helps you, we maybe should add it to the documentation.

@SamMatthewsIsACommonName
Copy link
Contributor Author

Hey,
screen shot 2017-06-23 at 10 59 15

Thanks for the suggestions, tried all but still not working. I'm still getting the same error. I had previously found the building from react solution in my many traversals of all these issues on github / stackoverflow.
I guess my point is it used to work, and now after trying so many things I still can't get it to work at all. And I have no doubt the RNFirebase aspect is working fine, it's just these issues with the react pods that are crippling me. This is all I've been working on for almost 17 hours now and still can't get past square one... It's just incredibly frustrating.

@Salakar
Copy link
Contributor

Salakar commented Jun 23, 2017

Can you try the versions we use in the tests app: https://github.com/invertase/react-native-firebase/blob/master/tests/package.json#L35-L36

@SamMatthewsIsACommonName
Copy link
Contributor Author

OK tried with those versions. This is where the 'death spiral' aspect comes in (that I was dealing with yesterday with the issues doing init on version 0.45.0 + ). before version 0.45.0 you can't have the 'BatchedBridge' pod:
screen shot 2017-06-23 at 11 18 37
But that's what you need to fix the error I'm now getting:
screen shot 2017-06-23 at 11 17 53

So it goes round and round...

@SamMatthewsIsACommonName
Copy link
Contributor Author

Will the library work the way it used to with only the firebase pods and the rest just linked as a framework? Or is that not an option anymore?

@D1no
Copy link
Contributor

D1no commented Jun 23, 2017

I know that feeling. It is still very odd. My curiosity drove me now to just try it out. And it defiantly works for me. Here is a full repo without an .gitignore (to be able to fully test — watch out, its large ): https://github.com/D1no/firebasepods

  • Clone it and try to run the firebasepods.xcworkspace without any additional installation.

So it seems its an issue with your system. A radical approach could be, to start fresh with node & npm. Install nvs and download the latest node version (8.1) and set it to default. This provides also a new environment for node modules pulled from npm. You need to re-install react-native-cli, yarn etc. But this could be the reason for your problems.

Versions

node: 8.1
yarn: 0.24.6
npm: 5.0.3
cocoapods: 1.2.1
xcode: 8.3.3
react-native-cli: 2.0.1

Setup a test project named "firebasepods"

react-native init firebasepods

cd firebasepods

# verify it works
react-native run-ios

yarn add react-native-firebase

cd ios && touch Podfile
# Copy past content to pod file from below & save.

pod install

# Open firebasepods.xcworkspace with xcode and run it on the simulator.

Podfile copy & paste

platform :ios, '9.0'

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

  pod "Yoga", :path => "../node_modules/react-native/ReactCommon/yoga"
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'BatchedBridge', # Required For React Native 0.45.0+
    'Core',
    # Add any other subspecs you want to use in your project
  ]

  # Required by RNFirebase
  pod 'Firebase/Core'
  pod 'RNFirebase', :path => '../node_modules/react-native-firebase'

  # [OPTIONAL PODS] - comment out pods for firebase products you won't be using.
  # pod 'Firebase/AdMob'
  pod 'Firebase/Analytics'
  pod 'Firebase/Auth'
  pod 'Firebase/Crash'
  pod 'Firebase/Database'
  pod 'Firebase/DynamicLinks'
  pod 'Firebase/Messaging'
  pod 'Firebase/RemoteConfig'
  pod 'Firebase/Storage'

end

Here the full terminal log of setting up that test-project: https://gist.github.com/D1no/23018798c803976bc3d2aa6ad39c5566

@SamMatthewsIsACommonName
Copy link
Contributor Author

Great thanks a lot for this. Yes your project compiled with no problem (I was watching in envy as it did), so as you say it must be something wrong with my init etc. I will reinstall everything and report back. Thanks a lot.

@D1no
Copy link
Contributor

D1no commented Jun 23, 2017

Glad to hear that :) Would be worse if our system just magically works. If you figure out what the issue is/was, let us know. I'd really like to know what is so fragile about react-native to also have a better feeling about our build set-up 😅

@SamMatthewsIsACommonName
Copy link
Contributor Author

SamMatthewsIsACommonName commented Jun 23, 2017

OK so I followed along, added nvs and used new version with all same version as you said ^. Followed the instructions verbatim, then still ended up with the jschelpers issue.
This being the case, is it possible to use the new version of the library in the old way, or are we reliant on the react pods now?

I can continue using the older version of the library that worked for me in the past, but I'm jsut scared of being left behind and unable to upgrade :/

@SamMatthewsIsACommonName
Copy link
Contributor Author

I also tried adding the jschelpers framework as mentioned as a possible solution here facebook/react-native#13010

@D1no
Copy link
Contributor

D1no commented Jun 23, 2017

That is super odd — and you should probably investigate that further. I assume you cleared the xcode directives (rm -rf ~/Library/Developer/Xcode/DerivedData) and ran nvs link current to make sure everything is using the nvs node version.

The only option left after that are weird environment variables and/or folders with a weird cmod. If you want to go into that further,

  • clone my project.
  • Add the .gitignore.
  • Run git clean -fdx.
  • Run yarn install and than cd ios && pod install.
  • Run the project from firebasepods.workspace.
  • Delete the .gitignore again
  • and commit your outcome of the installation procedure.

Looking at the commit diff, you should see what our system does different to yours — potentially leading to the cause of your issues.

Regarding manual add, well, though I consider it to be a hack, @Salakar would have to explain how that works with the new structure.

@SamMatthewsIsACommonName
Copy link
Contributor Author

Thanks, honestly all this kind of stuff is way beyond me. I'm already 2 days behind schedule now and stressed out to the point I can't think anymore.
I was really hoping could just go back to the old way of installing firebase pods and not having to rely on any other pods. This seems to be the way with all other libraries that use native code. So this pod based system is going to be exclusively the way forward from now on?

@SamMatthewsIsACommonName
Copy link
Contributor Author

But I will try that now thanks. I'm just worried that that it compiled last time so not sure if it will show anything that's leading up to the initial problem

@SamMatthewsIsACommonName
Copy link
Contributor Author

OK the only difference I got was cocoapods version (I had initially been using 1.2.1 but for some reason was only 1.0 using that new setup), so I updated it and tried again and same result.

@D1no
Copy link
Contributor

D1no commented Jun 23, 2017

Ok. I am sadly out of ideas. I assume if you just delete the build and/or pods folder of my project and let xcode build, it will fail. I think we are entering the void of horrible apple tooling.

@SamMatthewsIsACommonName
Copy link
Contributor Author

Thanks for the help anyway though. But that's what scares me is that the reliance on the React pods introduces this whole new layer of potentially crippling issues, and RN itself works fine without having to take the pods approach, so it seems a heavy burden to have to introduce that and all the many unsloved issues into the mix to use this library

@SamMatthewsIsACommonName
Copy link
Contributor Author

Specifically if this issue facebook/react-native#13010 was properly resolved (the answers seem to work for some people, but not in my case), then I'd feel a lot more comfortable about it

@Ehesp Ehesp closed this as completed Jul 5, 2017
@DanGDroid
Copy link

Run the project from firebasepods.workspace.
this is the main point

@SamMatthewsIsACommonName
Copy link
Contributor Author

@DanGDroid yes I was the issue I was having is the one I referenced above ^

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

5 participants