https://www.jianshu.com/p/39f22e82c97f
https://www.cnblogs.com/yaogengzhu/p/10833285.html
-bash: rvm: command not found之刨根問底
https://www.jianshu.com/p/f5591af6859d
關於CocoaPods,是OS X和iOS下的一個第三方類庫管理工具,它的好處這里不多說,主要說下如何安裝CocoaPods。
CocoaPods的安裝需要Ruby環境,Mac系統都自帶Ruby,通過下面終端命令查看Ruby版本:ruby -v
~$ruby -v
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
CocoaPods支持的Ruby最低版本是2.2.2,如果自己的版本低於2.2.2就需要更新升級Ruby:sudo gem update --system
更換Ruby鏡像
Ruby默認的源地址是國外網絡地址,通過下面終端命令查看當前鏡像地址:gem sources -l
~$gem sources -l /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/universal-darwin18/rbconfig.rb:215: warning: Insecure world writable dir /Applications/Cocos/tools/ant/bin in PATH, mode 040777 *** CURRENT SOURCES *** https://rubygems.org/
首先移除當前鏡像gem sources --remove https://rubygems.org/
~$gem sources --remove https://rubygems.org/ /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/universal-darwin18/rbconfig.rb:215: warning: Insecure world writable dir /Applications/Cocos/tools/ant/bin in PATH, mode 040777 https://rubygems.org/ removed from sources
然后添加國內最新Ruby鏡像地址gem sources -a https://gems.ruby-china.com/
~$gem sources -a https://gems.ruby-china.com/ /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/universal-darwin18/rbconfig.rb:215: warning: Insecure world writable dir /Applications/Cocos/tools/ant/bin in PATH, mode 040777 https://gems.ruby-china.com/ added to sources
這時候再查看鏡像地址就是這樣的了
~$gem sources -l /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/universal-darwin18/rbconfig.rb:215: warning: Insecure world writable dir /Applications/Cocos/tools/ant/bin in PATH, mode 040777 *** CURRENT SOURCES *** https://gems.ruby-china.com/
安裝CocoaPods
Ruby環境安裝好以后,接下來就是安裝CocoaPods,終端輸入:sudo gem install cocoapods
~$sudo gem install cocoapods Password: ...... Done installing documentation for concurrent-ruby, i18n, thread_safe, tzinfo, activesupport, nap, fuzzy_match, cocoapods-core, claide, cocoapods-deintegrate, cocoapods-downloader, cocoapods-plugins, cocoapods-search, cocoapods-stats, netrc, cocoapods-trunk, cocoapods-try, molinillo, atomos, CFPropertyList, colored2, nanaimo, xcodeproj, escape, fourflusher, gh_inspector, ruby-macho, cocoapods after 33 seconds 28 gems installed
如果終端出現上面的提示,表示安裝成功。到這里還剩最后一步,還需執行命令:pod setup
這一步可能需要耐心等待,需要下載上百M的文件。
~$pod setup
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/universal-darwin18/rbconfig.rb:215: warning: Insecure world writable dir /Applications/Cocos/tools/ant/bin in PATH, mode 040777
Setting up CocoaPods master repo
$ /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress
Cloning into 'master'...
remote: Enumerating objects: 179, done.
remote: Counting objects: 100% (179/179), done.
remote: Compressing objects: 100% (135/135), done.
remote: Total 2819986 (delta 66), reused 64 (delta 42), pack-reused 2819807
Receiving objects: 100% (2819986/2819986), 614.27 MiB | 834.00 KiB/s, done.
Resolving deltas: 100% (1676501/1676501), done.
Checking out files: 100% (304760/304760), done.
Setup completed
至此,CocoaPods安裝完成!
使用CocoaPods
在使用之前,我們先驗證下CocoaPods是否安裝成功,搜索一個第三方庫。終端輸入:~$pod search AFNetworking
正常情況下,這是會提示Creating search index for spec repo 'master'...
等待一會就會出現搜索結果了(也可能需要等待很長時間,大約二十幾分鍾,不要着急,耐心等待就行😂)。

出現上圖這個就說明成功了。直接按“Q”鍵就可以退出。
接下來,終端進入iOS項目工程的根目錄(就是*.xcodeproj所在的目錄),然后創建Podfile文件,終端輸入:~$touch Podfile
這時工程目錄下多了一個Podfile文件。
現在我們要接入Admob廣告SDK,就可以使用CocosPods的方法,用編輯器打開Podfile文件,並將下面的的代碼加到里面:
platform :ios, '8.0' target 'MyApp' do pod 'Google-Mobile-Ads-SDK' end
其中,MyApp應該是你項目中的Target名稱。文件保存后,在終端中輸入~$pod install
。
安裝成功后,工程目錄中會生成一個*.xcworkspace文件。
以后打開工程就打開這個文件,不再使用*.xcodeproj文件。
問題報錯
當我們打開*.xcworkspace文件使用Xcode編譯時,可能會報這么一個錯誤:
diff: /../Podfile.lock: No such file or directory diff: /Manifest.lock: No such file or directory error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.
作者:吃菜小怪獸
鏈接:https://www.jianshu.com/p/39f22e82c97f
來源:簡書
著作權歸作者所有。商業轉載請聯系作者獲得授權,非商業轉載請注明出處。
Homebrew是一個包管理器,用於在Mac上安裝一些OSX上沒有的UNIX工具(比如wget)。
brew官網
1.安裝,打開終端,復制粘貼,大約1分鍾左右,下載完成,過程中需要輸入密碼,其他無需任何操作:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2.卸載,有安裝就要有卸載,打開終端,復制粘貼:
其實只用把上面安裝的install換成uninstall就行了。
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
3.Homebrew 怎么使用?常用命令有哪些?
安裝軟件,如:brew install oclint
卸載軟件,如:brew uninstall oclint
搜索軟件,如:brew search oclint
更新軟件,如:brew upgrade oclint
查看安裝列表, 如:brew list
更新Homebrew,如:brew update
使用brew安裝wget:
brew install wget
秘籍一:使用wget更新hosts
wget https://raw.githubusercontent.com/racaljk/hosts/master/hosts -qO /tmp/hosts && sudo sh -c 'cat /tmp/hosts > /etc/hosts'
mac--“-bash: brew: command not found”,怎么解決?
報錯
1
|
“
-
bash: brew: command
not
found”
|
執行下面命令,安裝HomeBrew
1
|
ruby
-
e
"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
此時報錯:
1
2
|
Error: Failure
while
executing: git clone https:
/
/
github.com
/
Homebrew
/
homebrew
-
core
/
usr
/
local
/
Library
/
Taps
/
homebrew
/
homebrew
-
core
-
-
config core.autocrlf
=
false
-
-
depth
=
1
-
q
Error: Failure
while
executing:
/
usr
/
local
/
bin
/
brew tap homebrew
/
core
-
q
|
依次執行下面兩行命令即可成功解決
1、sudo chown -R apple:staff * 2、brew doctor
命令執行完之后HomeBrew也就安裝好了
好了,小伙伴們,可以開始你們的操作啦
brew install xxx 安裝xxx brew uninstall xxx 卸載xxx brew update xxx 更新xxx brew doctor 修復brew