Skip to content

Instantly share code, notes, and snippets.

@ThePredators
Last active November 14, 2024 13:05
Show Gist options
  • Save ThePredators/064c46403290a6823e03be833a2a3c21 to your computer and use it in GitHub Desktop.
Save ThePredators/064c46403290a6823e03be833a2a3c21 to your computer and use it in GitHub Desktop.
Setup Mobile Development Environment

⭐ Setup Mobile Development Environment

⚠️ The following configuration has been tested on Intel, M1 & M2 Ships ⚠️

Pre-requisit :

If you have any issues with macOS, or need anything related to it check this documentation

Install Xcode Command Line tools :

xcode-select --install

Intel Chips

Nothing else to do.

ARM Chips

Install Rosetta :

/usr/sbin/softwareupdate --install-rosetta --agree-to-license

Install FFI

arch -arm64 sudo gem install ffi

Part 1 : Install Tools

Install HomeBrew

Intel :

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

If you need to remove it, to make a clean install

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

Apple Silicon :

To install Homebrew on M1 Apple :

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

Add this alias to .zshrc

alias brew="arch -arm64 brew"

Add HomeBrew to Your Path

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

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 iTerm

brew install --cask iterm2

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 --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-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

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

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

My P10k config Options :

- Rainbow
- Unicode
- 24H
- Flat
- Flat
- 2 lines
- Dotted
- Right
- Darkest
- Sparse
- Concise
- No
- Verbose
- Overright
- No (.zshrc)

Install SVN

brew install subversion

Install Repo

brew install repo

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 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 VirtualBox

brew install --cask virtualbox

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 :

Part 2 : Install iOS

Install Ruby

curl -L https://get.rvm.io | bash -s stable
echo $"\nsource /Users/$(whoami)/.rvm/scripts/rvm\n" >> /Users/$(whoami)/.zshrc # or .bashrc
rvm install ruby-3.2.2
rvm use ruby-3.2.2
rvm --default use 3.2.2

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 Bundler

gem install bundler

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 xcodesorg/made/xcodes

# list available xcode versions
xcodes list

# Update available xcode versions
xcodes update

# Install Aria2 "For Fast download"
brew install aria2

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

Before running xcodes, export this environment variables :

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

Others :

Install Runtimes :

Using again Xcodes tool from above

List Runtimes

xcodes runtimes --include-betas

Install iOS Runtime

xcodes runtimes install "iOS 17.0-beta1"

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

gem install fastlane -NV

then run :

bundle update
bundle install
bundle exec fastlane ...

Sometimes a write issue appear using bundle install/update to fix it do this :

sudo chown -R $(whoami) /Users/$(whoami)/.gem

More details

Part 3 : Install Android

Install Java JDK :

Using Jabba "Java Version Manager" (Recommanded)

# Install Jabba 
echo $'\nexport 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 [email protected]

# Verify java version
java -version

## The result should be : 
# openjdk 17.0.1 ...

# Don't forget to export JAVA_HOME
echo $"\nexport JAVA_HOME=/Users/$(whoami)/.jabba/jdk/[email protected]/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 $"\nexport GRADLE_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 Android Tools

Install Command-line tools for building and debugging Android apps (sdkmanager, avdmanager, etc.)

# Command-line tools for building and debugging Android apps
brew install --cask android-commandlinetools

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

Install SDKManager :

Do this :

# Export SDK MANAGER
echo $"\nexport SDK_MANAGER=$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager\n" >> /Users/$(whoami)/.zshrc
echo $"\nexport PATH=$SDK_MANAGER:$PATH\n" >> /Users/$(whoami)/.zshrc

If you ever have an issue regarding unaccepted licence do this :

# Accept all licenses
yes | sdkmanager --licenses

Usefull CLI :

# list available repos (Stable chanel)
sdkmanager --list --channel=0

# Install Android SDK Command-line Tools Latest
sdkmanager "cmdline-tools;latest"

# Install Android SDK Platform 34
sdkmanager "platforms;android-34"

# Install Android SDK Build-Tools
sdkmanager "build-tools;34.0.0"

