Skip to content

Instantly share code, notes, and snippets.

@pbindustries
Forked from ThePredators/readme-mde.md
Created March 11, 2022 20:21
Show Gist options
  • Save pbindustries/9a4f4e8f0c6c8d5738bc8de5d3cd6607 to your computer and use it in GitHub Desktop.
Save pbindustries/9a4f4e8f0c6c8d5738bc8de5d3cd6607 to your computer and use it in GitHub Desktop.
Setup Mobile Development Environment

⭐ Setup Mobile Development Environment (Tested on macOS M1+Intel)

Install HomeBrew

## Install xcode utils
xcode-select --install
## Install Brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Add HomeBrew to Your Path

HBP=`brew --prefix`
export PATH=$HBP/bin:$PATH

Apple M1 Support

To install Homebrew on M1 Apple :

arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Add this alias to .zshrc

alias brew="arch -arm64 brew"

Usefull CLI

## Check that everything is Ok
brew doctor
## To update HomeBrew
brew update
## To update/upgrade a brew package just run :
brew reinstall PACKAGE_NAME

Install ZSH

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

🔆 Configure Zsh in a clever way

Clone the following repository and follow the described steps zshconfig

(The above tool is fully automated and available for Intel & M1 Mac)

Install PowerLvl Template + Zsh Plugins

## Install Power10k :
git clone https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k

### change ZSH_THEME to : ZSH_THEME="powerlevel10k/powerlevel10k"
### then run :
p10k configure

## Install Auto-Suggestion :
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
### Edit .zshrc & add in plugins array : zsh-autosuggestions

## Install Syntaxe Hylight :
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
### Edit .zshrc & add in plugins array : zsh-syntax-highlighting

## Install Completion : 
git clone https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions
### Edit .zshrc & add this line before source $ZSH/oh-my-zsh.sh
#### fpath+=${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions/src

Don't forget to import Meslo Font into iTerm -> Preferences -> Profiles -> "Selected Profile" -> Text -> Font -> Select the Meslo font you want to use.

Install Git

brew install git
brew install git-lfs

Install Git Flow

brew install git-flow

Install Sublime Text

brew install --cask sublime-text
brew install --cask fork

Install iTerm

brew install --cask iterm2

Install PowerLine Fonts for iTerm (Optionnal) :

# clone
git clone https://github.com/powerline/fonts.git --depth=1

# install
cd fonts && ./install.sh

# clean-up a bit
cd .. && rm -rf fonts

Install Ruby

Recommended using : rbenv

Globally :

  1. Install and configure rbenv
brew install rbenv

then add this 2 line to .zshrc or .bashrc

export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
  1. Install ruby version 2.7.4
rbenv install 2.7.4
  1. Set Global ruby version
rbenv global 2.7.4
  1. Install latest version of bundler
gem install bundler:2.2.19 -n /usr/local/bin

Under you project :

Set local ruby version

rbenv local 2.7.4

If you need to run bundle install you need to run instead this :

bundle install --path vendor/bundle

M1 Support

Add the following to your .zshrc

alias gem="arch -x86_64 sudo gem"

Please run the following scripts too !

gem install --user-install ffi -- --enable-libffi-alloc

More Options :

Install CocoaPods :

sudo gem install cocoapods -n /usr/local/bin

M1 Support

Add this to .zshrc

alias pod="arch -arm64 pod"

No Need to install on macOS ! Don't forget to check the SPM Aliases !

Install XCode

Many options to download Xcode you can use the following

Recommended Using : Xcodes

# Install xcodes
brew install robotsandpencils/made/xcodes

# list available xcode versions
xcodes list

# Install XCode
xcodes install 13 Beta 5

Before running xcodes, export this environment variables :

export XCODES_USERNAME=""
export XCODES_PASSWORD=""

Others :

Install iOS Simulator :

Install xcode-install

sudo gem install xcode-install

Display all simulators By name

xcversion simulators

Install a Simulator

xcversion simulators --install="iOS 14.4 Simulator"

Display all availables devices and simulators ByIds

xcrun simctl list

Output Example :

D9C60396-FC76-4693-AEE2-84AA7C8EB200 (active, disconnected)
    Watch: Apple Watch Series 6 - 44mm (FE1A98F8-C2F2-446D-B436-B484B1D87837) (Shutdown)
    Phone: iPhone 12 Pro Max (7395B23C-9AAE-4CEB-8FCC-82A70FCE0553) (Shutdown)

Open Simualtor/Device ById

I advice to add this alias to your config :

alias sim="/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator -CurrentDeviceUDID"

Then just run :

sim D9C60396-FC76-4693-AEE2-84AA7C8EB200

(ex. From above the DeviceUDID is : D9C60396-FC76-4693-AEE2-84AA7C8EB200)

To Open latest iOS Simulator

open -a Simulator

Install Java JDK :

