Comments (23)
Thanks for opening up this issue. This was the setup I had in mind as well.
One other thing that's going to be interesting is plugins, since they have both a obj-c and js part.
from react-native.
cc @a2 @nicklockwood
from react-native.
Would it better to package these together like Cordova does? Check out this simple example: cordova-facebook
Otherwise I could imagine keeping the CocoaPod version inline with the npm version a challenge.
from react-native.
@joewood one of the issue with Cordova is that they invented their own package manager and registry. I really don't want us to be in the business of running a registry for react native plugins. I'd much rather leave this hard work to npm and cocoapods :)
from react-native.
@vjeux totally agree. Why not use npm to pull the files from a single repo and then the build/package process would take the files out of the node_modules directory?
If the native package managers were to be used, it could soon become a dependency nightmare between maven, npm, nuget, cocoapods etc...
from react-native.
Three packages in two different package managers sounds like it would be hard to manage. What value does CocoaPod provide here?
from react-native.
I've also been thinking about this, it seems like it would be best to rely heavily on npm to package both the JS and Obj-C code (for plugins) and have it integrate to the build process by scripts/convention. Most developers familiar with React will be used to npm but likely not have seen Cocoapods etc. before. Might reduce some friction and make contributing and versioning easier...
from react-native.
With npm, for the C++ part of any build node-gyp could be used too. Taking some of the pain out of the build environment set-up.
from react-native.
CocoaPods handles the Xcode workspace configuration and linking. Things that you can do by hand or with a tool like Carthage (though that's iOS8-only which I think is a no-go for Facebook) but are nicer when handled automatically.
Most developers familiar with React will be used to npm but likely not have seen Cocoapods etc. before.
I think this is true at the moment because the project was advertised to people attending React Conf and are mostly doing web development, but I think ReactKit is going to get substantial traction when iOS developers get on board. Since CocoaPods is by far the most popular way to publish iOS libraries I think it is a good place to start even if something that's designed for polyglot modules supersedes it.
from react-native.
I think this is true at the moment because the project was advertised to people attending React Conf and are mostly doing web development, but I think ReactKit is going to get substantial traction when iOS developers get on board. Since CocoaPods is by far the most popular way to publish iOS libraries I think it is a good place to start even if something that's designed for polyglot modules supersedes it.
It sounds like this could be really useful for more advanced users. However, it seems like the common case would be developers writing JavaScript and not worrying much about Obj-C. Additionally, we're working on the Android version of ReactNative, and possibly a Windows version to follow. If we added their respective package managers as first-class dependencies, we can easily get to a point were getting started would be too hard. Let's try to make the common thing easy and the more advanced thing possible.
Can we have the initial project set up via npm and scripts and then more advanced users that want to write native components and use third party libraries can have the choice to install and use CocoaPods?
from react-native.
Some more things to put into consideration.
-
What's the story for Android? Do we ask people to also install Maven/Graddle/whatever is being used there?
-
What's the story for custom components? Let say I want to use Shimmer, do I have to do
pod install react-native-shimmer; npm install react-native-shimmer
? Or do we put everything in the npm module? Or everything in the pod?
from react-native.
I'm inclined to agree with @joewood. I like CocoaPods, and if this were an iOS-specific framework I would say that pods were an obvious solution for managing plugins. But in the long term, our plugins are going to contain JavaScript, Objective-C (or Swift!) and Java code, with whatever dependencies each of those requires, and CocoaPods only really makes sense for managing the Objective-C code.
Given that the target consumers of these plugins are predominantly web developers, and that node is a requirement to run the platform, I'd say that npm makes sense, provided that it can meet all of our requirements.
I totally understand @vjeux's disinclination for us to try to build our own package manager, however the plugin management of Cordova is one of its strongest features, and I would like to make sure that whatever we end up with provides at least that ease of use for plugin developers and consumers.
In the short term however, I see no harm in including a podspec, as it will make it easier for iOS developers to discover and try out React Native.
from react-native.
- Yeah. I think you want compatibility with Maven and Gradle so that the class path is automatically handled. These tools shouldn't be required, like how you're not forced to use CocoaPods even if a project has a podspec, but they automate the project setup experience a lot more.
- Great question. I'm not sure of the answer though I think the solution for distributing ReactKit could apply to UI components as well. Lots of similarities like having both JS and ObjC code, needing to integrate with Xcode, making the packager aware of the JS, etc.
I want to reiterate that integrating with the iOS ecosystem & community and drawing upon the wealth of Cocoa experience could be really valuable for ReactKit. From another angle, CocoaPods is familiar to people already building iOS apps today who might find it easier to drop into Obj-C when building features that ReactKit hasn't yet anticipated.
from react-native.
In the short term however, I see no harm in including a podspec, as it will make it easier for iOS developers to discover and try out React Native.
Totally. The podspec is hopefully unobtrusive. There's a fair chance that CocoaPods isn't part of the picture at the end but I think it is worth experimenting with.
Here's another idea for the dependency management & binary build process: what if there were a small tool that looked inside node_modules for React Native components and updated the Xcode project file (or even updated the Podfile to reference these modules, and delegated the rest of the work to CocoaPods)? Something like:
File hierarchy:
Podfile
Autogenerated-npm-Podfile # created by the tool
node_modules/
react-native-page-view-controller/
package.json
index.js
ios/
RCTPageViewController.h
RCTPageViewController.m
react-native-page-view-controller.podspec
Podfile
# all your normal dependencies, here are some examples
pod 'AWSiOSSDKv2', '~> 2.0'
pod 'CocoaLumberjack', '~> 2.0.0-rc'
pod 'FMDB', '~> 2.5'
pod 'GoogleAnalytics-iOS-SDK', '~> 3.0'
pod 'Reachability', '~> 3.2'
require 'Autogenerated-npm-Podfile'
Autogenerated-npm-Podfile
# @generated by hypothetical tool
# Reference the local pods that live in node_modules
pod 'react-native-page-view-controller', 'node_modules/react-native-page-view-controller/ios'
What the tool does:
- Scans node_modules for the podspecs
- Adds references to them in an autogenerated file that is loaded from the Podfile (Podfiles and Podspecs are just Ruby)
- Runs
pod install
orpod update
, whatever is appropriate
The workflow
npm install react-native-page-view-controller
cool_tool
# open App.xcworkspace
Now here's the cool part / litmus test: can ReactKit itself be distributed this way? I think it can.
from react-native.
I think the above provides the best of both worlds. This makes npm the parent package manager, CocoaPod, Maven etc. subordinate. Most JS developers won't have to worry about the native modules, as long as the scripts keep the packages in sync.
from react-native.
I like James' proposal a lot - basically leveraging cocoapods (or Maven or whatever) as a platform-specific installer, and all the code is pulled in as one versioned unit from one system (npm), and we can even hide the steps inside npm install so it's super smooth for developers.
On Feb 24, 2015, at 6:38 PM, Joe Wood [email protected] wrote:
I think the above provides the best of both worlds. This makes npm the parent package manager, CocoaPod, Maven etc. subordinate. Most JS developers won't have to worry about the native modules, as long as the scripts keep the packages in sync.
—
Reply to this email directly or view it on GitHub.
from react-native.
+1 for @ide 's suggestion.
from react-native.
Can we close this now that we have a CP spec?
from react-native.
@a2 Yeah soon I think. The podspec needs a little bit of work (see #285) but with my diff I've gotten things running.
I would like to exclude unused code soon though, which is one thing a package system should provide. Discussion about external packages can continue in #235.
from react-native.
As an iOS developer, +1 on @ide 's suggestion.
from react-native.
+1 on @ide 's suggestion to use npm as parent package manager and CocoaPods/Maven as platform-specific installers.
from react-native.
The podspecs for RN and its helper libraries are in a reasonable place now. Module system still needs to be worked out and let's have that discussion separately.
from react-native.
Hop on to the module system discussion over at #235 if you want to hear about progress on the above suggestions.
from react-native.
Related Issues (20)
- ImageSource is now open for inheritance but the getUri method is still final and cannot override it HOT 3
- App not covering fulll device height HOT 5
- When using TextInput with secureTextEntry={true} on iOS, pressing the back button erases the entire text instead of just the last character. HOT 6
- 'getUri()' cannot override 'getUri()' in 'com.facebook.react.views.imagehelper.ImageSource'; overridden method is final HOT 3
- React Native 0.74.0 - Getting issue on production build -Crashed: Thread: SIGSEGV 0x0000006df6aebf90 HOT 6
- FlatList Items Not Occupying Full Screen Height with Paging Enabled HOT 3
- [Android] ScrollView does not properly handle `testID` property
- Application Scene Delegates support in RN >= 0.74 HOT 5
- How to initialize a react-native app of version 0.75.2 in year 2024? HOT 11
- Codegen resolves wrong dependency in multi-app monorepo; when apps specify different versions of same dep (ios) HOT 7
- Why support only Ukraine but not Palestine?Either support both or support neither. Why bring selective support into technology? HOT 4
- Tried to show an alert while not attached to an Activity HOT 5
- Unable to use Hermes engine in fresh CLI project HOT 10
- [email protected] / Android / New Arch - Bug HOT 5
- ForceRTL(false) is not working as intended HOT 5
- Bug: TextInput with multiline and lineHeight has height issue when controlled HOT 3
- [[email protected]] `yoga/style/Style.h` file not found HOT 10
- Creating a module with New Architecture and including a .swift file introduces compiler errors HOT 11
- [v0.75.2] macOS (Catalyst) builds fail with `hermes.framework: bundle format is ambiguous (could be app or framework)` HOT 24
- `Text` Components Positioned with bottom: 0 Gets Hidden Behind Navigation Bar on Android Devices HOT 29
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native.