Skip to content

Instantly share code, notes, and snippets.

@fahmyfarahat
Last active April 15, 2023 13:37
Show Gist options
  • Save fahmyfarahat/5ea70825c9b564dfde5c57605d49a7fc to your computer and use it in GitHub Desktop.
Save fahmyfarahat/5ea70825c9b564dfde5c57605d49a7fc to your computer and use it in GitHub Desktop.
Automated React Native environment setup and project creation script for macOS.
#!/bin/sh
# Update package lists
echo "Updating package lists..."
brew update
# List of necessary packages
packages=("node" "watchman" "python3" "make" "gcc" "git" "ruby" "bash" "curl")
# Install packages if they are not already installed
for package in "${packages[@]}"; do
if ! brew list --formula $package >/dev/null 2>&1; then
echo "Installing $package..."
brew install $package
fi
done
# Install CocoaPods based on its presence
echo "Installing CocoaPods..."
sudo gem install cocoapods
# Ensure pip, setuptools, and wheel are installed and up-to-date
echo "Ensuring pip, setuptools, and wheel are installed and up-to-date..."
python3 -m ensurepip
python3 -m pip install --no-cache --upgrade pip setuptools wheel
#install global react-native-cli if exists
echo "Installing global react-native-cli..."
npm install -g react-native-cli
# Clear npm cache
echo "Clearing npm cache..."
npm cache clean --force
# Set up a new React Native project
echo "Setting up a new React Native project..."
read -p "Enter the name of your React Native project: " project_name
npx react-native init $project_name
# Change to the project directory
cd $project_name
# Run the React Native app on iOS
echo "Running the React Native app on iOS..."
npx react-native run-ios
@fahmyfarahat
Copy link
Author

fahmyfarahat commented Apr 2, 2023

This script helps you set up a new React Native project on macOS by automating the installation of necessary dependencies and creating a new project. It also runs the app on iOS for the first time.

Usage:

  1. Save the script as setup_react_native.sh.
  2. Open a terminal and navigate to the directory where the script is saved.
  3. Make the script executable by runningchmod +x setup_react_native.sh.
  4. Execute the script by running ./setup_react_native.sh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment