1. 程式人生 > >ios_2017年安裝CocoaPods Mac OS 10.12.2 系統

ios_2017年安裝CocoaPods Mac OS 10.12.2 系統

CocoaPods使用步驟(已有Ruby環境):
(沒有Ruby環境也沒關係,後面會安裝升級的,或者翻我之前安裝Ruby環境文章也行)
(注:1., gem sources –remove https://rubygems.org/

為了驗證你的Ruby映象是並且僅是taobao,可以用以下命令檢視:
$ gem sources -l

只有在終端中出現下面文字才表明你上面的命令是成功的:

* CURRENT SOURCES *

1.5升級gem命令:$ sudo gem update –system

2.安裝CocoaPods,在終端輸入
$ sudo gem install cocoapods
這裡出現問題了.安裝不了,

下面是解決方法:
這個地方很坑,之前安裝cocoapods一直是沒有這個問題的,這裡提示Ruby版本要大於或等於2.2.2
於是檢視ruby版本
$ruby -v

ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]
果然這裡就要升級Ruby版本啦
檢視目前的所有ruby版本:
$rvm list known

如果提示command not found 請先安裝rvm

在Mac上安裝好ruby的RVM後,
在終端輸入時,出現rvm: command not found,經過OverStackFlow上的查詢,
發現瞭解決辦法:rvm: command not found MAC OX
可能是因為ram的shell配置沒有載入,在終端輸入:
$ source ~/.rvm/scripts/rvm

接著輸入:
$ type rvm | head -n 1

如果輸出是rvm is a function,
則需要將source ~/.rvm/scripts/rvm新增到~/.bash_profile檔案中。
$Sudo vi ~/.bash_profile

則需要將source ~/.rvm/scripts/rvm新增到~/.bash_profile檔案中。 然後儲存退出 $esc:wq

}
如果有ruby版本則不需要這行($curl -L get.rvm.io | bash -s stable )
如果已安裝會列出所有的ruby版本:

MRI Rubies

[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.8]
[ruby-]2.2[.4]
[ruby-]2.3[.0]
[ruby-]2.2-head
ruby-head

JRuby

jruby-1.6[.8]
jruby-1.7[.23]
jruby[-9.0.5.0]
jruby-head

Rubinius

rbx-1[.4.3]
rbx-2.3[.0]
rbx-2.4[.1]
rbx[-2.5.8]
rbx-head

Opal

opal

Minimalistic ruby implementation - ISO 30170:2012

mruby[-head]

Ruby Enterprise Edition

ree-1.8.6
ree[-1.8.7][-2012.02]

GoRuby

goruby

Topaz

topaz

MagLev

maglev[-head]
maglev-1.0.0

Mac OS X Snow Leopard Or Newer

macruby-0.10
macruby-0.11
macruby[-0.12]
macruby-nightly
macruby-head

IronRuby

ironruby[-1.1.3]
ironruby-head
這裡我們安裝2.2.2:
$rvm install 2.2.2
終端執行結果:(如果直接成功請繞過homebrew的解除安裝安裝)
Searching for binary rubies, this might take some time.
Checking requirements for osx.
About to install Homebrew, press Enter for default installation in /usr/local,
type new path if you wish custom Homebrew installation (the path needs to be writable for user)
回車:
It appears Homebrew is already installed. If your intent is to reinstall you
should do the following before running this installer again:
ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)”
The current contents of /usr/local are .git
Requirements installation failed with status: 1.
這裡執行:

(下面是解除安裝Home_brew的

)

$ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

解除安裝home-brew
Warning: This script will remove:
/Library/Caches/Homebrew/
/usr/local/.git/
Are you sure you want to uninstall Homebrew? [y/N] y
==> Removing Homebrew installation…
==> Removing empty directories…
==> Homebrew uninstalled!
You may want to restore /usr/local’s original permissions
sudo chmod 0755 /usr/local
sudo chgrp wheel /usr/local
再執行:
$ rvm install 2.2.2

提示:
Searching for binary rubies, this might take some time.
Checking requirements for osx.
About to install Homebrew, press Enter for default installation in /usr/local,
type new path if you wish custom Homebrew installation (the path needs to be writable for user)
按回車:
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/…
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew

Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/mkdir /Library/Caches/Homebrew
Password:
這裡需要輸入電腦密碼:
==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew
==> /usr/bin/sudo /usr/sbin/chown haha /Library/Caches/Homebrew
==> Downloading and installing Homebrew…
remote: Counting objects: 501, done.
remote: Compressing objects: 100% (445/445), done.
remote: Total 501 (delta 29), reused 360 (delta 27), pack-reused 0
Receiving objects: 100% (501/501), 787.83 KiB | 169.00 KiB/s, done.
Resolving deltas: 100% (29/29), done.
From https://github.com/Homebrew/brew
* [new branch] master -> origin/master
HEAD is now at 32f7e73 download_strategy: ensure fixed commit hash length
==> Tapping homebrew/core
Cloning into ‘/usr/local/Library/Taps/homebrew/homebrew-core’…
remote: Counting objects: 3714, done.
remote: Compressing objects: 100% (3598/3598), done.
remote: Total 3714 (delta 14), reused 2112 (delta 6), pack-reused 0
Receiving objects: 100% (3714/3714), 2.88 MiB | 240.00 KiB/s, done.
Resolving deltas: 100% (14/14), done.
Checking connectivity… done.
Checking out files: 100% (3717/3717), done.
Tapped 3591 formulae (3,740 files, 9.0M)
==> Installation successful!
==> Next steps
Run brew help to get started
Further documentation: https://git.io/brew-docs
==> Homebrew has enabled anonymous aggregate user behaviour analytics
Read the analytics documentation (and how to opt-out) here:
https://git.io/brew-analytics
Installing requirements for osx.
Updating system…..
Installing required packages: autoconf, automake, libtool, pkg-config, libyaml, readline, libksba, openssl……..
Certificates in ‘/usr/local/etc/openssl/cert.pem’ are already up to date.
Requirements installation successful.
ruby-2.2.2 - #configure
ruby-2.2.2 - #download
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6854k 100 6854k 0 0 61342 0 0:01:54 0:01:54 –:–:– 132k
ruby-2.2.2 - #validate archive
ruby-2.2.2 - #extract
ruby-2.2.2 - #validate binary
ruby-2.2.2 - #setup
ruby-2.2.2 - #gemset created /Users/haha/.rvm/gems/[email protected]
ruby-2.2.2 - #importing gemset /Users/haha/.rvm/gemsets/global.gems…………………………
ruby-2.2.2 - #generating global wrappers……..
ruby-2.2.2 - #gemset created /Users/haha/.rvm/gems/ruby-2.2.2
ruby-2.2.2 - #importing gemsetfile /Users/haha/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.2.2 - #generating default wrappers……..
Updating certificates in ‘/etc/openssl/cert.pem’.
mkdir: /etc/openssl: Permission denied
mkdir -p “/etc/openssl” failed, retrying with sudo
haha password required for ‘mkdir -p /etc/openssl’:
and sudo mkdir worked
這樣ruby2.2.2就安裝好了
現在就可以安裝cocoapods啦:
$sudo gem install cocoapods
看看這樣cocoapods就安裝成功了
Fetching: nap-1.1.0.gem (100%)
Successfully installed nap-1.1.0
Fetching: fourflusher-0.3.2.gem (100%)
Successfully installed fourflusher-0.3.2
Fetching: escape-0.0.4.gem (100%)
Successfully installed escape-0.0.4
Fetching: colored-1.2.gem (100%)
Successfully installed colored-1.2
Fetching: concurrent-ruby-1.0.2.gem (100%)
Successfully installed concurrent-ruby-1.0.2
Fetching: thread_safe-0.3.5.gem (100%)
Successfully installed thread_safe-0.3.5
Fetching: tzinfo-1.2.2.gem (100%)
Successfully installed tzinfo-1.2.2
Fetching: i18n-0.7.0.gem (100%)
Successfully installed i18n-0.7.0
Fetching: activesupport-5.0.0.gem (100%)
Successfully installed activesupport-5.0.0
Fetching: claide-1.0.0.gem (100%)
Successfully installed claide-1.0.0
Fetching: xcodeproj-1.1.0.gem (100%)
Successfully installed xcodeproj-1.1.0
Fetching: molinillo-0.4.5.gem (100%)
Successfully installed molinillo-0.4.5
Fetching: cocoapods-try-1.0.0.gem (100%)
Successfully installed cocoapods-try-1.0.0
Fetching: netrc-0.7.8.gem (100%)
Successfully installed netrc-0.7.8
Fetching: cocoapods-trunk-1.0.0.gem (100%)
Successfully installed cocoapods-trunk-1.0.0
Fetching: cocoapods-stats-1.0.0.gem (100%)
Successfully installed cocoapods-stats-1.0.0
Fetching: cocoapods-search-1.0.0.gem (100%)
Successfully installed cocoapods-search-1.0.0
Fetching: cocoapods-plugins-1.0.0.gem (100%)
Successfully installed cocoapods-plugins-1.0.0
Fetching: cocoapods-downloader-1.0.1.gem (100%)
Successfully installed cocoapods-downloader-1.0.1
Fetching: cocoapods-deintegrate-1.0.0.gem (100%)
Successfully installed cocoapods-deintegrate-1.0.0
Fetching: fuzzy_match-2.0.4.gem (100%)
Successfully installed fuzzy_match-2.0.4
Fetching: cocoapods-core-1.0.1.gem (100%)
Successfully installed cocoapods-core-1.0.1
Fetching: cocoapods-1.0.1.gem (100%)
Successfully installed cocoapods-1.0.1
Parsing documentation for nap-1.1.0
Installing ri documentation for nap-1.1.0
Parsing documentation for fourflusher-0.3.2
Installing ri documentation for fourflusher-0.3.2
Parsing documentation for escape-0.0.4
Installing ri documentation for escape-0.0.4
Parsing documentation for colored-1.2
Installing ri documentation for colored-1.2
Parsing documentation for concurrent-ruby-1.0.2
Installing ri documentation for concurrent-ruby-1.0.2
Parsing documentation for thread_safe-0.3.5
Installing ri documentation for thread_safe-0.3.5
Parsing documentation for tzinfo-1.2.2
Installing ri documentation for tzinfo-1.2.2
Parsing documentation for i18n-0.7.0
Installing ri documentation for i18n-0.7.0
Parsing documentation for activesupport-5.0.0
Installing ri documentation for activesupport-5.0.0
Parsing documentation for claide-1.0.0
Installing ri documentation for claide-1.0.0
Parsing documentation for xcodeproj-1.1.0
Installing ri documentation for xcodeproj-1.1.0
Parsing documentation for molinillo-0.4.5
Installing ri documentation for molinillo-0.4.5
Parsing documentation for cocoapods-try-1.0.0
Installing ri documentation for cocoapods-try-1.0.0
Parsing documentation for netrc-0.7.8
Installing ri documentation for netrc-0.7.8
Parsing documentation for cocoapods-trunk-1.0.0
Installing ri documentation for cocoapods-trunk-1.0.0
Parsing documentation for cocoapods-stats-1.0.0
Installing ri documentation for cocoapods-stats-1.0.0
Parsing documentation for cocoapods-search-1.0.0
Installing ri documentation for cocoapods-search-1.0.0
Parsing documentation for cocoapods-plugins-1.0.0
Installing ri documentation for cocoapods-plugins-1.0.0
Parsing documentation for cocoapods-downloader-1.0.1
Installing ri documentation for cocoapods-downloader-1.0.1
Parsing documentation for cocoapods-deintegrate-1.0.0
Installing ri documentation for cocoapods-deintegrate-1.0.0
Parsing documentation for fuzzy_match-2.0.4
Installing ri documentation for fuzzy_match-2.0.4
Parsing documentation for cocoapods-core-1.0.1
Installing ri documentation for cocoapods-core-1.0.1
Parsing documentation for cocoapods-1.0.1
Installing ri documentation for cocoapods-1.0.1
Done installing documentation for nap, fourflusher, escape, colored, concurrent-ruby, thread_safe, tzinfo, i18n, activesupport, claide, xcodeproj, molinillo, cocoapods-try, netrc, cocoapods-trunk, cocoapods-stats, cocoapods-search, cocoapods-plugins, cocoapods-downloader, cocoapods-deintegrate, fuzzy_match, cocoapods-core, cocoapods after 146 seconds
23 gems installed