More Infos :

Install AVD Manager (Android Vitrual Device Manager) :

echo $"\nexport AVD=$ANDROID_HOME/cmdline-tools/latest/bin/avdmanager\n" >> /Users/$(whoami)/.zshrc
echo $"\nexport PATH=$AVD:$PATH\n" >> /Users/$(whoami)/.zshrc

Install Android Emulator (& Run Standalone Emulators without Android Studio) :

sdkmanager "emulator"
echo $"\nexport EMULATOR=$ANDROID_HOME/emulator\n" >> /Users/$(whoami)/.zshrc
echo $"\nexport PATH=$EMULATOR:$PATH\n" >> /Users/$(whoami)/.zshrc

# List existing avds (already created)
avdmanager list avds

# Install an EMULATOR system image
sdkmanager "system-images;android-33;google_apis_playstore;arm64-v8a"

# Create an AVD (ex. SDK 33 for // Architecture: arm64-v8a (Apple Silicom Mac) or x86_64 (Intel) )
avdmanager create avd -f --name "PIXEL_8" -k "system-images;android-33;google_apis_playstore;arm64-v8a"

# list available Emulator
$EMULATOR/emulator -list-avds

# Run an emulator (ex. NAME_OF_EMU: Pixel_8)
$EMULATOR/emulator -avd NAME_OF_EMU

Install Android SDK component (ADB, fastboot, etc.)**

## This command download the latest android-platform-tools and copy them into `brew --prefix`/bin and do the linking as well
brew install android-platform-tools

Install Toolset to implement parts of Android apps in native code (NDK)

brew install --cask android-ndk

Install Android studio

Install Android studio

brew install --cask android-studio

Install Android Emulator

GenyMotion (Recomended for Intel)

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

⚠️ For Apple Silicon genymotion is not available since they do not yet support VirtualBox version 7 ⚠️

Install Android File Transfer : (Optionnal)

Best tool so far OpenMtp: better than Google AFT

brew install --cask openmtp

Google Android Tool

brew install --cask android-file-transfer

Install Android Debug Tool : (Optionnal)

Best for anything : Scrcpy (Recomended) (Vysor + Android File Transfer alternative)

brew install scrcpy

Part 4 : 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

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

Result :

If everything was all good you should get something like this :

❯ flutter doctor -v                                                          ─╯
[] Flutter (Channel stable, 3.10.2, on macOS 13.4 22F66 darwin-arm64 (Rosetta),
    locale en-BE)
    • Flutter version 3.10.2 on channel stable at
      /usr/local/Caskroom/flutter/3.10.2/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 9cd3d0d9ff (3 days ago), 2023-05-23 20:57:28 -0700
    • Engine revision 90fa3ae28f
    • Dart version 3.0.2
    • DevTools version 2.23.1

[] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /usr/local/share/android-commandlinetools
    • Platform android-32, build-tools 30.0.2
    • ANDROID_HOME = /usr/local/share/android-commandlinetools
    • ANDROID_SDK_ROOT = /usr/local/share/android-commandlinetools
    • Java binary at: /Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[] Xcode - develop for iOS and macOS (Xcode 14.3)
    • Xcode at /Applications/Xcode-14.3.0.app/Contents/Developer
    • Build 14E222b
    • CocoaPods version 1.12.1

[] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[] Android Studio (version 2022.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      17.0.6+0-17.0.6b802.4-9586694)

[] VS Code (version 1.78.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 13.4 22F66 darwin-arm64
      (Rosetta)
    • Chrome (web)    • chrome • web-javascript • Google Chrome 113.0.5672.126

[] Network resources
    • All expected network resources are available.

• No issues found!

FAQ :

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 !

@ThePredators
Copy link
Author

Update 01/2024 :

  • Updated section Android

@ThePredators
Copy link
Author

UPDATE 09/2024 :

  • Updated Android Tools Section

@ThePredators
Copy link
Author

if somebody had an issue downloading iOS or others runtimes in Xcode 16.1 + follow this : XcodesOrg/xcodes#396 (comment)

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