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

[CocoaPods] Make podspec great again. #12089

Closed
wants to merge 12 commits into from
Closed

Conversation

alloy
Copy link
Contributor

@alloy alloy commented Jan 27, 2017

Fixes #11272
Fixes #11572
Fixes #11781

The main changes here are:

  • This depends on the latest CocoaPods (1.2.0). It’s currently in RC, but if I’m not mistaken a proper release is expected soon. /cc @dantoml
  • Adds required header search paths for the jschelpers and cxxreact subspecs.
  • Makes the jschelpers and cxxreact headers private to building React Native, not visible to the user’s project.
  • It uses the canonical upstream Yoga v1.0.0 podspec: https://github.com/facebook/yoga/blob/master/Yoga.podspec
  • Consistent styling.

I have been able to get our app to build again using this artsy/emission#437. The spec has some warnings, but otherwise fully passes lint.

@rh389 @sjmueller Could you please test with your projects?

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. GH Review: review-needed labels Jan 27, 2017
@alloy
Copy link
Contributor Author

alloy commented Jan 27, 2017

Next week I will take some time to get both Yoga and React Native to perform linting on CI, so that I can hear of these regressions when they happen. (Do you have some way with your bot to notify specific people when specific parts of the CI setup fail?)

React.podspec Outdated
ss.frameworks = "JavaScriptCore"
ss.libraries = "stdc++"
s.subspec "Core" do |ss|
ss.dependency "Yoga", "~> 1.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this use the local copy of Yoga? The RN tests in this repo (and separate tests within FB I imagine) are run against whatever copy of Yoga is synced into this repo and we want to avoid divergence between using CocoaPods vs. manually linking the framework.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ide Yeah you’re totally right that the code should match what’s being used in the tests, but I was under the impression that Yoga moving to an official podspec was paving the way for us to make using both RN and Yoga as dependencies of our apps nicer.

I.e. I would really like to have the choice to have flattened transitive dependencies in my app, no duplications (smaller binary size), and less dealing with possible duplicate symbols and what not.

@emilsjolander do you know if that was/is not the case?


Nonetheless, as it stands, the code is indeed out of sync, I should have noted that.

  1. The code vendored in RN is this Yoga version.
  2. The published v1.0.0 of Yoga is this newer revision.

So if this were to be used, either the version in 1 needs to be published as e.g. Yoga v0.9, or the vendored code in RN should be updated to the version in 2.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting releases in sync will be very hard. @dshahidehpour, could we have the podspec in the dirsynced folder so we can reference the included copy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting releases in sync will be very hard.

Oh, bummer, I thought that cutting Yoga releases wasn’t a big deal “If you need a new release to be cut please file a task.”

could we have the podspec in the dirsynced folder so we can reference the included copy?

You mean that users would add that to their Podfile separately? Because I don’t see a way to reference it from RN’s podspec 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took a quick look at using the vendored Yoga code, alas this is not going to work well right now due to CocoaPods/CocoaPods#6440

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way I would be comfortable with relying with Yoga from the CocoaPods repo is if Facebook were to use the same snapshot of Yoga (whether via CocoaPods or another mechanism e.g. Buck). I strongly prefer a systemic way that makes sure FB engineers are less likely to break open-source and vice versa, by making sure everyone is running the same copy of Yoga.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think settling on the same systems is going to be a hard sell. If I understand it right, there’s the following types of consumers:

  • FB engineers, I assume they use Buck
  • OSS CP users
  • OSS npm users

What’s most important is that they can all know, at release time, what the right version is, no? So some metadata about the Yoga commit/tag that’s being used is the main requirement. This could be a file next to the vendored code, or maybe something like a git subtree (assuming that git records metadata about these like with subomdules, but I’ve never used them).

The same applies to other parts of RN, btw, like the snapshot (image) testing module. The way it’s currently included makes it hard to integrate with apps that use FBSnapshotTestcase directly.

Copy link
Contributor

@ide ide Jan 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The systems don't need to be the same, I want just the Yoga code to be the same -- I would be on board with specifying a precise commit.

@robhogan
Copy link
Contributor