Using Jabba "Java Version Manager" (Recommanded)

# Install Jabba 
echo $'\nnexport JABBA_VERSION="0.11.2"\n' >> /Users/$(whoami)/.zshrc
curl -sL https://github.com/shyiko/jabba/raw/master/install.sh | bash && . ~/.jabba/jabba.sh

# Verify this line is in .zshrc (Should be added automatically)
[ -s "/Users/$(whoami)/.jabba/jabba.sh" ] && source "/Users/$(whoami)/.jabba/jabba.sh"

# List available java versions
jabba ls-remote

# Install JDK 16
jabba install openjdk@1.16.0

# Verify java version
java -version

## The result should be : 
# openjdk 16.0.1 2021-04-20
# OpenJDK Runtime Environment (build 16.0.1+9-24)
# OpenJDK 64-Bit Server VM (build 16.0.1+9-24, mixed mode, sharing)

# Switch to a different Java version (need to first be installed using Jabba)
jabba use ...

# Don't forget to export JAVA_HOME
echo $"\nexport JAVA_HOME=/Users/$(whoami)/.jabba/jdk/openjdk@1.16.0/Contents/Home\n" >> /Users/$(whoami)/.zshrc
echo $"\nexport PATH=$JAVA_HOME:$PATH\n" >> /Users/$(whoami)/.zshrc

Old way :

brew tap adoptopenjdk/openjdk
brew install --cask adoptopenjdk8
echo $"\nexport JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/\n" >> /Users/$(whoami)/.zshrc
echo $"\nexport PATH=$JAVA_HOME:$PATH\n" >> /Users/$(whoami)/.zshrc

Install Gradle

## In my case latest version of gradle was : 7.3.3
brew install gradle
echo $"\nexport GRADLE_HOME=/usr/local/Cellar/gradle/7.3.3\n" >> /Users/$(whoami)/.zshrc
echo $"\nexport PATH=$GRADLE_HOME/bin:$PATH\n" >> /Users/$(whoami)/.zshrc

Install Flutter

## Install Flutter
## Dart & Dart SDK will be inside : bin/ & bin/cache
brew install --cask flutter

## Migrate to null safety (Only inside a project)
# dart migrate --apply-changes

## Check That everythong is OK
flutter doctor -v

Export some PATH to .zshrc

FLUTTER_VERSION=$(echo $(arr=($(flutter --version | awk '{ print $2 }')) && echo ${arr[1]}))
export FLUTTER_SDK=`brew --prefix`/Caskroom/flutter/$FLUTTER_VERSION/flutter
export PATH=$PATH:$FLUTTER_SDK

## Flutter cache
PUB_CACHE_BIN=$HOME/.pub-cache/bin
export PATH=$PATH:$PUB_CACHE_BIN

## Dart Path
DART_PATH=$FLUTTER_SDK/bin/dart
export PATH=$PATH:$DART_PATH

## Export DART SDK Path
export DART_SDK=$FLUTTER_SDK/bin/cache/dart-sdk

Apple M1 Support for Flutter & Docker

softwareupdate --install-rosetta
## Flutter
arch -x86_64 sudo gem install ffi

Troubleshooting Dart SDK Install

Update them from Software Update in System Preferences or run:

softwareupdate --all --install --force

If that doesn't show you any updates, run:

sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install

Install Android "SDK + NDK"

Install Android SDK (sdkmanager, avdmanager, lint, retrace, screenshot2, apkanalyzer)

## Since android-sdk is deprecated
brew install --cask android-commandlinetools

# Export some paths
echo $"\nexport ANDROID_HOME=`brew --prefix`/share/android-commandlinetools\n" >> /Users/$(whoami)/.zshrc
echo $"\nexport PATH=$ANDROID_HOME:$PATH\n" >> /Users/$(whoami)/.zshrc

echo $"\nexport SDK_MANAGER=`brew --prefix`/bin/sdkmanager\n" >> /Users/$(whoami)/.zshrc
echo $"\nexport PATH=$SDK_MANAGER:$PATH\n" >> /Users/$(whoami)/.zshrc

echo $"\nexport AVD=`brew --prefix`/bin/avdmanager\n" >> /Users/$(whoami)/.zshrc
echo $"\nexport PATH=$AVD:$PATH\n" >> /Users/$(whoami)/.zshrc

# Then Install Tools
sdkmanager "cmdline-tools;latest"
sdkmanager "patcher;v4"
sdkmanager "build-tools;30.0.2"
sdkmanager "platforms;android-32"
sdkmanager "emulator"
sdkmanager "tools"
sdkmanager "platform-tools"

# Then Accept all licenses
yes | sdkmanager --licenses

Install Android NDK

sdkmanager "ndk-bundle"

Install (ADB, fastboot, sload_f2fs, dmtracedump, e2fsdroid, etc1tool, hprof-conv, make_f2fs, make_f2fs_casefold, mke2fs)

