-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
feat: Do not require pod install
after react-native init
#24638
Conversation
Big thanks to @orta for pointing me towards a solution - I would loose my mind if it wasn't for you <3 |
pod install
after react-native init
pod install
after react-native init
pod install
after react-native init
pod install
after react-native init
Now that react-native-community/cli#362 is going to be merged, I'll update the PR to always init from a tarball. That way, we will be able to make sure that we test contents of a real package, not the source. This is important, because we have an explicit list of |
FYI putting |
cd template | ||
|
||
npm install | ||
(cd ios && pod install) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we'll want to pass --repo-update
flag so we publish up-to-date pods
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... mind elaborating a bit what that flag is doing? We have local pods (from local spec within the repo, so no need to update the whole CocoaPods repo) and we also rm -rf Pods anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
forgot it's local, you're right
Unfortunately, There's no way right now other than requiring to run Our I think it's important to make sure that initing a new app is as smooth as possible and we should pay an extra time to a) think about the best scenario, b) how to implement it and c) test it. Possible next-steps:
|
As a very recent new user that commented on the initial RFC related to "podless install" I can say that Pods is absolutely, without a doubt the way to handle iOS things. The problem is just unfamiliarity and expectations (for me). If the tools even spit out a big message that said "Before running react-native run-ios you must run pod install in the ios directory http://docsurl/react-native-and-pods.html" and on that page there was a very quick intro to pods (either brew or gems to install, big first time download, always open .xcworkspace) This would be fine. In other words, two quick bits of documentation to start getting devs up to speed. They are not that complicated, it's just new knowledge - but useful enough that the community would/should rally around it as a big new feature I think |
It might be possible to duplicate the files for the headers instead of having the symlinks? |
It is possible. Question is whether this will affect CocoaPods at all? (I
assume it must have used symlinks for a reason)
…On Tue, 30 Apr 2019 at 15:14, Orta ***@***.***> wrote:
It might be possible to duplicate the files for the headers instead of
having the symlinks?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#24638 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AASZZRXCYEZKEBZEMDQMRUDPTBA3JANCNFSM4HI6XRXA>
.
|
My gut says no, CP (quite reasonably) probably didn't want to have to make duplicate files in the fs. I just tested it locally in one of my working CP projects, and replaced the links with the originals and it compiled file. Could be enough? |
Ok. I will give it another go and hopefully that’s it!
…On Tue, 30 Apr 2019 at 15:33, Orta ***@***.***> wrote:
My gut says no, CP (quite reasonably) probably didn't want to have to make
duplicate files in the fs. I just tested it locally in one of my working CP
projects, and replaced the links with the originals and it compiled file.
Could be enough?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#24638 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AASZZRRMCKK6LNGD366IYNTPTBDBDANCNFSM4HI6XRXA>
.
|
Looks like this:
will do! Updated and testing in |
Unfortunately, converting symlinks to real files doesn't work as it produces "duplicated declaration" linker errors. The only way to solve this would be to actually "restore symlinks" in CC: @thymikee |
I get the reasoning behind wanting to avoid users needing to manually run As the template uses Cocoapods now, users are going to have to use it at some point when they add any library with external dependencies. At that point they are going to need Cocoapods to be installed. Isn't it best to get them to install it along with the other required dependencies like Watchman and Node? All that is required is a call to At that point, if we know (and can check) that they have Cocoapods installed, and we can just run |
# Set the React Native version to point to the `.tgz` file | ||
node scripts/set-rn-template-version.js "file:$PACKAGE_LOCATION" | ||
|
||
# We need to generate CocoaPods project. To do so, we install depdendencies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# We need to generate CocoaPods project. To do so, we install depdendencies | |
# We need to generate CocoaPods project. To do so, we install dependencies |
I agree with you @matt-oakes. Unfortunately, there are too many hacks that need to be done in order to support this reliably. I am going to consult it with the CLI team where and how we can add support for automatically running |
@grabbou we've found integrating CocoaPods to be very challenging, to the point that we've historically opted to stick with Carthage for iOS dependency management. We're going to try switching to CocoaPods again, but I'm nervous about the potential disruption to our development process. Sorry to cross-post, but check my comment in #23563. |
@benjarwar this is for new projects only. For users who would like to always start with Carthage, there's an option to create and release to npm a custom template (since RN 0.60.0 or Once you create it, one can do: npx @react-native-community/cli@next init ProjectName --template sample-carthage-template or when RN 0.60.0 RC is up: npx react-native@^0.60.0-rc.0 init ProjectName --template sample-carthage-template |
We're moving away from |
@grabbou What are the hacks which are needed and what is the issue with running it directly? It is because you're not sure if the user has Cocoapods installed through Bundler or a similar tool? |
The hacks were needed because after running `pod install` pre-publish and
copying that to user directory after init has different paths which is
broken. Once you workaround this, you need to figure out symlinks -
CocoaPods uses symlinks but npm publish will always skip them. Converting
to real files works, but gives a duplicated file error.
Generally speaking, it's not worth it and we will just stick to running
`pod install` or installing CocoaPods on user side while initing.
…On Mon, 6 May 2019 at 19:02, Matt Oakes ***@***.***> wrote:
@grabbou <https://github.com/grabbou> What are the hacks which are needed
and what is the issue with running it directly? It is because you're not
sure if the user has Cocoapods installed through Bundler or a similar tool?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#24638 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AASZZRTASC7BTIH6CDILMF3PUBQANANCNFSM4HI6XRXA>
.
|
@grabbou I think we're agreeing. I was suggesting that |
Yes, exactly :) I agree with you and that's the approach we are taking
right now :)
…On Tue, 7 May 2019 at 17:18, Matt Oakes ***@***.***> wrote:
@grabbou <https://github.com/grabbou> I think we're agreeing. I was
suggesting that pod install is run on the user side while initing. The
hacks you mention seem to be for running install before publishing the
template, unless I'm getting confused.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#24638 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AASZZRWOVSXRSRU7APUYGL3PUGMS7ANCNFSM4HI6XRXA>
.
|
Summary
This pull request pre-generates CocoaPods files by running
pod install
locally inside atemplate
before we publish it.Rationale:
We have recently migrated default template from a regular iOS project to the one powered by CocoaPods. This was done to simplify set up required and make it easier to handle native modules in the future too.
Unfortunately, one drawback was that
pod install
was now going to be required to be run as an additional command, afterreact-native init
has completed.The detailed discussion and rationale can be found here: #23563 (comment)
Implementation:
We install Node dependencies inside a
template
. That also includes installing React Native, which at this point, points towards a previously generatedtgz
archive. Thanks to that, we are consuming an archive that will be published to the registry - same set of files.Once dependencies are installed, we install CocoaPods dependencies (by running
pod install
command insideios
). Thanks to Node dependencies being installed,../node_modules/react-native
paths are resolved correctly.Once Pods folder and Pods.xcodeproj has been generated, we remove
node_modules
and proceed to the next step, which is runningreact-native init
itself.At this point, we have
Pods
folder with all files generated. No steps required afterreact-native init
completed - justreact-native run-ios
and we are set.Note: Once CLI supports passing path to a template as
.tgz
instead of a folder, we shouldnpm pack
the template too. That way, we can make sure thatPods
is present in the archive (and on npm).