[RN-CheatSheet] React-Native setup in M1 device

HYUNGU, KANG·2023년 10월 30일
1

React-Native-CheatSheet

목록 보기
14/24

When the M1 chip was first released, there were limited compatible programs available, so users had to use a program called Rosetta 2 to run Intel-based Mac software.

Commonly, in a command-line interface (CLI) environment, you would use the arch -x86_64 some-program command to run these programs.

However, as of now, nearly two+ years since the introduction of the M1 architecture, almost all programs are fully supported, making the need for this command obsolete. In fact, using it can confuse beginners rather than helping them.

If you mistakenly install or use Homebrew, Ruby/Gem, or CocoaPods for Intel Macs, you will need to append arch -x86_64 to all related commands to execute them.
This can lead to confusion and problems, especially when architectural issues arise due to a lack of overall understanding or forgetting what you've installed.


To ensure smooth installation in an M1 environment, follow the steps below:

Install Homebrew:

Apple silicon (M1) is now fully supported. Follow the installation guide on the official website.

If the which brew command in the terminal doesn't return /opt/homebrew/bin/brew, it's likely installed under the x86 architecture.
In such a case, consider migrating or reinstalling as discussed in this GitHub thread: https://github.com/Homebrew/discussions/discussions/417.

Install Ruby:

The version of Ruby that comes pre-installed on M1 Macs may have issues, like problems with FFI.
To avoid affecting tools like Cocoapods and Bundler, install rbenv and use it to install Ruby version 2.7.5 or higher.
Typically, you would install rbenv using Homebrew, but be cautious if you've previously installed Homebrew for Intel Macs, as it may cause issues with Ruby installation.

Once Ruby is successfully installed via rbenv, running the which ruby command should return the path to rbenv's Ruby, such as /Users/name/.rbenv/shims/ruby. If the path remains unchanged, it indicates that the environment variables in your shell profile (e.g., .zshrc) are not properly set. Check and configure them accordingly.

Install CocoaPods:

If Ruby is correctly installed, you can now install CocoaPods using the gem install cocoapods command.

Once everything is installed correctly, you won't need to use the arch -x86_64 command anymore.

profile
JavaScript, TypeScript and React-Native

0개의 댓글