1, the preface

Recently, I was writing the programmer’s macOS series. Before I wrote the first programmer’s macOS series: A selection of Mac Apps, everyone wanted me to update it as soon as possible, but it was delayed for 2 months, so today I finally updated it! In fact, macOS development environment, system default ruby, PHP, python2, GCC, g++, bash and other environments, and because macOS is based on Unix, so the traditional Unix/Linux features, very suitable for efficient and less cumbersome developers. Therefore, this article mainly explains some common development environment configuration, mainly is necessary and improves the efficiency mainly! There is no profound introduction, of course, because the main role of the building is iOS, so other development environment contact is not much (modest), we need to learn and use the current environment is similar, familiar with it is not a problem. The article is not exhaustive, to learn every point is not so simple, but to throw a brick to introduce jade, I hope you work hard to improve!

  • Programmer’s macOS Series: Select Mac Apps
  • Programmer’s macOS series: Mac Development environment configuration
  • Programmer’s macOS series: Efficient Alfred Advanced

Currently, I’m planning to write three macOS series for programmers, but I’ll update them later with more ideas

2. Development environment configuration

Note in advance that this article does not use proxy source, if the command is invalid, you remember to go over the wall ah. This tutorial tries to do everything through the command line, which is still the most efficient environment for programmers! If it is installed by a software package, it is not listed here. For example, Java installation can be searched by itself

Homebrew

Homebrew is a powerful terminal tool for managing the dependencies of many programs and packages operating under the terminal. It is an essential first step for programmers who need to work with terminal applications on a regular basis.

Open the terminal and run the following command:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Copy the code

The above command, I want you to not just copy and paste it and run it, but I want you to know more about it:

  • /usr/bin/ruby -e: Runs in the Ruby environment
  • curl -fsSL: Use the curl command to download the file

Understand these 2 points, so ruby environment, curl command and the role of parameters, I believe you can search in-depth learning, rather than a one-sided copy and paste run, to learn for use, this is really learning!

Brew some common commands:

brew search
brew info
brew install
brew remove
brew update
brew upgrade
Copy the code

Brew command is not much to say, similar to Linux apt-get, programmers from the introduction to master ah ~

Command Line Tools

You may not need to install Xcode if you are not developing for iOS or macOS, but you may need to install the Xcode command line tool because many environments and software use and rely on it (Carthage, Python3, below).

xcode-select --install
Copy the code

The xcode-select command can also be used to switch the xcode build version (directory). For more information, see xcode-select –help.

If you remember the name of the command, but don’t remember how to use it, you can use:

xxx --help
Copy the code

You can also use:

man xxx
Copy the code

The difference between the –help command and the man command is that the man command is detailed and comprehensive.

Bash, Zsh)

ZSH is a shell language, compatible with bash, providing powerful command-line functions, such as TAB completion, automatic error correction, and so on.

Install the ZSH:

brew install zsh
Copy the code

Using oh-my-zsh makes ZSH even more powerful and clever:

sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
Copy the code

You can also install oH-My-Zsh plug-ins such as autoJump, FASD, and zsh-autosuggestions on the command line

Personalization profiles, including aliases, are in the directory ~/.zshrc, you need to in-depth tutorials automatically online search ah. Here is only configuration entry, practice or see individual ah!

Example of creating an alias:

ZSHRC //vim ~/.zshrc //vimalias myblog='cd /Users/HTC/Documents/iHTCBlog'// Quickly reach the specified directoryalias st='open -a "Sublime Text"'// Open an appCopy the code

Node/npm

Node(Node.js) is an open source, cross-platform JavaScript runtime environment based on Chrome V8 engine that can run JavaScript on the server side. Node.js uses an event-driven, non-blocking I/O model, making it lightweight and efficient.

brew install node
Copy the code

After Node is installed, the NPM tool is automatically installed. NPM is the Node Package Manager, which searches for, downloads, and manages node.js related packages.

NPM some common commands:

npm helpNPM install // Install component NPM Remove // remove component NPM Update // Update componentCopy the code

In addition to Node being used for front-end/background development, React Native and Hexo blogs are also dependent on Node environment. I am still trying to learn more about Node. If I have new knowledge about Node, I will come back to update it. I don’t think so

vi(vim)

Vi is short for Visual Interface, and vim is VI IMproved. The vi(vim) command is numerous, but if used flexibly, it will greatly improve efficiency! From now on no mouse is not a dream!

Vi (Vim) is delivered with Unix/Linux terminals. Therefore, it is also delivered with macOS. So what is vi of vim going to configure?

You can call a NERD Tree, you can completeme, you can syntastic, you can call a plugin, you can call a plugin, you can call a plugin, you can call a plugin, you can call a plugin File fuzzy search (CTRLP), display vim status bar (Vim Powerline), theme color (Molokai), display file structure (Tagbar) and many other functions

