Skip to content

Commit

Permalink
Update RNTester documentation for Mac M1
Browse files Browse the repository at this point in the history
Summary:
This Diff updates the RNTester README to support Mac M1 laptops.

## Changelog
[General][Changed] - Updated `rn-tester/README.md` to include instructions for Mac M1 users

Reviewed By: cortinico

Differential Revision: D34376951

fbshipit-source-id: 7195bddefb6e202261fef9b5f5225484c506fd9b
  • Loading branch information
Riccardo Cipolleschi authored and facebook-github-bot committed Feb 21, 2022
1 parent 200488e commit 4ec2d6c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/rn-tester/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,16 @@ rm Podfile.lock
If you are still having a problem after doing the clean up (which can happen if you have built RNTester with older React Native versions where files were generated inside the react-native folder.), the best way might be to clean-install react-native (e.g. remove node_modules and yarn install).

Both macOS and Xcode are required.
- `cd packages/rn-tester`
- Install [Bundler](https://bundler.io/): `gem install bundler`. We use bundler to install the right version of [CocoaPods](https://cocoapods.org/) locally.
- Install Bundler and CocoaPods dependencies: `bundle install && bundle exec pod install`. In order to use Hermes engine instead of JSC, run: `USE_HERMES=1 bundle exec pod install` instead.
- Open the generated `RNTesterPods.xcworkspace`. This is not checked in, as it is generated by CocoaPods. Do not open `RNTesterPods.xcodeproj` directly.
1. `cd packages/rn-tester`
1. Install [Bundler](https://bundler.io/): `gem install bundler`. We use bundler to install the right version of [CocoaPods](https://cocoapods.org/) locally.
1. Install Bundler and CocoaPods dependencies: `bundle install && bundle exec pod install`. In order to use Hermes engine instead of JSC, run: `USE_HERMES=1 bundle exec pod install` instead.
1. Open the generated `RNTesterPods.xcworkspace`. This is not checked in, as it is generated by CocoaPods. Do not open `RNTesterPods.xcodeproj` directly.

#### Note for M1 users
If you own a Mac M1 laptop, you need to run some different commands to install and run cocoapods.

- `sudo arch -x86_64 gem install ffi`: this installs the `ffi` package to load dynamically-linked libraries.
- `arch -x86_64 pod install`: this run `pod install` with the right architecture.

### Running on Android

Expand Down

6 comments on commit 4ec2d6c

@Raraku
Copy link

@Raraku Raraku commented on 4ec2d6c Mar 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
I just tried this and I got an error running the pod install command
Screenshot 2022-03-02 at 08 57 29

Running the pod install command without the emulation worked.

I also noticed that I have built previous apps with the default commands and didn't encounter any issues.

@cortinico
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe @cipolleschi can help you over here?

@cipolleschi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Raraku, thanks for reporting this.

To help you out, I could need few more information:

  1. did you install ffi with arch -x86_64?
  2. did you run bundle exec pod install or bundle exec arch -x86_64 pod install?
  3. which ruby version have you installed/are you running?

@Raraku
Copy link

@Raraku Raraku commented on 4ec2d6c Mar 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @cipolleschi

  1. Yes, I installed ffi by running sudo arch -x86_64 gem install ffi.
  2. I ran arch -x86_64 pod install
  3. Using ruby -v I got version 2.6.8.

Please note that just running pod install worked and I was able to build the application

@cipolleschi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I run a few tests here and there to try to understand what's going on. I managed to reproduce your issue :D

First of all, that's not an error but a warning. If you open the RNTesterPods.xcworspace you should be able to build and run the app without issues. That's a good news.
The warning suggests to run this command env /usr/bin/arch -arm64 /bin/bash --login which logs you into a bash shell. However, this does not change a thing.

Looking into similar issues, I found this other related issue. This suggests to install cocoapods using brew instead of using bundler. But at this point, we can't use the bundle exec version of the command anymore, but we have to use the arch -x86_64 pod install directly.
If we do that, the warnings go away. If we reinstall cocoapods from gem, it comes back.

At the moment, I'm using gem 3.0.3.1, from gem -v.
The note was introduced to fix this error

I can't reproduce this error at the moment.

My best guess at the moment is that something has been updated since the 18th of Feb, when I incurred in the issue. Bundler has been updated the 23rd and it may now install a proper version.

@cortinico Maybe we should update the doc linking these resources and specifying that the issue may be caused by older versions of ruby, gem and bundler? We can suggest first to update the environment (the best practice to handle ruby is to use a ruby version manager like rbenv and, if the problem persist, to manually install ffi and cocoapods with the arch flag. What do you think?

@Raraku if it works for you with the simple pod install you should be able to work with that without issues, though. Thanks for reporting this problem.

@cortinico
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can suggest first to update the environment (the best practice to handle ruby is to use a ruby version manager like rbenv and, if the problem persist, to manually install ffi and cocoapods with the arch flag. What do you think?

I guess my point is the same as the one I wrote here: facebook/react-native-website#3003

Let's find the most universal & easiest command we can share and let's update the docs with that one. I don't have an M1 so I can't really try anything at this stage

Please sign in to comment.