Skip to content

Commit 1285a79

Browse files
author
Riccardo
authored
[Fix] Improve Getting started with iOS (facebook#3323)
1 parent 791d9d1 commit 1285a79

File tree

2 files changed

+70
-18
lines changed

2 files changed

+70
-18
lines changed

docs/_getting-started-macos-ios.md

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import M1Cocoapods from './\_markdown-m1-cocoapods.mdx'; import RemoveGlobalCLI
22

33
## Installing dependencies
44

5-
You will need Node, Watchman, the React Native command line interface, Xcode and CocoaPods.
5+
You will need Node, Watchman, the React Native command line interface, a Ruby version manager, Xcode and CocoaPods.
66

77
While you can use any editor of your choice to develop your app, you will need to install Xcode in order to set up the necessary tooling to build your React Native app for iOS.
88

@@ -19,6 +19,31 @@ If you have already installed Node on your system, make sure it is Node 14 or ne
1919

2020
[Watchman](https://facebook.github.io/watchman) is a tool by Facebook for watching changes in the filesystem. It is highly recommended you install it for better performance.
2121

22+
### Ruby
23+
24+
React Native uses a `.ruby-version` file to make sure that your version of Ruby is aligned with what is needed. Currently, macOS 12.5.1 is shipped with Ruby 2.6.8, which is **not** what is required by React Native. Our suggestion is to install a Ruby version manager and to install the proper version of Ruby in your system.
25+
26+
Some common Ruby version manager are:
27+
28+
- [rbenv](https://github.com/rbenv/rbenv)
29+
- [RVM](https://rvm.io/)
30+
- [chruby](https://github.com/postmodern/chruby)
31+
- [asdf-vm](https://github.com/asdf-vm) with the [asdf-ruby](https://github.com/asdf-vm/asdf-ruby) plugin
32+
33+
To check what is your current version of Ruby, you can run this command:
34+
35+
```
36+
ruby --version
37+
```
38+
39+
React Native uses [this version](https://github.com/facebook/react-native/blob/main/template/_ruby-version) of Ruby. You can also find which version your specific project needs in the `.ruby-version` file at root of your RN project.
40+
41+
### Bundler
42+
43+
[Bundler](https://bundler.io/) is a Ruby gem that helps managing the Ruby dependencies of your project. We need Ruby to install Cocoapods and using Bundler will make sure that all the dependencies are aligned and that the project works properly.
44+
45+
If you want to learn more about why we need this tool, you can read [this article](https://bundler.io/guides/rationale.html#bundlers-purpose-and-rationale).
46+
2247
### Xcode
2348

2449
The easiest way to install Xcode is via the [Mac App Store](https://itunes.apple.com/us/app/xcode/id497799835?mt=12). Installing Xcode will also install the iOS Simulator and all the necessary tools to build your iOS app.
@@ -39,14 +64,6 @@ To install a simulator, open <strong>Xcode > Preferences...</strong> and select
3964

4065
[CocoaPods](https://cocoapods.org/) is built with Ruby and it will be installable with the default Ruby available on macOS.
4166

42-
Using the default Ruby available on macOS will require you to use `sudo` when installing gems. (This is only an issue for the duration of the gem installation, though.)
43-
44-
```shell
45-
sudo gem install cocoapods
46-
```
47-
48-
Otherwise you can use a Ruby version manager, such as `rbenv`. Apps created with the command `npx react-native init` described below are configured to work well with `rbenv` and will pick the correct Ruby version requested by the template.
49-
5067
For more information, please visit [CocoaPods Getting Started guide](https://guides.cocoapods.org/using/getting-started.html).
5168

5269
<M1Cocoapods />
@@ -67,6 +84,15 @@ npx react-native init AwesomeProject
6784

6885
This is not necessary if you are integrating React Native into an existing application, if you "ejected" from Expo, or if you're adding iOS support to an existing React Native project (see [Integration with Existing Apps](integration-with-existing-apps.md)). You can also use a third-party CLI to init your React Native app, such as [Ignite CLI](https://github.com/infinitered/ignite).
6986

87+
:::info
88+
If you are having trouble with iOS, try to reinstall the dependencies by running:
89+
90+
1. `cd ios` to navigate to the
91+
2. `bundle install` to install Bundler
92+
1. If needed: install a [Ruby Version Manager](#ruby) and update the Ruby version
93+
3. `bundle exec pod install` to install the iOS dependencies.
94+
:::
95+
7096
### [Optional] Using a specific version or template
7197

7298
If you want to start a new project with a specific React Native version, you can use the `--version` argument:

website/versioned_docs/version-0.70/_getting-started-macos-ios.md

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import M1Cocoapods from './\_markdown-m1-cocoapods.mdx'; import RemoveGlobalCLI
22

33
## Installing dependencies
44

5-
You will need Node, Watchman, the React Native command line interface, Xcode and CocoaPods.
5+
You will need Node, Watchman, the React Native command line interface, a Ruby version manager, Xcode and CocoaPods.
66

77
While you can use any editor of your choice to develop your app, you will need to install Xcode in order to set up the necessary tooling to build your React Native app for iOS.
88

@@ -19,6 +19,31 @@ If you have already installed Node on your system, make sure it is Node 14 or ne
1919

2020
[Watchman](https://facebook.github.io/watchman) is a tool by Facebook for watching changes in the filesystem. It is highly recommended you install it for better performance.
2121

22+
### Ruby
23+
24+
React Native uses a `.ruby-version` file to make sure that your version of Ruby is aligned with what is needed. Currently, macOS 12.5.1 is shipped with Ruby 2.6.8, which is **not** what is required by React Native. Our suggestion is to install a Ruby version manager and to install the proper version of Ruby in your system.
25+
26+
Some common Ruby version manager are:
27+
28+
- [rbenv](https://github.com/rbenv/rbenv)
29+
- [RVM](https://rvm.io/)
30+
- [chruby](https://github.com/postmodern/chruby)
31+
- [asdf-vm](https://github.com/asdf-vm) with the [asdf-ruby](https://github.com/asdf-vm/asdf-ruby) plugin
32+
33+
To check what is your current version of Ruby, you can run this command:
34+
35+
```
36+
ruby --version
37+
```
38+
39+
React Native uses [this version](https://github.com/facebook/react-native/blob/main/template/_ruby-version) of Ruby. You can also find which version your specific project needs in the `.ruby-version` file at root of your RN project.
40+
41+
### Bundler
42+
43+
[Bundler](https://bundler.io/) is a Ruby gem that helps managing the Ruby dependencies of your project. We need Ruby to install Cocoapods and using Bundler will make sure that all the dependencies are aligned and that the project works properly.
44+
45+
If you want to learn more about why we need this tool, you can read [this article](https://bundler.io/guides/rationale.html#bundlers-purpose-and-rationale).
46+
2247
### Xcode
2348

2449
The easiest way to install Xcode is via the [Mac App Store](https://itunes.apple.com/us/app/xcode/id497799835?mt=12). Installing Xcode will also install the iOS Simulator and all the necessary tools to build your iOS app.
@@ -39,14 +64,6 @@ To install a simulator, open <strong>Xcode > Preferences...</strong> and select
3964

4065
[CocoaPods](https://cocoapods.org/) is built with Ruby and it will be installable with the default Ruby available on macOS.
4166

42-
Using the default Ruby available on macOS will require you to use `sudo` when installing gems. (This is only an issue for the duration of the gem installation, though.)
43-
44-
```shell
45-
sudo gem install cocoapods
46-
```
47-
48-
Otherwise you can use a Ruby version manager, such as `rbenv`. Apps created with the command `npx react-native init` described below are configured to work well with `rbenv` and will pick the correct Ruby version requested by the template.
49-
5067
For more information, please visit [CocoaPods Getting Started guide](https://guides.cocoapods.org/using/getting-started.html).
5168

5269
<M1Cocoapods />
@@ -67,6 +84,15 @@ npx react-native init AwesomeProject
6784

6885
This is not necessary if you are integrating React Native into an existing application, if you "ejected" from Expo, or if you're adding iOS support to an existing React Native project (see [Integration with Existing Apps](integration-with-existing-apps.md)). You can also use a third-party CLI to init your React Native app, such as [Ignite CLI](https://github.com/infinitered/ignite).
6986

87+
:::info
88+
If you are having trouble with iOS, try to reinstall the dependencies by running:
89+
90+
1. `cd ios` to navigate to the
91+
2. `bundle install` to install Bundler
92+
1. If needed: install a [Ruby Version Manager](#ruby) and update the Ruby version
93+
3. `bundle exec pod install` to install the iOS dependencies.
94+
:::
95+
7096
### [Optional] Using a specific version or template
7197

7298
If you want to start a new project with a specific React Native version, you can use the `--version` argument:

0 commit comments

Comments
 (0)