5.現在建一個工程,叫CocoaPodsDemo

6.CocoaPods的工作原理是利用Podfile檔案來下載我們指定的類庫,每個工程只需要一個Podfile檔案,但Podfile檔案需要我們利用終端自行建立

7.在終端中使用cd命令進入工程所在目錄,例如:
$ cd /Users/lanouhn/Desktop/Shared/CocoaPods

8.當前目錄下,利用vim建立Podfile,在終端中輸入:
$ vim Podfile

9.按【i】或【a】進入插入模式,輸入以下內容:
原因是podfile升級到最新版本,pod裡的內容必須明確指出所用第三方庫的target;可以修改Podfile檔案的配置檔案,讓它相容不指定固定版本;且又不報錯;

platform :ios, ‘7.0’
target ‘CocoaPodsDemo’ do
pod ‘AFNetworking’, ‘~> 2.4.1’
end

其中CocoaPodsDemo要換成當前target名,最後不要忘記增加一個end結尾,

(這兩行內容是在AFNetworking的github頁面找到的。
這兩句文字的意思是,當前AFNetworking支援的iOS最高版本是iOS 7.0, 要下載的AFNetworking版本是2.0)

輸入完畢後,按【ESC】返回命令列模式
按【:】(冒號)進入末行模式,輸入【wq】儲存命令並退出vim

