Skip to content

Instantly share code, notes, and snippets.

@malcohelper
Last active April 23, 2026 03:15
Show Gist options
  • Select an option

  • Save malcohelper/94b61cead0aaea046afe39a24b9863bb to your computer and use it in GitHub Desktop.

Select an option

Save malcohelper/94b61cead0aaea046afe39a24b9863bb to your computer and use it in GitHub Desktop.
setup_env_mobile

Setup Environment Mobile by ONE Script

This script automates the provisioning of a full-stack mobile development environment on macOS. From a single entry point, you can prepare React Native, Flutter (via FVM), iOS native, and Android native tooling. Key components installed or managed:

  • Homebrew
  • RVM (Ruby Version Manager) and Ruby 3.1.x
  • NVM (Node Version Manager) and Node 18 LTS
  • Bundler and CocoaPods
  • Yarn
  • Flutter Version Manager (FVM)
  • Watchman
  • Zulu JDK 11, Android Studio + Platform Tools
  • Xcode Command Line Tools

Prerequisites

Make sure you have the following:

  • macOS with administrator rights (Ventura or newer recommended)
  • Stable internet connection (script checks connectivity upfront)
  • Xcode downloaded from the App Store if you plan to target iOS
  • At least 30 GB free disk space for SDKs and emulators
  • Terminal access

Installation

  1. Make the script executable:

    chmod +x setup_env_mobile.sh
  2. Run the script:

./setup_env_mobile.sh
# or run in non-interactive mode
./setup_env_mobile.sh --force
  1. Pick the stack you need: the script prompts with five options (React Native, Flutter, iOS, Android, or All). Type the number and press Enter.

  2. Let the automation finish: every install step and PATH export runs hands-free. When complete, you get a summary table of provisioned tools.

Post Installation

After the script completes, run a quick validation:

ruby -v                # Verify Ruby via RVM
node -v                # Verify Node via NVM
yarn -v                # Confirm Yarn
pod --version          # Confirm CocoaPods
fvm --version          # Check Flutter Version Manager
fvm flutter doctor     # Inspect the Flutter toolchain through FVM
adb version            # Confirm Android Platform Tools (if installed)

If PATH looks incorrect, reload your shell:

source ~/.zshrc

For Flutter projects, pin a version with FVM before you start coding:

cd <project_name>
fvm use 3.19.0 --install
fvm flutter pub get

The script appends the alias flutter='fvm flutter', so every new terminal session routes flutter commands through FVM automatically.

Troubleshooting

  • If Homebrew is not found, try running:
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  • If RVM is not detected, restart your terminal and try:
    source /opt/homebrew/share/rvm/scripts/rvm
  • If NVM does not load properly, run:
    source ~/.zshrc
  • FVM reports a missing Flutter SDK: change into your project folder and run fvm use <version> --install.
  • Android Studio missing SDK packages: launch Android Studio once, open SDK Manager, and install SDK Platform 34 plus the latest tools.
  • pod install permission errors: execute sudo gem install cocoapods and retry from your iOS project.

Uninstallation

To remove installed tools, use the following:

brew uninstall rvm nvm
rvm implode
nvm uninstall <node_version>
gem uninstall cocoapods bundler

Updated Flowchart (Environment Provisioning Flow)

flowchart TD
  A[Setup request ticket] --> B{Select target stack}
  B -->|React Native| C[Option 1: React Native]
  B -->|Flutter| D[Option 2: Flutter]
  B -->|iOS Native| E[Option 3: iOS Native]
  B -->|Android Native| F[Option 4: Android Native]
  B -->|Full Suite| G[Option 5: All]
  C --> H[RVM + NVM + Yarn + Pods]
  D --> I[FVM install & fvm flutter doctor]
  E --> J[Xcode CLT + Pods]
  F --> K[Zulu JDK + Android Studio]
  G --> H
  G --> I
  G --> J
  G --> K
  H --> L[Aggregate logs & sanity checks]
  I --> L
  J --> L
  K --> L
  L --> M[Share README + support contact]
Loading

🚀 Malco Helper!

#!/usr/bin/env bash
set -euo pipefail
###===========================###
### COLOR SETUP ###
###===========================###
INFO="\033[1;34m[INFO]\033[0m"
WARN="\033[1;33m[WARN]\033[0m"
ERROR="\033[1;31m[ERROR]\033[0m"
SUCCESS="\033[1;32m[SUCCESS]\033[0m"
FORCE_MODE=false
if [[ "${1:-}" == "--force" ]]; then
FORCE_MODE=true
fi
log() {
echo -e "$INFO $1"
}
warn() {
echo -e "$WARN $1"
}
error() {
echo -e "$ERROR $1" >&2
}
success() {
echo -e "$SUCCESS $1"
}
check_command() {
command -v "$1" >/dev/null 2>&1
}
prompt_yes_no() {
local prompt="$1"
read -rp "$prompt (y/n): " ans
case $ans in
[Yy]*) return 0 ;;
*) return 1 ;;
esac
}
check_internet() {
log "Checking internet connection..."
if ! ping -q -c 1 -W 2 google.com >/dev/null 2>&1; then
error "No internet connection. Please connect and try again."
exit 1
fi
success "Internet connection is available."
}
check_existing_installations() {
echo -e "\nChecking your system for existing tools..."
for cmd in ruby node yarn pod fvm flutter java javac xcode-select watchman; do
if check_command "$cmd"; then
echo -e "$SUCCESS $cmd is installed: $(eval "$cmd --version" 2>/dev/null | head -n1)"
else
echo -e "$WARN $cmd is not installed."
fi
done
}
ask_and_install() {
local cmd="$1"
local name="$2"
local install_fn="$3"
if $FORCE_MODE || ! check_command "$cmd"; then
if $FORCE_MODE || prompt_yes_no "Do you want to install $name?"; then
log "Installing $name..."
eval "$install_fn"
success "$name installation complete."
else
warn "$name skipped by user."
fi
else
success "$name is already installed. Skipping."
fi
}
append_to_zshrc() {
local line="$1"
if ! grep -Fxq "$line" ~/.zshrc; then
echo "$line" >> ~/.zshrc
log "Appended to .zshrc: $line"
fi
}
install_homebrew() {
ask_and_install "brew" "Homebrew" "/bin/bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\""
}
install_rvm_ruby() {
ask_and_install "ruby" "Ruby via RVM" "\curl -sSL https://get.rvm.io | bash -s stable --ruby && source \"\$HOME/.rvm/scripts/rvm\" && rvm install \"$RUBY_VERSION\" && rvm use \"$RUBY_VERSION\" --default"
}
install_nvm_node() {
ask_and_install "node" "Node via NVM" "curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash && export NVM_DIR=\"\$HOME/.nvm\" && [ -s \"\$NVM_DIR/nvm.sh\" ] && \\. \"\$NVM_DIR/nvm.sh\" && nvm install \"$NODE_VERSION\" && nvm use \"$NODE_VERSION\""
append_to_zshrc "export NVM_DIR=\"\$HOME/.nvm\""
append_to_zshrc "[ -s \"\$NVM_DIR/nvm.sh\" ] && \\. \"\$NVM_DIR/nvm.sh\""
}
install_yarn() {
ask_and_install "yarn" "Yarn" "brew install yarn"
}
install_cocoapods() {
ask_and_install "pod" "CocoaPods" "sudo gem install cocoapods"
}
install_java() {
ask_and_install "javac" "Java (Zulu JDK)" "brew tap homebrew/cask-versions && brew install --cask zulu11"
}
install_xcode_cli() {
ask_and_install "xcode-select" "Xcode CLI" "xcode-select --install || true"
}
install_watchman() {
ask_and_install "watchman" "Watchman" "brew install watchman"
}
install_flutter() {
ask_and_install "fvm" "Flutter Version Manager (FVM)" "brew tap leoafarias/fvm && brew install fvm"
warn "FVM installed. Run 'fvm use <version>' inside your project to download and pin a Flutter SDK."
append_to_zshrc "alias flutter='fvm flutter'"
}
install_android() {
if $FORCE_MODE || ! check_command "adb"; then
if $FORCE_MODE || prompt_yes_no "Do you want to install Android SDK + Studio?"; then
brew install --cask android-studio
brew install --cask android-platform-tools
append_to_zshrc "export ANDROID_HOME=\$HOME/Library/Android/sdk"
append_to_zshrc "export PATH=\$PATH:\$ANDROID_HOME/emulator:\$ANDROID_HOME/tools:\$ANDROID_HOME/tools/bin:\$ANDROID_HOME/platform-tools"
success "Android Studio and SDK installed."
else
warn "Android skipped by user."
fi
else
success "Android SDK already installed. Skipping."
fi
}
summary_check() {
echo -e "\n$INFO Final Environment Check:"
for tool in ruby node yarn pod fvm flutter java javac xcode-select watchman; do
if check_command "$tool"; then
echo -e "$SUCCESS $tool: $(eval "$tool --version" 2>/dev/null | head -n 1)"
else
echo -e "$WARN $tool not installed."
fi
done
}
main() {
RUBY_VERSION="3.1.4"
NODE_VERSION="18.17.1"
log "Mobile Environment Setup Script (React Native, Flutter, Android, iOS)"
check_internet
install_homebrew
check_existing_installations
echo "\nSelect development environment to setup:"
echo "[1] React Native"
echo "[2] Flutter"
echo "[3] iOS Native"
echo "[4] Android Native"
echo "[5] All of the above"
read -rp "Enter choice (1-5): " choice
case $choice in
1)
install_rvm_ruby
install_nvm_node
install_yarn
install_watchman
install_cocoapods
;;
2)
install_flutter
;;
3)
install_rvm_ruby
install_cocoapods
install_xcode_cli
;;
4)
install_java
install_android
;;
5)
install_rvm_ruby
install_nvm_node
install_yarn
install_watchman
install_cocoapods
install_flutter
install_java
install_android
install_xcode_cli
;;
*)
error "Invalid choice."
exit 1
;;
esac
summary_check
success "Setup complete! Please run 'source ~/.zshrc' or restart your terminal."
}
main "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment