# ⭐ Setup Mobile Development Environment (Tested on macOS M1+Intel) ## Install [HomeBrew](https://brew.sh/) ```sh ## 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** ```sh HBP=`brew --prefix` export PATH=$HBP/bin:$PATH ``` **Apple M1 Support** To install Homebrew on M1 Apple : ```sh arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` Add this alias to .zshrc ```sh alias brew="arch -arm64 brew" ``` **Usefull CLI** ```sh ## 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](https://ohmyz.sh/) ```sh 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](https://github.com/ThePredators/zshconfig) (The above tool is fully automated and available for Intel & M1 Mac) ### Install PowerLvl Template + Zsh Plugins - [Powerlevel9k](https://medium.com/@Clovis_app/configuration-of-a-beautiful-efficient-terminal-and-prompt-on-osx-in-7-minutes-827c29391961) - [Powerlevel10k (Recommended)](https://gist.github.com/kevin-smets/8568070) ```sh ## 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](https://github.com/romkatv/powerlevel10k#meslo-nerd-font-patched-for-powerlevel10k) font you want to use. ## Install [Git](https://git-scm.com/downloads) ```sh brew install git brew install git-lfs ``` ## Install [Git Flow](https://danielkummer.github.io/git-flow-cheatsheet/) ```sh brew install git-flow ``` ## Install [Sublime Text](https://www.sublimetext.com/) ```sh brew install --cask sublime-text ``` ## Install [Fork (Recommended)](https://git-fork.com/) ```sh brew install --cask fork ``` ## Install [iTerm](https://iterm2.com/) ```sh brew install --cask iterm2 ``` ### Install PowerLine Fonts for iTerm (Optionnal) : ```sh # 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](https://code.visualstudio.com/) ```sh 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 : ```json { ... "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](https://gist.github.com/ThePredators/63548e82749418aa805885c1ec87b97f) **Recommended using : [rbenv](https://github.com/rbenv/rbenv)** ### M1 Support Add the following to your .zshrc ```sh alias gem="arch -x86_64 sudo gem" ``` Please run the following scripts too ! ```sh gem install --user-install ffi -- --enable-libffi-alloc ``` ## Install [CocoaPods](https://guides.cocoapods.org/using/getting-started.html) : ```sh sudo gem install cocoapods -n /usr/local/bin ``` **M1 Support** Add this to .zshrc ```sh alias pod="arch -arm64 pod" ``` ## Install [Swift Package Manager (Recommended)](https://swift.org/getting-started/) No Need to install on macOS ! Don't forget to check the SPM Aliases ! - **SPM Template (With SwiftUI) : [swift5-module-template](https://github.com/fulldecent/swift5-module-template)** - **SPM Sample App (With StoryBoard) : [SwiftExampleAppWithSPM](https://github.com/ThePredators/SwiftExampleAppWithSPM)** ## Install XCode Many options to download Xcode you can use the following **Recommended** Using : [Xcodes](https://github.com/RobotsAndPencils/xcodes) ```sh # 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 : ```sh export XCODES_USERNAME="" export XCODES_PASSWORD="" ``` **Others :** - [MAS](https://github.com/mas-cli/mas) - [Xcodes BigSure+](https://github.com/RobotsAndPencils/XcodesApp) - [Downloader-for-Apple-Developers](https://github.com/vineetchoudhary/Downloader-for-Apple-Developers) - [Troubleshooting](https://wilsonmar.github.io/xcode/#XcodeInstall) ## Install iOS Simulator : **Install xcode-install** ```sh sudo gem install xcode-install ``` **Display all simulators By name** ```sh xcversion simulators ``` **Install a Simulator** ```sh xcversion simulators --install="iOS 14.4 Simulator" ``` **Display all availables devices and simulators ByIds** ```sh xcrun simctl list ``` Output Example : ```md 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 : ```sh alias sim="/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator -CurrentDeviceUDID" ``` Then just run : ```sh sim D9C60396-FC76-4693-AEE2-84AA7C8EB200 ``` (ex. From above the DeviceUDID is : D9C60396-FC76-4693-AEE2-84AA7C8EB200) **To Open latest iOS Simulator** ```sh open -a Simulator ``` ## Install [Fastlane](https://docs.fastlane.tools/) ```sh brew install fastlane ``` [**Here is a quick Tutorial on how to integrate Fastlane with TestFlight & AppCenter for Android/iOS/Flutter**](https://gist.github.com/ThePredators/a1d105b0794198cade4ef2b0e0836541) ## Install Java JDK : **Using [Jabba "Java Version Manager"](https://github.com/shyiko/jabba) (Recommanded)** ```sh # 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 :** ```sh 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 ```sh 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](https://flutter.dev/docs/get-started/install) ```sh ## 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** ```sh 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** ```sh softwareupdate --install-rosetta ## Flutter arch -x86_64 sudo gem install ffi ``` ## Install Android "SDK + NDK" **Install Android SDK (sdkmanager, avdmanager, lint, retrace, screenshot2, apkanalyzer)** ```sh ## 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** ```sh sdkmanager "ndk-bundle" ``` **Install (ADB, fastboot, sload_f2fs, dmtracedump, e2fsdroid, etc1tool, hprof-conv, make_f2fs, make_f2fs_casefold, mke2fs)** ```sh 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 : - [SDKManager](https://developer.android.com/studio/command-line/sdkmanager) ## Install Android studio **Install Android studio** ```sh 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. ```sh flutter config --android-sdk $ANDROID_HOME ``` **Options 2 :** 1. create a symbolic link to Android SDK : ```sh ln -s $ANDROID_HOME ``` 2. call the link you created from (Preference -> Appearance & Behaviour -> System Settings -> Android SDK) #### Link Dart SDK : 1. create a symbolic link to Dart SDK : ```sh ln -s $DART_SDK ``` 2. call the link you created from (Preference -> Languages & Frameworks -> Dart) #### Link Flutter SDK : 1. create a symbolic link to Flutter SDK : ```sh ln -s $FLUTTER_SDK ``` 2. 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 : ```sh ln -s $JAVA_HOME ``` 2. call the link you created ## Install Android Emulator **[GenyMotion (Recomended)](https://www.genymotion.com/)** ```sh brew install --cask genymotion ``` Usefull ClI : - [genyshell](https://docs.genymotion.com/desktop/latest/05_Genymotion_Shell.html#starting-genymotion-shell) - [gmtool](https://docs.genymotion.com/desktop/latest/06_GMTool.html#general-commands) ```sh ## 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](https://github.com/google/android-emulator-m1-preview/releases) ## Install Android File Transfer (Optionnal) ```sh brew install --cask android-file-transfer ``` ## Install Vysor (Optionnal) ```sh brew install --cask vysor ``` ## Install [Scrcpy (Recomended)](https://github.com/Genymobile/scrcpy) (Vysor + Android File Transfer alternative) ```sh brew install scrcpy ``` ## Install Docker + Kitematic ### Install Docker **Intel Support** ```sh brew install docker ``` **M1 Support** Download this docker M1 image [Docker Desktop Apple M1](https://desktop.docker.com/mac/stable/arm64/Docker.dmg?utm_source=docker&utm_medium=webreferral&utm_campaign=docs-driven-download-mac-arm64) ### Install Kitematic ```sh brew install --cask kitematic ``` ## Install some macOS developer Tools **[OpenInTerminal](https://github.com/Ji4n1ng/OpenInTerminal)** ```sh brew install --cask openinterminal ``` **[Spectacle](https://github.com/eczarny/spectacle)** ```sh brew install --cask spectacle ``` **[Dozer](https://github.com/Mortennn/Dozer)** ```sh brew install --cask dozer ``` **[DB Browser for SQLite](https://sqlitebrowser.org)** ```sh brew install --cask db-browser-for-sqlite ``` **[Proxyman](https://proxyman.io/)** ```sh brew install --cask proxyman ``` **[PostMan](https://www.postman.com)** ```sh brew install --cask postman ``` ## Install Browser Plugins : **Chrome :** - [Octotree](https://chrome.google.com/webstore/detail/octotree-github-code-tree/bkhaagjahfmjljalopjnoealnfndnagc) - [User Agent Switcher](https://chrome.google.com/webstore/detail/user-agent-switcher-for-c/djflhoibgkdhkhhcedjiklpkjnoahfmg) - [DarkReader](https://chrome.google.com/webstore/detail/dark-reader/eimadpbcbfnmbkopoojfekhnkhdbieeh) - [Session Manager](https://chrome.google.com/webstore/detail/session-buddy/edacconmaakjimmfgnblocblbcdcpbko) **FireFox :** - [Tab Session Manager](https://addons.mozilla.org/en-US/firefox/addon/tab-session-manager/) - [firefox-multi-account-containers](https://addons.mozilla.org/fr/firefox/addon/multi-account-containers/) - [Simple-tab-groups](https://addons.mozilla.org/en-US/firefox/addon/simple-tab-groups/) - [uBlock Origin](https://addons.mozilla.org/en-US/firefox/addon/ublock-origin/) - [CORS Everywhere](https://addons.mozilla.org/en-US/firefox/addon/cors-everywhere/?utm_source=addons.mozilla.org&utm_medium=referral&utm_content=search) - [User Agent Switcher](https://addons.mozilla.org/en-US/firefox/addon/user-agent-string-switcher/) - [Octotree](https://addons.mozilla.org/en-US/firefox/addon/octotree/) - [DarkReader](https://addons.mozilla.org/en-US/firefox/addon/darkreader/) - [Bitwarden Password Manager](https://addons.mozilla.org/en-US/firefox/addon/bitwarden-password-manager/) ## troubleshooting : **Install Rosetta 2** ```sh softwareupdate --install-rosetta ``` **Dart SDK Install issues** - Update them from Software Update in System Preferences or run:** ```sh softwareupdate --all --install --force ``` - If that doesn't show you any updates, run : ```sh sudo rm -rf /Library/Developer/CommandLineTools sudo xcode-select --install ``` You're good to go !