LGTM - working nicely in a mixed Swift/Obj-C project importing React as a framework, with a bunch of React subspecs and third-party native modules installed as pods. No hacks, no post-install scripts, no manual config! 🎉

Thanks for finding the time to work on this 👍

@javache
Copy link
Member

javache commented Jan 27, 2017

Thanks for your help @alloy! We should definitely get this on CI as well, @hramos can you help with that?

s.subspec "jschelpers" do |ss|
ss.source_files = "ReactCommon/jschelpers/{JavaScriptCore,JSCWrapper}.{cpp,h}"
ss.private_header_files = "ReactCommon/jschelpers/{JavaScriptCore,JSCWrapper}.h"
ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "$(PODS_TARGET_SRCROOT)/ReactCommon" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will work for now, but it doesn't match the xcode behaviour in terms of recursion. For now, we can try not include any subfolders in these directors.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean you would add subfolders but not include them with the same path, but rather all under the ‘namespace’?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In our xcode setup, a header like ReactCommon/jschelpers/foo/bar.h would be includable as <jschelpers/bar.h>, which won't work this setup as I understand it.

In the short term, we can avoid any adding new subfolders under these ReactCommon targets

@endocrimes
Copy link

I just released 1.2.0 proper. 👍. https://github.com/CocoaPods/CocoaPods/releases/tag/1.2.0

@mkonicek
Copy link
Contributor

mkonicek commented Jan 30, 2017

Hi guys, I'm the React Native oncall this week - doing my usual mark&sweep through pull requests :) What's the conclusion here? Is this good to go, needs changes, or there is no consensus on what to do next?

bachand added a commit to airbnb/react-native that referenced this pull request Jan 31, 2017
React.podspec Outdated
s.platform = :ios, "8.0"
s.pod_target_xcconfig = { "CLANG_CXX_LANGUAGE_STANDARD" => "c++14" }
s.preserve_paths = "package.json", "LICENSE", "LICENSE-CustomComponents", "PATENTS"
s.cocoapods_version = ">= 1.2.0.beta.1"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alloy is there a feature of CocoaPods 1.2.0 that is required to support this new podspec? If not, do you think we could relax the version requirement? Would be nice if it wasn't necessary to update to consume this fix!

Thanks for doing this, solves the problem we've been having!! 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This version of the spec uses POD_TARGET_SRCROOT, which is a CocoaPods 1.2.0 only feature. I'll have another think when finalizing it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alas, this is definitely the better fix for the majority of people. However, you could probably replace the $(POD_TARGET_SRCROOT) parts with $(SRCROOT) and point it to where your RN source lives relative to the Xcode source root.

@robhogan
Copy link
Contributor

@mkonicek I think ideally we need someone at FB to modify the process by which Yoga etc are copied in from other repos so that CP can know which version to pull to match the local copy.

@alloy's idea of generating a metadata file that sits alongside any imported code specifying at least a github tag/SHA (of the 'canonical' open-source repo) sounds pretty useful to me.

@d16r
Copy link
Contributor

d16r commented Jan 31, 2017

@emilsjolander is in charge of the Yoga mirror at FB.

@alloy
Copy link
Contributor Author

alloy commented Jan 31, 2017

@mkonicek Yup, what @rh389 said. I'll send my thoughts on how to do this to @emilsjolander tomorrow and will report back here once we've reached consensus.

@javache
Copy link
Member

javache commented Jan 31, 2017

For now, can we just have our own spec for Yoga as a subspec and not make use of the Yoga spec file?

@rops
Copy link

rops commented Feb 1, 2017

@alloy just tried this patch but #11721 doesn't seem to be fixed for me. I'm using latest versions of 3rd party modules ( with new imports <React/..> ) and I'm including React from pods. Building the 3rd party libraries fails at "<React/RCTBridgeModule> file not found". Any idea what's wrong? Maybe has to do with header search paths?

@alloy
Copy link
Contributor Author

alloy commented Feb 1, 2017

@javache I’ll spend some more time to see I can get that to work.

@alloy
Copy link
Contributor Author

alloy commented Feb 1, 2017

@rops Hmm, might be a different issue after all. I’ll take a good look at that one once this issue/PR is resolved.

@rops
Copy link

rops commented Feb 1, 2017

