Skip to content

Instantly share code, notes, and snippets.

@Skyblueballykid
Forked from ThePredators/readme-mde.md
Created April 9, 2022 04:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Skyblueballykid/de1747cbb1fb8baec4ad1bcb62ac7631 to your computer and use it in GitHub Desktop.
Save Skyblueballykid/de1747cbb1fb8baec4ad1bcb62ac7631 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 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
}

Install Ruby

Checkout this detailled tutorial Ruby Version Manager

Recommended using : rbenv

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

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

# Update available xcode versions
xcodes update

# Install XCode (ex. Xcode 13 Beta 5)
xcodes install 13 Beta 5

Before running xcodes, export this environment variables :

export XCODES_USERNAME="<your_email>"
export XCODES_PASSWORD="<your_pass>"

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 Fastlane

brew install fastlane

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

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

brew install gradle
## Reinstall Gradle to Latest Version
echo $"\nGRADLE_VERSION=$(echo $(arr=($(gradle --version | awk '{ print $2 }')) && echo ${arr[1]}))\n" >> /Users/$(whoami)/.zshrc
echo $"\nexport GRADLE_HOME=`brew --prefix`/Cellar/gradle/$GRADLE_VERSION\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

Add theses lines 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

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 + Kitematic

Install Docker

Intel Support

brew install docker

M1 Support Download this docker M1 image Docker Desktop Apple M1

Install Kitematic

brew install --cask kitematic

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 :

FireFox :

troubleshooting :

Install Rosetta 2

softwareupdate --install-rosetta

Dart SDK Install issues

  • 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

You're good to go !

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