Vi (vim) operation of the shortcut tutorial can refer to the main article before: vi(vim) shortcut notes

Vim sets syntax highlighting for editing text:

vim ~/.vimrc

syntax on
Copy the code

More vi knowledge, we search to learn ah ~

Git

Git’s role is not much to say, if you are just graduated novice, it is recommended to study on their own, to your development help must be very big ~

In addition, if Xcode is installed, git will be installed by default. If Xcode is not installed, you can install it yourself:

Git installation:

brew install git
Copy the code

Git basic configuration

git config --global user.name "iHTCboy" git config --global user.email "[email protected]" git config --global Git config --global alias. Ci commit git config --global git config St status git config --global alias.br branch git config --global core.editor "vim" # Set the editor to use vim git config --global core.quotepath falseCopy the code

The user’s git configuration file directory is ~/.gitconfig

  • Tig highlights to visualize the Git command line

Git more command tutorials, you search, if you want to get familiar with, or more practice ah ~ of course, the principle is also an essential step!

python3

Python3 is the future, so install, use and develop!

brew install python3
Copy the code

To view the version of PYTHon3:

python3 --version
Copy the code

There are so many things that Python can do, artificial intelligence, machine learning, big data analysis, crawlers, the Web, it can be said that Python has penetrated everywhere

jenkins

Save for now and write back later

CocoaPods

CocoaPods is a package management tool for iOS. It is similar to Maven for Java, NPM for Node.js, PIP for Python, PHP Composer for Ruby, and Gem for Ruby.

CocoaPods based on Ruby development, so install CocoaPods before the need to install Ruby environment. As mentioned earlier, macOS comes with Ruby by default! So go ahead and install it in Ruby’s gem environment

1. Installation command:

sudo gem install cocoapods
Copy the code

2. Configure the CocoaPods environment and install the Specs library. Since the library is large (several hundred MB), it takes some time and network speed:

pod setup
Copy the code

Some common commands for pod:

Pod --version //pod init // create a pod file pod install // project pod install pod update // project pod update pod search // search the libraryCopy the code

For more instructions, search on your own

Carthage

We use package management to make it easier and faster to integrate third-party libraries. Sometimes CocoaPods, the iOS package management tool, wastes a lot of time dealing with errors caused by package management. Carthage uses a non-invasive philosophy and does not make any changes to our project structure, much less create a workspace. It simply downloads the third-party libraries configured in the file we described locally, and builds the framework files using XCodeBuild.

In addition to being non-invasive, Carthage is decentralized. Unlike CocoaPods, which has a central server (Cocoapods.org) that manages the meta information for each package, It relies on each third-party library’s own source address, such as Github.

Installation:

brew install carthage
Copy the code

Carthage:

Brew upgrade Carthage brew upgrade Carthage Carthage Update install or update the project libraryCopy the code

For more instructions, search on your own

Package management tool

Package client Language Package format Description
npm JavaScript package.json Node package manager
gem Ruby Gemfile RubyGems package manager
mvn Java pom.xml Apache Maven project management and comprehension tool
gradle Java build.gradle or build.gradle.kts Gradle build automation tool for Java
docker N/A Dockerfile Docker container management platform
nuget .NET nupkg NuGet package management for .NET
pip Python requirements.txt Python package manager
Composer PHP composer.json PHP package manager
pod ObjC/Swift Podfile Cocoa application package manager
carthage ObjC/Swift Cartfile Cocoa app package manager

Reference: About GitHub Packages

3. Other environment configurations and plug-ins

Finder (access) preview plug-in

For the Finder to quickly display the contents of a file, this GitHub dedicated collection of special Finder plug-ins: github.com/sindresorhu…

Install command:

brew cask install qlcolorcode qlstephen qlmarkdown quicklook-json  qlimagesize webpquicklook suspicious-package quicklookase qlvideo provisionql quicklookapk
Copy the code

Quick look-plugins: quick look-plugins

  • Qlcolorcode: Highlighted during code file preview
  • Qlstephen: Previews files with no extension or unknown extension in plain text
  • Qlmarkdown: Preview the rendered MarkDown file
  • Quicklook-json: previews the formatted JSON file
  • ProvisionQL: displays information about the IPA file
  • QuickLookAPK: Displays information about apK files

QuickLookJSON: QuickLookJSON:

QLMarkdown:

ProvisionQL:

QuickLookAPK:

Hexo blog

npm install -g hexo
Copy the code

For details on how to use Hexo, please refer to the previous article: Hexo Building Github Pages Blog Pit Tutorial

It is recommended that every technical person set up their own blog and rely on the free services provided by GitHub, OSChina or Coding.net. It is totally fine. If you need your own domain name, you can buy a domain name for a few hundred yuan for 10 years. Programmers summarize more. For example, if you learn a technique or do a project, without a bit of recording, without a bit of summary, without a bit of thinking, can you learn anything??