brew install android-platform-tools

echo $"\nexport ADB=`brew --prefix`/bin/adb\n" >> /Users/$(whoami)/.zshrc
echo $"\nexport PATH=$ADB:$PATH\n" >> /Users/$(whoami)/.zshrc

More Infos :

Install Android studio

Install Android studio

brew install --cask android-studio

Link "Android SDK, Flutter SDK, Dart SDK, JDK" to Android Studio

In case export environment variable doesn't work properly with Android Studio, follow theses steps.

Link Android SDK :

Option 1 : In case the following command didn't work, follow the bellow steps.

flutter config --android-sdk $ANDROID_HOME

Options 2 :

  1. create a symbolic link to Android SDK :
ln -s $ANDROID_HOME
  1. call the link you created from (Preference -> Appearance & Behaviour -> System Settings -> Android SDK)

Link Dart SDK :

  1. create a symbolic link to Dart SDK :
ln -s $DART_SDK
  1. call the link you created from (Preference -> Languages & Frameworks -> Dart)

Link Flutter SDK :

  1. create a symbolic link to Flutter SDK :
ln -s $FLUTTER_SDK
  1. call the link you created from (Preference -> Languages & Frameworks -> Flutter)

Link Java JDK :

Make sure that exported JAVA_HOME was not read in Android Studio Correctly. Go to (Right Click on your project -> Platform Settings -> SDKs).

If not :

  1. create a symbolic link to Java JDK :
ln -s $JAVA_HOME
  1. call the link you created

Install Android Emulator

GenyMotion (Recomended)

brew install --cask genymotion

Usefull ClI :

## Copy this to .zshrc
echo 'GMTOOL_PATH="/Applications/Genymotion.app/Contents/MacOS/"' >> /Users/$(whoami)/.zshrc
echo 'export PATH=$GMTOOL_PATH:$PATH' >> /Users/$(whoami)/.zshrc

## Display devices list
genyshell -c "devices list"

## To Create / run u need licence !
## Create a device
gmtool admin create "Google Pixel - 9.0 - API 28 - 1080x1920" GP_9

## Run a device
gmtool admin run GP_9

Android Emulator - Apple M1

Download this emulator Apple M1

Install Android File Transfer (Optionnal)

brew install --cask android-file-transfer

Install Vysor (Optionnal)

brew install --cask vysor

Install Scrcpy (Recomended) (Vysor + Android File Transfer alternative)

brew install scrcpy

Install Docker

Download this docker M1 image Docker Desktop Apple M1

Install Fastlane

brew install fastlane

Here is a quick Tutorial on how to integrate Fastlane with TestFlight & AppCenter for Android/iOS/Flutter

Install VsCode

brew install --cask visual-studio-code

How to use iTerm + PowerLvl10k in Vscode :

(I assume here you already followed steps decribed in section Install ZSH)

Edit this Vscode User Settings file /Users/$(whoami)/Library/Application\ Support/Code/User/settings.json and add the following :

{
    ...
    "terminal.external.osxExec": "iTerm.app",
    "terminal.integrated.shell.osx": "/bin/zsh",
    "terminal.integrated.fontFamily": "'MesloLGS NF'",
    "terminal.integrated.cursorStyle": "line",
    "terminal.integrated.lineHeight": 1.3
}

If for some reason you want to edit those colors you can add this and play a little bit with values :

{
    ...
    "workbench.colorCustomizations": {
        "terminal.background":"#131212",
        "terminal.foreground":"#6bb8e6",
        "terminal.ansiBlack":"#000000",
        "terminal.ansiBrightBlack":"#414141",
        "terminal.ansiBlue": "#bceafa",
        "terminal.ansiBrightBlue":"#77dcff",
        "terminal.ansiCyan":"#a3e9d4",
        "terminal.ansiBrightCyan":"#a3e9d5",
        "terminal.ansiGreen":"#68f400",
        "terminal.ansiBrightGreen":"#dcf152",
        "terminal.ansiMagenta":"#f58a8d",
        "terminal.ansiBrightMagenta":"#ffb4b8",
        "terminal.ansiRed":"#ff4c41",
        "terminal.ansiBrightRed":"#ff7c77",
        "terminal.ansiWhite":"#ffffff",
        "terminal.ansiBrightWhite":"#ffffff",
        "terminal.ansiYellow":"#ffe100",
        "terminal.ansiBrightYellow":"#fff68b",
    }
}

Install some macOS developer Tools

OpenInTerminal

brew install --cask openinterminal

Spectacle

brew install --cask spectacle

Dozer

brew install --cask dozer

DB Browser for SQLite

brew install --cask db-browser-for-sqlite

Proxyman

brew install --cask proxyman

PostMan

brew install --cask postman

Install Browser Plugins :

Chrome

TroubleShoots :

Install Rosetta 2

softwareupdate --install-rosetta

You're good to go !

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