@alloy I've done some digging and it seems that the third party libraries can't find <React> because they don't have the Pods header path in their Header Search Path. Can you think of some cocoapods hackery to fix that?

@alloy
Copy link
Contributor Author

alloy commented Feb 1, 2017

@rops Let’s take this to #11721

@guysegal
Copy link

guysegal commented Feb 3, 2017

If this PR will be merged are we expecting to see it only in 0.43.0 (March release)?

@keatongreve
Copy link
Contributor

@alloy This might need to be updated for some changes in master/0.42.x. I've been using the work in this PR to host versions of React in a private podspec, and while I got a working version of 0.41.0 pushed, 0.42.0-rc.1 was not successful (I didn't test rc.0).

This fixed it for me: hudl@97f6565

Other than that, this work has been super helpful for how we're using React Native, hopefully we see this merged soon.

@alloy
Copy link
Contributor Author

alloy commented Feb 5, 2017

For now, can we just have our own spec for Yoga as a subspec and not make use of the Yoga spec file?

@javache The problem here is that when building as a framework a header is expected to be part of the frameworks’s namespace, other namespaces are expected to be outside of the framework (i.e. in a different framework). Thus, an import like yoga/Yoga.h cannot exist inside the same framework. As this import exists in public headers exported by React (RCTConvert.h and RCTShadowView.h), this leads to an error when trying to build a Clang module for the framework (or otherwise would have lead to an error if the user tried to import one of these headers).

In fact, the only reason that jschelpers and cxxreact can be subspecs at all is simply because I made their headers private to the project.

In conclusion the only possible interim solution I see is to add a separate podspec for the vendored Yoga code and have users add that one specifically to their Podfile. I’ll add an example to this PR.

@ide
Copy link
Contributor

ide commented Feb 5, 2017

In conclusion the only possible interim solution I see is to add a separate podspec for the vendored Yoga code and have users add that one specifically to their Podfile. I’ll add an example to this PR.

Sounds good. People already have to add subspecs for basic things like Images and Networking when including RN via CocoaPods, so I find it reasonable to ask the same for Yoga. It's extra work but not much extra complexity, if that makes sense.

@alloy
Copy link
Contributor Author

alloy commented Feb 5, 2017

@ide Good point.

@ide
Copy link
Contributor

ide commented Feb 6, 2017

@facebook-github-bot shipit

@facebook-github-bot
Copy link
Contributor

@ide has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

nicktate pushed a commit to nicktate/react-native that referenced this pull request Feb 7, 2017
Summary:
Fixes facebook#11272
Fixes facebook#11572
Fixes facebook#11781

The main changes here are:

* This depends on the latest CocoaPods (1.2.0). It’s currently in RC, but if I’m not mistaken a proper release is expected soon. /cc dantoml
* Adds required header search paths for the jschelpers and cxxreact subspecs.
* Makes the jschelpers and cxxreact headers private to building React Native, not visible to the user’s project.
* It uses the canonical upstream Yoga v1.0.0 podspec: https://github.com/facebook/yoga/blob/master/Yoga.podspec
* Consistent styling.

I have been able to get our app to build again using this artsy/emission#437. The spec has some warnings, but otherwise fully passes lint.

rh389 sjmueller Could you please test with your projects?
Closes facebook#12089

Differential Revision: D4518605

fbshipit-source-id: ecf86232d8b1af52d139eadd1acc10f5c1d42c29
@alloy
Copy link
Contributor Author

alloy commented Feb 7, 2017

Wow. You know what I only just now realised? The title of this PR… I wrote it while I was in the US and might have been watching news in the background and made a Freudian slip.

It was supposed to say “Make podspec work again.”

@guysegal
Copy link

guysegal commented Feb 7, 2017

It seem like that was your intention in the PR name.. Anyway you actually made podspec GREAT again.
We've been following this PR and it solves us a lot of problems!
Thank you

@vongohren

This comment has been minimized.

@robhogan

This comment has been minimized.

@vongohren

This comment has been minimized.

@alloy

This comment has been minimized.

@vongohren

This comment has been minimized.

normanjoyner pushed a commit to nicktate/react-native that referenced this pull request Feb 9, 2017
Summary:
Fixes facebook#11272
Fixes facebook#11572
Fixes facebook#11781

The main changes here are:

* This depends on the latest CocoaPods (1.2.0). It’s currently in RC, but if I’m not mistaken a proper release is expected soon. /cc dantoml
* Adds required header search paths for the jschelpers and cxxreact subspecs.
* Makes the jschelpers and cxxreact headers private to building React Native, not visible to the user’s project.
* It uses the canonical upstream Yoga v1.0.0 podspec: https://github.com/facebook/yoga/blob/master/Yoga.podspec
* Consistent styling.

I have been able to get our app to build again using this artsy/emission#437. The spec has some warnings, but otherwise fully passes lint.

rh389 sjmueller Could you please test with your projects?
Closes facebook#12089

Differential Revision: D4518605

fbshipit-source-id: ecf86232d8b1af52d139eadd1acc10f5c1d42c29
nicktate pushed a commit to nicktate/react-native that referenced this pull request Feb 9, 2017
Summary:
Fixes facebook#11272
Fixes facebook#11572
Fixes facebook#11781

The main changes here are:

* This depends on the latest CocoaPods (1.2.0). It’s currently in RC, but if I’m not mistaken a proper release is expected soon. /cc dantoml
* Adds required header search paths for the jschelpers and cxxreact subspecs.
* Makes the jschelpers and cxxreact headers private to building React Native, not visible to the user’s project.
* It uses the canonical upstream Yoga v1.0.0 podspec: https://github.com/facebook/yoga/blob/master/Yoga.podspec
* Consistent styling.

I have been able to get our app to build again using this artsy/emission#437. The spec has some warnings, but otherwise fully passes lint.

rh389 sjmueller Could you please test with your projects?
Closes facebook#12089

Differential Revision: D4518605

fbshipit-source-id: ecf86232d8b1af52d139eadd1acc10f5c1d42c29
nicktate pushed a commit to nicktate/react-native that referenced this pull request Feb 9, 2017
Summary:
Fixes facebook#11272
Fixes facebook#11572
Fixes facebook#11781

The main changes here are:

* This depends on the latest CocoaPods (1.2.0). It’s currently in RC, but if I’m not mistaken a proper release is expected soon. /cc dantoml
* Adds required header search paths for the jschelpers and cxxreact subspecs.
* Makes the jschelpers and cxxreact headers private to building React Native, not visible to the user’s project.
* It uses the canonical upstream Yoga v1.0.0 podspec: https://github.com/facebook/yoga/blob/master/Yoga.podspec
* Consistent styling.

I have been able to get our app to build again using this artsy/emission#437. The spec has some warnings, but otherwise fully passes lint.

rh389 sjmueller Could you please test with your projects?
Closes facebook#12089

Differential Revision: D4518605

fbshipit-source-id: ecf86232d8b1af52d139eadd1acc10f5c1d42c29
@huangcheng1
Copy link

Do you tried using Swift?

@alloy
Copy link
Contributor Author

alloy commented Feb 9, 2017

Yes, @rh389 did (see earlier comments). I also tested this as a framework build, which is all that is required for Swift interoperability.

alloy added a commit to alloy/react-native that referenced this pull request Feb 9, 2017
Summary:
Fixes facebook#11272
Fixes facebook#11572
Fixes facebook#11781

The main changes here are:

* This depends on the latest CocoaPods (1.2.0). It’s currently in RC, but if I’m not mistaken a proper release is expected soon. /cc dantoml
* Adds required header search paths for the jschelpers and cxxreact subspecs.
* Makes the jschelpers and cxxreact headers private to building React Native, not visible to the user’s project.
* It uses the canonical upstream Yoga v1.0.0 podspec: https://github.com/facebook/yoga/blob/master/Yoga.podspec
* Consistent styling.

I have been able to get our app to build again using this artsy/emission#437. The spec has some warnings, but otherwise fully passes lint.

rh389 sjmueller Could you please test with your projects?
Closes facebook#12089

Differential Revision: D4518605

fbshipit-source-id: ecf86232d8b1af52d139eadd1acc10f5c1d42c29
nicktate pushed a commit to nicktate/react-native that referenced this pull request Feb 9, 2017
Summary:
Fixes facebook#11272
Fixes facebook#11572
Fixes facebook#11781

