Skip to content

Commit dc709b0

Browse files
authored
Merge pull request #27 from thecodingmachine/features/setup-cocoapods
Append useful documentation about using cocoapods
2 parents 555d295 + 258f899 commit dc709b0

File tree

2 files changed

+103
-2
lines changed

2 files changed

+103
-2
lines changed

README.md

Lines changed: 10 additions & 2 deletions
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,9 +96,16 @@ 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
100+
101+
- Using [Fastlane](https://fastlane.tools/) to automate builds and store deployments (iOS and Android)
102+
- [Distributing beta builds](docs/beta%20builds.md)
103+
104+
105+
### Package dependencies
99106

100-
[Distributing beta builds](docs/beta%20builds.md)
107+
- You may want to use [CocoaPods](https://cocoapods.org/) to manage your dependencies (iOS only)
108+
- [Using CocoaPods to manage your package dependencies](docs/setup%20cocoapods.md)
101109

102110
## License
103111

docs/setup cocoapods.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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 thirdparty 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, we didn't specify it yet, but this tool is for iOS dependencies only. On Android, `react-native linking` seems to be enough.
10+
11+
12+
## Setup CocoaPods
13+
14+
First you must install CocoaPods :
15+
```bash
16+
brew install cocoapods
17+
```
18+
19+
Then simply create a `Podfile` file, which will be the configuration file of all your dependencies.
20+
The easiest way is by running :
21+
```bash
22+
cd ios
23+
pod init
24+
```
25+
26+
## Package management
27+
28+
### React Native framework
29+
30+
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.
31+
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`.
32+
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)
33+
34+
So, add the following into your `Podfile` :
35+
```
36+
# The target name is most likely the name of your project.
37+
target 'NumberTileGame' do
38+
39+
# Your 'node_modules' directory is probably in the root of your project,
40+
# but if not, adjust the `:path` accordingly
41+
pod 'React', :path => '../node_modules/react-native', :subspecs => [
42+
'Core',
43+
'CxxBridge', # Include this for RN >= 0.47
44+
'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
45+
'RCTText',
46+
'RCTNetwork',
47+
'RCTWebSocket', # Needed for debugging
48+
'RCTAnimation', # Needed for FlatList and animations running on native UI thread
49+
# Add any other subspecs you want to use in your project
50+
]
51+
# Explicitly include Yoga if you are using RN >= 0.42.0
52+
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
53+
54+
# Third party deps podspec link
55+
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
56+
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
57+
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
58+
59+
end
60+
```
61+
62+
Your are now ready to install your pod.
63+
```
64+
pod install
65+
```
66+
67+
### Thirdparty packages
68+
69+
On the other hand, you can really easily link librairies to your project.
70+
71+
You just have to append a line like the following inside your Podfile :
72+
```
73+
pod 'RNExampleLib.podspec', :path => '../node_modules/react-native-example-lib'
74+
```
75+
and run :
76+
```
77+
pod install
78+
```
79+
80+
That's all ! :tada:
81+
82+
## Key points
83+
84+
85+
- You must always use the `.xcworkspace` file inside Xcode instead of the `.xcodeproj` one.
86+
- Sometimes, running `react-native link` will automatically try to perform a pod install. Read carefuly each thirdparty package install doc.`
87+
88+
---
89+
90+
More resources :
91+
- [Demystifying react-native modules linking](https://engineering.brigad.co/demystifying-react-native-modules-linking-ae6c017a6b4a)
92+
- [Configuring CocoaPods dependencies](https://facebook.github.io/react-native/docs/integration-with-existing-apps#configuring-cocoapods-dependencies)
93+
- [Beginner’s Guide to Using CocoaPods with React Native](https://shift.infinite.red/beginner-s-guide-to-using-cocoapods-with-react-native-46cb4d372995)

0 commit comments

Comments
 (0)