Skip to content

Commit 08733ee

Browse files
authored
Merge pull request #18 from orta/master
RFC for Improving CocoaPods support
2 parents a53b3c1 + 1d1ea4f commit 08733ee

File tree

1 file changed

+117
-0
lines changed

1 file changed

+117
-0
lines changed
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
---
2+
title: CocoaPods Support Improvements
3+
author:
4+
- Orta Therox
5+
- Eloy Durán
6+
date: 2018-08-15
7+
---
8+
9+
# RFC0003: CocoaPods Support Improvements
10+
11+
## Summary
12+
13+
Simplify CocoaPods support in React Native, by reducing the differences between how CocoaPods maps React Native into the existing set of Xcode projects.
14+
15+
## Basic example
16+
17+
CocoaPods support in React Native is a tad tricky, because it’s trying to map a complex set of Xcode projects into a single dependency. The Podspec for React Native does a lot of work under the hood at ~300 LOC. This is, in part, because we use a CocoaPods abstraction called subspecs to consolidate out the React Native library into one single library.
18+
19+
If we split the `React.podspec` into many podspecs, one per Xcode project. Roughly ~10ish Podspecs per React Native release. These would match up one-to-one to the Xcode projects so that when CocoaPods support is broken in React Native, an error report would make it obvious which part of the project is broken.
20+
21+
This means we can also move React Native and we can get CocoaPods support back in CI. This route allows CocoaPods support to be tested without network access (all the required information would be inside the same)
22+
23+
The CocoaPods React dependency would then depend on React-ART, and React-RCTSettings etc.
24+
25+
## Motivation
26+
27+
For teams adding React Native to existing apps CocoaPods support let's RN be treated as a dependency like all of the other ones. CocoaPods is built with a lot of escape valves for consumers to fix issues at runtime (you see people passing around `post_install` [fixes](https://github.com/facebook/react-native/issues/20182#issuecomment-409131862) for example, and I built a [CocoaPods plugin](https://github.com/orta/cocoapods-fix-react-native) to try consolidate them all)
28+
29+
I think one of the a key reasons for the drift between the CocoaPods support and the Xcode projects is because they're not mapped together.
30+
31+
## Detailed design
32+
33+
```sh
34+
rm React.podspec
35+
36+
touch React/React.podspec
37+
pod spec lint React/React.podspec
38+
39+
touch Libraries/ART/React-ART.podspec
40+
touch RNTester/React-RNTester.podspec
41+
touch Libraries/Blob/React-RCTBlob.podspec
42+
# etc
43+
```
44+
45+
Implementing that is reasonably straight forwards. Then we have two ideas about how the Podspecs can be distributed.
46+
47+
- Podspecs are shipped to CocoaPods trunk when a release is deployed. This is the simplest for library consumers, but a bit more taxing on release deployment. It must have been discussed before, but they were classed as being deprecated. I'm open for this RFC to be about bringing that back.
48+
49+
- Or... The React Native repo is turned into a Podspecs Repo. This would mean making a Specs folder in the root of the react-native repo, and putting in the CocoaPods Podspecs. People using CocoaPods would include React Native at the top of their Podfiles like so:
50+
51+
```ruby
52+
source 'https://github.com/facebook/react-native.git'
53+
source 'https://github.com/CocoaPods/Specs.git'
54+
55+
pod "React"
56+
pod "React-Devtools"
57+
```
58+
59+
The changes would convert the React Native repo to act like a specs repo:
60+
61+
```
62+
$ ls .
63+
64+
[... as it is today]
65+
Specs
66+
[... as it is today]
67+
68+
$ tree Specs
69+
70+
React
71+
├── 0.57.0
72+
│ └── React.podspec.json
73+
└── 0.57.1
74+
└── React.podspec.json
75+
React-ART
76+
├── 0.57.0
77+
└── React-ART.podspec.json
78+
└── 0.57.1
79+
└── ...
80+
React-RCTSettings
81+
├── 0.57.0
82+
└── 0.57.1
83+
Yoga
84+
├── 0.45.0-rc.2.React
85+
└── 0.48.4.React
86+
[.. for all the specs]
87+
```
88+
89+
## Drawbacks
90+
91+
Why should we _not_ do this? Please consider:
92+
93+
- This adds more files for CocoaPods support in the React Native repo, but it puts each one next to the Xcodeproj it represents.
94+
- The "React Native repo as Specs repo" adds a folder called "Specs" in the root, which is confusing for JS/Android folk. We can add support into CocoaPods to recognize "Podspecs" instead also.
95+
- If you were already separating your JS repo from your app code, then you would need to change your Podfile. But this means you don't have to host these Podspecs yourself (or [use Artsy's](https://github.com/artsy/specs))
96+
97+
98+
## Alternatives
99+
100+
- CocoaPods support could be handled by [shipping binaries](https://github.com/react-native-community/discussions-and-proposals/issues/15) of React Native to clients. Personally, I prefer to be working with the source code for ease of forkability and debugging.
101+
102+
## Adoption strategy
103+
104+
Shouldn't be major, a paragraph or two in the blog post for the version that first supports it and an update to the docs page for integrating with an existing app.
105+
106+
## How we teach this
107+
108+
Shouldn't be an issue here.
109+
110+
## Unresolved questions
111+
112+
The biggest call is:
113+
114+
- Submitting the Podspecs to CocoaPods on a deploy, or
115+
- Turning the "React Native repo into a Spec repo"
116+
117+
If anyone can talk to the original reasons for deprecating trunk support? then I can give a better opinion about which makes the most sense. The first one is simpler for everyone, but in 2016 the trunk support was [deprecated](http://cocoapods.org/pods/React).

0 commit comments

Comments
 (0)