The main changes here are:

* This depends on the latest CocoaPods (1.2.0). It’s currently in RC, but if I’m not mistaken a proper release is expected soon. /cc dantoml
* Adds required header search paths for the jschelpers and cxxreact subspecs.
* Makes the jschelpers and cxxreact headers private to building React Native, not visible to the user’s project.
* It uses the canonical upstream Yoga v1.0.0 podspec: https://github.com/facebook/yoga/blob/master/Yoga.podspec
* Consistent styling.

I have been able to get our app to build again using this artsy/emission#437. The spec has some warnings, but otherwise fully passes lint.

rh389 sjmueller Could you please test with your projects?
Closes facebook#12089

Differential Revision: D4518605

fbshipit-source-id: ecf86232d8b1af52d139eadd1acc10f5c1d42c29
@yimingtang

This comment has been minimized.

@vongohren

This comment has been minimized.

@ide
Copy link
Contributor

ide commented Feb 10, 2017

This PR has no effect on Android -- please try to keep the discussion at hand focused.

@vongohren

This comment has been minimized.

@yimingtang

This comment has been minimized.

grabbou pushed a commit that referenced this pull request Feb 14, 2017
Summary:
Fixes #11272
Fixes #11572
Fixes #11781

The main changes here are:

* This depends on the latest CocoaPods (1.2.0). It’s currently in RC, but if I’m not mistaken a proper release is expected soon. /cc dantoml
* Adds required header search paths for the jschelpers and cxxreact subspecs.
* Makes the jschelpers and cxxreact headers private to building React Native, not visible to the user’s project.
* It uses the canonical upstream Yoga v1.0.0 podspec: https://github.com/facebook/yoga/blob/master/Yoga.podspec
* Consistent styling.

I have been able to get our app to build again using this artsy/emission#437. The spec has some warnings, but otherwise fully passes lint.

rh389 sjmueller Could you please test with your projects?
Closes #12089

Differential Revision: D4518605

fbshipit-source-id: ecf86232d8b1af52d139eadd1acc10f5c1d42c29
GaborWnuk pushed a commit to GaborWnuk/react-native that referenced this pull request Feb 28, 2017
Summary:
Fixes facebook#11272
Fixes facebook#11572
Fixes facebook#11781

The main changes here are:

* This depends on the latest CocoaPods (1.2.0). It’s currently in RC, but if I’m not mistaken a proper release is expected soon. /cc dantoml
* Adds required header search paths for the jschelpers and cxxreact subspecs.
* Makes the jschelpers and cxxreact headers private to building React Native, not visible to the user’s project.
* It uses the canonical upstream Yoga v1.0.0 podspec: https://github.com/facebook/yoga/blob/master/Yoga.podspec
* Consistent styling.

I have been able to get our app to build again using this artsy/emission#437. The spec has some warnings, but otherwise fully passes lint.

rh389 sjmueller Could you please test with your projects?
Closes facebook#12089

Differential Revision: D4518605

fbshipit-source-id: ecf86232d8b1af52d139eadd1acc10f5c1d42c29
maarf pushed a commit to fullcontact/react-native that referenced this pull request Apr 26, 2017
Summary:
Fixes facebook#11272
Fixes facebook#11572
Fixes facebook#11781

The main changes here are:

* This depends on the latest CocoaPods (1.2.0). It’s currently in RC, but if I’m not mistaken a proper release is expected soon. /cc dantoml
* Adds required header search paths for the jschelpers and cxxreact subspecs.
* Makes the jschelpers and cxxreact headers private to building React Native, not visible to the user’s project.
* It uses the canonical upstream Yoga v1.0.0 podspec: https://github.com/facebook/yoga/blob/master/Yoga.podspec
* Consistent styling.

I have been able to get our app to build again using this artsy/emission#437. The spec has some warnings, but otherwise fully passes lint.

rh389 sjmueller Could you please test with your projects?
Closes facebook#12089

Differential Revision: D4518605

fbshipit-source-id: ecf86232d8b1af52d139eadd1acc10f5c1d42c29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet