Skip to content

Commit c98e498

Browse files
committed
append useful documentation about using cocoapods
1 parent e592926 commit c98e498

File tree

2 files changed

+95
-1
lines changed

2 files changed

+95
-1
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ You also need to install the dependencies required by React Native:
7070
- for [Android development](https://facebook.github.io/react-native/docs/getting-started.html#installing-dependencies-3)
7171
- for [iOS development](https://facebook.github.io/react-native/docs/getting-started.html#installing-dependencies)
7272

73+
7374
## Using the boilerplate
7475

7576
To create a new project using the boilerplate:
@@ -95,10 +96,15 @@ Assuming you have all the requirements installed, you can setup and run the proj
9596

9697
## Useful documentation
9798

98-
### Distribute beta builds
99+
### Deployment
99100

100101
[Distributing beta builds](docs/beta%20builds.md)
101102

103+
104+
### Package dependencies
105+
106+
[Using CocoaPods to manage your packages](docs/setup%20cocoapods.md)
107+
102108
## License
103109

104110
This project is released under the [MIT License](LICENSE).

docs/setup cocoapods.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Setup CocoaPods
2+
3+
[CocoaPods](https://cocoapods.org/) is a package management tool for iOS and macOS development.
4+
You can use it to add the actual React Native framework code into our project, and especially to manage thirdparties packages.
5+
6+
In this boilerplate, we don't want to make CocoaPods as a required tool.
7+
But if you planned to manage a lot of thirdparty dependencies, it should be a really good idea to follow this guide.
8+
9+
Finally, I didn't specify it yet, but this tool is for iOS dependencies only. On Android, react-native linking is enought.
10+
11+
_You can read more why using CocoaPods can help you to avoid a lot of constraints [on this great article](https://engineering.brigad.co/demystifying-react-native-modules-linking-ae6c017a6b4a) from Brigad._
12+
13+
14+
## Setup CocoaPods
15+
16+
First you must install CocoaPods :
17+
```bash
18+
brew install cocoapods
19+
```
20+
21+
Then simply create a `Podfile` file, which will be the configuration file of all your dependencies.
22+
The easiest way is bu running :
23+
```bash
24+
cd ios
25+
pod init
26+
```
27+
28+
## Package management
29+
30+
### React Native framework
31+
32+
One of the main thing you must know about using CocoaPods, is that we need to manage React itself as a pod dependency to make it works well.
33+
It means that you can decide what parts of React Native framework you would like to integrate into your app. So you must not forget to append each React Native `subspec` inside the [podfile]().
34+
This part is fully explained in the [official React Native documentation](https://facebook.github.io/react-native/docs/integration-with-existing-apps#configuring-cocoapods-dependencies)
35+
36+
So, add the following into your `Podfile` :
37+
```
38+
# The target name is most likely the name of your project.
39+
target 'NumberTileGame' do
40+
41+
# Your 'node_modules' directory is probably in the root of your project,
42+
# but if not, adjust the `:path` accordingly
43+
pod 'React', :path => '../node_modules/react-native', :subspecs => [
44+
'Core',
45+
'CxxBridge', # Include this for RN >= 0.47
46+
'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
47+
'RCTText',
48+
'RCTNetwork',
49+
'RCTWebSocket', # Needed for debugging
50+
'RCTAnimation', # Needed for FlatList and animations running on native UI thread
51+
# Add any other subspecs you want to use in your project
52+
]
53+
# Explicitly include Yoga if you are using RN >= 0.42.0
54+
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
55+
56+
# Third party deps podspec link
57+
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
58+
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
59+
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
60+
61+
end
62+
```
63+
64+
Your are now ready to install your pod.
65+
```
66+
pod install
67+
```
68+
69+
### Thirdparty packages
70+
71+
On the other hand, you can really easily link librairies to your project.
72+
73+
You just have to append a line like the following inside your Podfile :
74+
```
75+
pod 'RNExampleLib.podspec', :path => '../node_modules/react-native-example-lib'
76+
```
77+
and run :
78+
```
79+
pod install
80+
```
81+
82+
That's all ! :tada:
83+
84+
## Key points
85+
86+
87+
- You must always use the `.xcworkspace` file inside Xcode instead of the `.xcodeproj` one.
88+
- Sometimes, running `react-native link will automatically try to perform a pod install. Read carefuly each thirdparty package install doc.

0 commit comments

Comments
 (0)