10.這時你會發現工程目錄中,出現一個名為Podfile的檔案,而且檔案內容就是剛剛輸入的內容。
(注意,Podfile檔案應該和工程檔案.xcodeproj在同一個目錄下)

此時就可以利用CocoPods下載AFNetworking類庫了,還是在終端中的當前工程目錄下,執行以下命令:
$ pod install
(個人猜測,執行該命令後,CocoPods自動會找到該目錄下的Podfile檔案,下載檔案內容對應的第三方類庫)
[ps.最近使用CocoaPods來新增第三方類庫,無論是執行pod install還是pod update都卡在了Analyzing dependencies不動
原因在於當執行以上兩個命令的時候會升級CocoaPods的spec倉庫,加一個引數可以省略這一步,然後速度就會提升不少。

加引數的命令如下:
pod install –verbose –no-repo-update
pod update –verbose –no-repo-update
或者 pod update 以及 pod install 也可以

11.執行完畢後,終端會出現以下資訊:
EricmatoMacBook-Pro:CocoaPodsDemo ericwang$ pod install
Analyzing dependencies
Downloading dependencies
Installing AFNetworking (2.0.2)
Generating Pods project
Integrating client project

[!] From now on use CocoaPodsDemo.xcworkspace.

(注意最後一句話,意思是:以後開啟工程就用 CocoaPodsDemo.xcworkspace 開啟,而不是之前的.xcodeproj檔案)

12.此時工程目錄會多一個.xcworkspace檔案,一個“Podfile.lock”檔案和一個資料夾“Pods”

13.點選 .xcworkspace 開啟工程,你會發現,AFNetwoking已經成功匯入專案了

現在,你就可以開始使用AFNetworking.h了。
可以稍微測試一下,在你的專案任意程式碼檔案中輸入(貌似不提示):

import

import “AFNetworking.h”

然後編譯,看看是否出錯
*/
/*
提示我們從現在起,我們需要使用CocoaPodsTest.xcworkspace檔案來開發。

對於工程發生的變化,有幾點需要說明:

第三方庫會被編譯成靜態庫供我們真正的工程使用

CocoaPods會將所有的第三方庫以target的方式組成一個名為Pods的工程,該工程就放在剛才新生成的Pods目錄下。整個第三方庫工程會生成一個名稱為libPods.a的靜態庫提供給我們自己的CocoaPodsTest工程使用。

我們的工程和第三方庫所在的工程會由一個新生成的workspace管理

為了方便我們直觀的管理工程和第三方庫,CocoaPodsTest工程和Pods工程會被以workspace的形式組織和管理,也就是我們剛才看到的CocoaPodsTest.xcworkspace檔案。

原來的工程設定已經被更改了,這時候我們直接開啟原來的工程檔案去編譯就會報錯,只能使用新生成的workspace來進行專案管理。\

pod –verson 查詢當前版本
這是系統重灌之後今天安裝的方法,安裝不到一個小時就搞好了,上一次安裝都被坑了,
坑人的格式,有一些顯示的和我寫的不一樣.太噁心了

相關推薦

ios_2017安裝CocoaPods Mac OS 10.12.2 系統

CocoaPods使用步驟(已有Ruby環境): (沒有Ruby環境也沒關係,後面會安裝升級的,或者翻我之前安裝Ruby環境文章也行) (注:為提示作用,不要在終端中輸入)1.打開終端,輸入 gem sources –remove https://rub

vmware workstation 12 pro 安裝Mac OS 10.12.4系統

6、開啟虛擬機器,新建 虛擬機器點選下一步,選中系統E:\BaiduYunDownload\macOS S 10.12.4(16E195)(MD5-44E6A3EC38BB85CA49A68382D10FB264).cdr

Mac OS 10.12安裝caffe的步驟記錄

準本工作: 1、安裝Xcode,MacOS下的編譯工作需要用到,如果沒有安裝,可以到AppStore裡進行安裝 2、Python 可以不用安裝,系統自帶了2.7版本的python 3、brew,這個是個智慧化的安裝工具,非常好用,如果沒有安裝可以用下面的方法來安裝 ruby -e "$(cu

2018VMware虛擬機器安裝Mac OS 10.12.1

說明:該篇部落格是博主一字一碼編寫的,實屬不易,請尊重原創,謝謝大家! 一.下載安裝中所需的映象檔案以及補丁工具 Mac OS 10.12.1 Sierra (16B2555) 懶人版(下載地址):https://pan.baidu.com/s/1y7XCqsWuxrLtmBY

虛擬機器VirtualBox安裝MAC OS 10.12圖文教程

注:本文來自轉載,原文連結https://www.cnblogs.com/liming2017/p/7566953.html,只不過加了一個紫色注意部分,我自己在解壓時候操作不對,導致安裝失敗,所以發個部落格VirtualBox虛擬機器安裝Mac OS 10.12圖文教程的準

win10下使用VMware12安裝MAC OS 10.12遇到的問題,無MAC OS安裝選項,無法安裝VMwareTools等

參考教程為:http://bbs.pcbeta.com/forum.php?mod=viewthread&tid=1726460&page=21#pid46861638 個人補充的地方:虛擬機器預設使用虛擬記憶體功能(即使用硬碟代替部分記憶體),導致宿主機和

MAC OS 10.12 安裝任意來源應用

在終端輸入sudo spctl --master-disable 在提示下輸入密碼並回車就可以了。 在新的系統版本中,為了方便大家操作,新增加了 “仍要開啟” 選項,方便開啟不受信任的程式。操作流程為,系統提示“不能開啟 XX 程式” 或 “XX 程式不完

Mac OS 10.12使用U盤重裝(轉)

password and 存在 log lan 桌面 回車 sta -1 OS X Capitan和macOS Sierra的安裝方式和下載系統的方法都是一致的,下面是OS X Capitan的安裝方法: 一、準備工作: 準備一個8GB或者8G以上容量的U盤 確

Mac OS 10.12 編譯Android原始碼:錯誤小結

在Mac OS 10.12 編譯Android原始碼 錯誤小結 記錄自己遇到的一些問題 1、在Terminal跳轉到映象目錄的命令是 cd /Volumes/映象名稱 即建立的磁碟映象是在根目錄下的Volumes資料夾 2、在通過ma

Appium之mac OS 10.12.5+Xcode 8.3.2 配置使用

1、下載或者更新Homebrew:        homebrew官網 macOS 不可或缺的套件管理器 $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebre

華碩B85 pro gamer +i5 4590 +GTX960 成功安裝黑蘋果 macOS 10.12.2

其實現在安裝都挺簡單的,都是大神們弄好了,不像前幾年複雜的要死,而且還不一定成功。安裝的方式有很多種,變色龍和四葉草都可以,我一開始用的就是四葉草的u盤uefi方式安裝。現在說一下我的安裝方式,如果你也想裝,希望我的安裝過程能給你一些幫助吧。簡單步驟1.刻啟動u盤首先下載系統的映象檔案Usb_Clover_m

mac os 10.13下安裝配置cocoapods並在xcode中使用

關閉SIP保護 10.3.4版本下macOS開啟了SIP保護,即便是root使用者也不能修改系統目錄中的檔案,所以要安裝cocoapods,需要先關閉這個服務 方法如下 1. 重啟電腦按住comm

《VMware安裝Mac OS 10.11.6》

leo cbe 權限 截圖 watermark 中文簡體 紅色 密碼 跟著 準備工作:VMware 11.1.0(虛擬化平臺)Unlocker204(破解VMware插件)El Capitan 10.11.6 Installer.cdr(Mac OS X鏡像) 百度資源:u

VirtualBox安裝Mac OS 10.11——虛擬機安裝黑蘋果

cmd set 安裝完成 環境 config true == 時區 tail 由於需要安裝mac環境跑IOS應用,所以在虛擬機裝個黑蘋果. 一、下載虛擬機安裝包,VirtualBox是官網下的最新版: 5.0.6 for Windows hosts x86/amd64

VMware 15 安裝 MAC OS 10.13 原版(詳細圖文教程)

VMware 15 安裝 MAC OS 10.13 原版(詳細圖文教程) 生命在於折騰,之前本想裝個雙系統黑蘋果,什麼 U 盤啟動盤,四葉草引導,都配置好了,最後跪在一個動態捲上,備份格盤現在弄不了,先裝個 VMware 上跑的。 本篇文章收錄所有新手常見問題,如果不是第一次安裝

vm安裝蘋果mac os系統 10.14.cdr

原文地址::https://blog.csdn.net/iwave8080/article/details/83146052   相關文章 1、蘋果mac os Mojave系統10.14.1(懶人版)_cdr----https://download.csdn.net/down

Mac OS 10.11上安裝python, pyqt

1.首先安裝homebrew,通過在終端中執行如下的命令: ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"  2.接著安裝python brew install python

VMware15安裝MACMAC OS 10.13)(OS X 10.14)原版可升級最新可解鎖macOS Unlocker3.0(OS X 10.13)

  目錄樹 1.1.2安裝環境: 1.1.5 配置環境 1.1.4 Unlocker 3.0解鎖 1.1.3所需資源: 1.1.6開始安裝 1.1.7開啟虛擬機器進入MAC安裝介面 1.1.8 macOS 10.13 安裝允許任何來源沒了怎

virtualbox虛擬機器安裝Mac OS 10.6.x全過程

注意:                 要先檢查你的機器是否符合安裝虛擬Mac OS的條件,下載cpu_zs.zip,我就不給下載地址了,很好找                                                             

VirtualBox安裝Mac OS 10.11——虛擬機器安裝黑蘋果

VirtualBox安裝Mac OS 10.11 ,安裝日期:2016 / 5 / 14 用虛擬機器裝黑蘋果本人也裝了不下3次了,這次為了做這個教程還特意把virtualbox和舊版的Mac OS刪了,重新再裝一遍。 所以保證能執行,不像網上其他教程都是匯出複製,還不要臉