macOS开发环境学习笔记

macOS开发环境学习笔记
文章图片
Paste_Image.png 1、unix终端环境变量,怎么设置 /etc/profile, ~/.bashrc, ~/.bash_login, ~/.profile
修改后执行source使立即生效
export
env或者printenv查看

printenv | grep PATH PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/mysql/bin:/Users/ff/.rvm/bin

freebsd UNIX 基础看这里
2、unix包管理器有哪些 apt-get, rpm, dpkg, yum, dnf, aptitude, macports, homebrew,RubyGems
3、unix shell解释器 【macOS开发环境学习笔记】sh,bash,ksh,csh,zsh
困扰很久的- --参数
参数前有一横的表示后面跟的参数是单字符
参数前有两横的表示后面跟的参数是单词,字符个数大于等于2
参数前没有横杠的是bsd风格
参数前有横杠的是systemv风格
4、brew是什么 brew是一个shell脚本程序,是为Homebrew软件包管理工具。
file /usr/local/bin/brew /usr/local/bin/brew: Bourne-Again shell script text executable, ASCII textbrew config HOMEBREW_VERSION: 1.0.9 ORIGIN: https://github.com/Homebrew/brew HEAD: 8a7317aa8ff5f12067eb65e529a13490bc69deda Last commit: 4 months ago Core tap ORIGIN: https://github.com/Homebrew/homebrew-core Core tap HEAD: d1ae707b59c7241c17492e70bae2782255f1d154 Core tap last commit: 4 months ago HOMEBREW_PREFIX: /usr/local HOMEBREW_REPOSITORY: /usr/local/Homebrew HOMEBREW_CELLAR: /usr/local/Cellar HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com CPU: quad-core 64-bit haswell Homebrew Ruby: 2.0.0-p648 Clang: 8.0 build 800 Git: 2.6.3 => /usr/local/bin/git Perl: /usr/bin/perl Python: /usr/bin/python Ruby: /usr/local/bin/ruby => /usr/local/Cellar/ruby/2.3.1_2/bin/ruby Java: 1.7.0_79 macOS: 10.12.2-x86_64 Xcode: 8.2.1 CLT: 8.2.0.0.1.1480973914 X11: N/A

brew从哪来
ls -l /usr/local/bin/brew lrwxr-xr-x1 ffadmin28 114 12:12 /usr/local/bin/brew -> /usr/local/Homebrew/bin/brew

安装Homebrew
https://brew.sh/index_zh-cn.html
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

卸载homebrew
https://github.com/Homebrew/brew/blob/master/docs/FAQ.md
5、ruby是什么 ruby是一个可执行二进制程序。是为ruby脚本的解释器环境。
ls /usr/local/Cellar/ruby/2.3.1_2/bin erbgemirbrake rdoc rirubyfile ruby ruby: Mach-O 64-bit executable x86_64otool -L ruby ruby: /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1348.1.0) /usr/local/Cellar/ruby/2.3.1_2/lib/libruby.2.3.0.dylib (compatibility version 2.3.1, current version 2.3.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0) /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)

ruby从哪来
安装ruby
brew install ruby --verbose

env | grep PATH PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/mysql/bin:/Users/ff/.rvm/binwhich ruby /usr/local/bin/ruby/usr/local/bin/ruby --version ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin16]/usr/bin/ruby --version ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]which -a gem /usr/local/bin/gem /usr/bin/gemwhich gem /usr/local/bin/gem

6、gem是什么 gem 是一个ruby脚本程序。
file /usr/local/bin/gem /usr/local/bin/gem: a /usr/local/opt/ruby/bin/ruby script text executable, ASCII textls -l /usr/local/bin/gem lrwxr-xr-x1 ffadmin30 114 13:50 /usr/local/bin/gem -> ../Cellar/ruby/2.3.1_2/bin/gemls /usr/local/Cellar/ruby/2.3.1_2/bin erbgemirbrake rdoc riruby

设置gem源(用默认的)
gem sources --add https://rubygems.org/ --remove https://gems.ruby-china.org/

更新gem
sudo gem update --verbose

7、brew /gem 命令 brew install python 安装python包,默认是稳定版?
brew info python 查看python包信息,包括包的dependencies/optional等
brew cache clean 顾名思义,清除缓存
brew uninstall python 卸载python
brew search python 查找包
brew list 查看已经安装的包
brew list carthagefabriclibxml2libyamlopensslreadlineruby

brew upgrade python 更新python
gem update --system 更新gem自身,在某些linux发行版中为了系统稳定性次命令禁用
gem install fastlane 从Gem源安装gem包
gem install -l fastlane 从本机安装gem包
gem install fastlane --version=1.1.1 安装指定版本的gem包
gem update 更新所有已安装的gem包
gem update fastlane 更新指定的gem包,不会升级旧版本的包
gem uninstall fastlane 删除所有已安装的版本
gem uninstall fastlane --version=1.1.1 删除指定的版本
gem list --local 查看本季已安装的所有gem包
8、brew cask https://www.zhihu.com/question/22624898
brew主要用来下载一些不带界面的命令行下的工具和第三方库来进行二次开发brew cask主要用来下载一些带界面的应用软件,下载好后会自动安装,并能在mac中直接运行使用
举个例子,brew install curl可以安装curl第三方库,这样你在开发时就可以使用它的库来进行开发brew cask install chrome可以安装谷歌浏览器应用程序,可直接运行
brew偏管理第三方库和命令行工具方面的东东brew cask可以看作是苹果官方app store的补充,是一个众多贡献者们维护的非苹果官方软件商店,你也可以在这里下mac软件用
9、常用软件更新 http://www.jianshu.com/p/923d1fbe0e51
cocoapods 更新
1,更新gem homebrew(brew)-》ruby-》gem
http://www.jianshu.com/p/78c3166be2f3
2,更新cocoapods 1、升级cocoapods
sudo gem install cocoapods --pre

2、降级cocoapods
执行sudo gem uninstall cocoapods 卸载现有 cocopods
sudo gem install cocoapods -v 0.39.0

3、更新本地cocoapods库
pod repo update --verbose
4、验证
再查看本地安装过的cocopods相关东西,命令如下:
gem list --local | grep cocoapods会显示如下
gem list --local|grep cocoapods cocoapods (1.2.0.beta.3, 1.1.1) cocoapods-core (1.2.0.beta.3, 1.1.1) cocoapods-deintegrate (1.0.1) cocoapods-downloader (1.1.3, 1.1.2) cocoapods-plugins (1.0.0) cocoapods-search (1.0.0) cocoapods-stats (1.0.0) cocoapods-trunk (1.1.2, 1.1.1) cocoapods-try (1.1.0)

    推荐阅读