Safari Extensions

Apple – Safari – Safari Extensions Gallery

Why Safari? Don’t recommend Google Chrome? A lot of people have this question, in fact, Safari as an official browser, like Windows IE/Edge, my son, must be better. I think it’s two things,

  • 1.Safari perfectly synchronizes open pages, bookmarks, and history to othersmacOS/iOSEquipment, seamless.
  • 2. Compatibility and performance in Safari is better than others, whether you like it or not — -. (Although front-end page compatibility developers will step on the pit more ~)

Here are a few common ones:

  • Translate
  • Evernote Web Clipper
  • webQR
  • Search Alias
  • Awesome Screenshot

In addition, after macOS 10.14, Apple’s Safari browser no longer supports insecure extensions. Only apple-approved updates can be found in the App Store or Safari browser extension library.

The Finder’s visit to the da

Many people may be like me, do not like to use the third party file management application, the general Apple built-in use, I will not use the third party, a convenient migration cost is high, on the other hand, the system’s built-in stability and memory occupancy are done better.

A constant pain point for me is that there is no absolute path shown!! On macOS, you can use Option + Command + P to display the full current path and jump at the bottom of the Finder. In addition, there is a SAO operation, which is shown in the title bar:

  • Displays the full path in the Finder title bar
defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES; killall FinderCopy the code
  • reduction
defaults delete com.apple.finder _FXShowPosixPathInTitle; killall FinderCopy the code

The effect is as follows:

Error: cannot open damaged installation package

If you fail to open the downloaded installation package, run the following command to resolve the problem:

sudo spctl --master-disable
Copy the code

Since macOS 10.14, Apple has been much tougher on security and privacy. Of course, there are both good and bad (and inconvenient) aspects to this issue.

alias macss="sudo spctl --master-disable"
Copy the code

Just type macSS in the terminal

MacOS Catalina 10.15 The third-party software file is damaged

After macOS 10.15, Apple strengthened certificate verification for software downloaded from third-party channels. Applications without certificates are not allowed to open. Try using the following command:

sudo xattr -r -d com.apple.quarantine xxx.app
Copy the code

Terminal command

In the terminal and vim, programmer’s efficiency must be improved a lot, but for beginners, the following is also listed some important terminal commands, convenient for you to focus on mastering, more on you automatically search:

The command role
say xxx Read the words
pwd Displays the path name of the current directory
ls View the files in the current directory
ls -al View all files, including hidden files
clear Clear screen or window contents
cd /xx/yy Skip to the directory /xx/yy
cd .. Returns the upper directory
cd / Return to root
cd – Return to the directory of the previous operation
cat xx View the contents of the xx file
man xx View detailed help information about commands, such as MAC ls
killall Finder Restart the Finder
touch xxx Create file XXX
mkdir xxx Create folder XXX
rm xxx Delete the file
rm -rf xxxx Deleting a folder
defaults write com.apple.finder AppleShowAllFiles TRUE

killall Finder
View hidden Files
defaults write com.apple.finder AppleShowAllFiles FALSE

killall Finder
Hidden files
Write left Read the record of the previous or next command
sudo vi /private/etc/hosts Editing the hosts file

There’s a whole bunch of commands that you can search for, like

  • Ccat highlights cat content

conclusion

MacOS development environment is about to talk about these, if you are not clear, online search has been a large, here is just a summary and summary, let you have a systematic understanding and learning, only you systematic and comprehensive understanding, in order to in-depth study each knowledge point. This is also the purpose of this article, given to the fish, not as good as given to fishing, I hope you study hard ~

At present, I have not been in contact with the front-end H5 and background development for a long time, so I don’t know what special environment they need to configure in macOS for the time being. This article first so ~ everyone can also leave a message feedback. Happy National Day ~

reference

  • Programmer’s macOS Series: Select Mac Apps
  • npm
  • The Missing Package Manager for macOS — The Missing Package Manager for macOS
  • Vi (vim) shortcuts reporter | iHTCboy ‘s blog
  • Vim configuration, Plug-ins, and Usage tips – a short book
  • Hexo structures, making Pages blog filling holes tutorial | iHTCboy ‘s blog
  • Make your iTerm more geeky! | iHTCboy’s blog
  • Git Common Command Memo – Stormzhang
  • EffectiveMac – bestswifter
  • Oh My Zsh – a delightful & open source framework for Z-Shell
  • ZSH | programmer’s self-improvement
  • tig
  • ccat
  • sindresorhus/quick-look-plugins: List of useful Quick Look plugins for developers
  • CocoaPods.org
  • Carthage/Carthage: A simple, decentralized dependency manager for Cocoa
  • Carthage package management tool, another agile and lighthearted iOS & MAC development experience – SwiftCafe enjoy the fun of code
  • Apple – Safari – Safari Extensions Gallery
  • About GitHub Packages – GitHub Help