cocopods安装使用和安装过程中遇到的问题及解决办法
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了cocopods安装使用和安装过程中遇到的问题及解决办法相关的知识,希望对你有一定的参考价值。
在osx 10.11之前cocopods问题不多,但是升级到11之后的版本,之前的cocopods大多用不了,需要重新安装,对于我这种使用测试版系统的技术狂来说,每次都需要重新安装很多东西,
当然,cocopods也避免不了安装很多次了。
对于新手来说,使用cocopods开发,还是节省了相当多的开发时间,以下便是cocopods安装和安装过程中遇到的问题及解决办法:
1 boai:~ boai$ sudo gem install cocoapods 2 ERROR: Could not find a valid gem ‘cocoapods‘ (>= 0), here is why: 3 Unable to download data from http://ruby.taobao.org/ - bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz) 4 boai:~ boai$ sudo gem install cocoapods 5 ERROR: Could not find a valid gem ‘cocoapods‘ (>= 0), here is why: 6 Unable to download data from http://ruby.taobao.org/ - bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz) 7 boai:~ boai$ sudo gem update --system 8 ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError) 9 bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
解决办法:
(1)先执行下面两行代码:
1 sudo gem sources -r https://rubygems.org
2 sudo gem sources -a http://rubygems.org
(2)执行过程如下:
1 boai:~ boai$ sudo gem sources -r https://rubygems.org 2 source https://rubygems.org not present in cache 3 boai:~ boai$ sudo gem sources -a http://rubygems.org 4 https://rubygems.org is recommended for security over http://rubygems.org 5 6 Do you want to add this insecure source? [yn] y
最后会提示
Do you want to add this insecure source? [yn]
你选择 y就行了
然后出现:
http://rubygems.org added to sources
这就说明成功了,就可以执行下面的安装了。
(3)安装cocopods
执行下面的语句:
1 sudo gem install cocoapods
会出现下面的界面:(激动。。。)
boai:~ boai$ sudo gem install cocoapods Fetching: nap-1.0.0.gem (100%) Successfully installed nap-1.0.0 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-4.2.5.gem (100%) Successfully installed activesupport-4.2.5 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: molinillo-0.4.0.gem (100%) Successfully installed molinillo-0.4.0 Fetching: netrc-0.7.8.gem (100%) Successfully installed netrc-0.7.8 Fetching: cocoapods-trunk-0.6.4.gem (100%) Successfully installed cocoapods-trunk-0.6.4 Fetching: cocoapods-try-0.5.1.gem (100%) Successfully installed cocoapods-try-0.5.1 Fetching: cocoapods-stats-0.6.2.gem (100%) Successfully installed cocoapods-stats-0.6.2 Fetching: cocoapods-search-0.1.0.gem (100%) Successfully installed cocoapods-search-0.1.0 Fetching: cocoapods-plugins-0.4.2.gem (100%) Successfully installed cocoapods-plugins-0.4.2 Fetching: cocoapods-downloader-0.9.3.gem (100%) Successfully installed cocoapods-downloader-0.9.3 Fetching: claide-0.9.1.gem (100%) Successfully installed claide-0.9.1 Fetching: xcodeproj-0.28.2.gem (100%) Successfully installed xcodeproj-0.28.2 Fetching: fuzzy_match-2.0.4.gem (100%) Successfully installed fuzzy_match-2.0.4 Fetching: cocoapods-core-0.39.0.gem (100%) Successfully installed cocoapods-core-0.39.0 Fetching: cocoapods-0.39.0.gem (100%) Successfully installed cocoapods-0.39.0 Parsing documentation for nap-1.0.0 Installing ri documentation for nap-1.0.0 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-4.2.5 Installing ri documentation for activesupport-4.2.5 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 molinillo-0.4.0 Installing ri documentation for molinillo-0.4.0 Parsing documentation for netrc-0.7.8 Installing ri documentation for netrc-0.7.8 Parsing documentation for cocoapods-trunk-0.6.4 Installing ri documentation for cocoapods-trunk-0.6.4 Parsing documentation for cocoapods-try-0.5.1 Installing ri documentation for cocoapods-try-0.5.1 Parsing documentation for cocoapods-stats-0.6.2 Installing ri documentation for cocoapods-stats-0.6.2 Parsing documentation for cocoapods-search-0.1.0 Installing ri documentation for cocoapods-search-0.1.0 Parsing documentation for cocoapods-plugins-0.4.2 Installing ri documentation for cocoapods-plugins-0.4.2 Parsing documentation for cocoapods-downloader-0.9.3 Installing ri documentation for cocoapods-downloader-0.9.3 Parsing documentation for claide-0.9.1 Installing ri documentation for claide-0.9.1 Parsing documentation for xcodeproj-0.28.2 Installing ri documentation for xcodeproj-0.28.2 Parsing documentation for fuzzy_match-2.0.4 Installing ri documentation for fuzzy_match-2.0.4 Parsing documentation for cocoapods-core-0.39.0 Installing ri documentation for cocoapods-core-0.39.0 Parsing documentation for cocoapods-0.39.0 Installing ri documentation for cocoapods-0.39.0 Done installing documentation for nap, thread_safe, tzinfo, i18n, activesupport, escape, colored, molinillo, netrc, cocoapods-trunk, cocoapods-try, cocoapods-stats, cocoapods-search, cocoapods-plugins, cocoapods-downloader, claide, xcodeproj, fuzzy_match, cocoapods-core, cocoapods after 21 seconds WARNING: Unable to pull data from ‘http://ruby.taobao.org/‘: bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz) 20 gems installed
看到最后一行代码,你就放120个心吧。。。
然后就可以查看你的pods版本了:
输入:pod
然后会出现下面的代码:
boai:~ boai$ pod Usage: $ pod COMMAND CocoaPods, the Cocoa library package manager. Commands: + cache Manipulate the CocoaPods cache + init Generate a Podfile for the current directory. + install Install project dependencies to Podfile.lock versions + ipc Inter-process communication + lib Develop pods + list List pods + outdated Show outdated project dependencies + plugins Show available CocoaPods plugins + repo Manage spec-repositories + search Search for pods. + setup Setup the CocoaPods environment + spec Manage pod specs + trunk Interact with the CocoaPods API (e.g. publishing new specs) + try Try a Pod! + update Update outdated project dependencies and create new Podfile.lock Options: --silent Show nothing --version Show the version of the tool --verbose Show more debugging information --no-ansi Show output without ANSI codes --help Show help banner of specified command boai:~ boai$
这就安装成功了,就可以正常使用pod了。。。
3、接下来就可以在项目中使用了,
打开终端:
cd 你的项目路径
boai:~ boai$ cd /Users/boai/Documents/博爱项目/BAPDCViewTest
然后:输入touch podfile
boai:BAPDCViewTest boai$ touch podfile boai:BAPDCViewTest boai$ pod install
接下来出现:
Last login: Fri Nov 20 11:02:59 on ttys006 boai:~ boai$ cd /Users/boai/Documents/博爱项目/BAPDCViewTest boai:BAPDCViewTest boai$ touch podfile boai:BAPDCViewTest boai$ pod install Updating local specs repositories Analyzing dependencies Downloading dependencies Generating Pods project Integrating client project [!] Please close any current Xcode sessions and use `BAPDCViewTest.xcworkspace` for this project from now on. Sending stats Pod installation complete! There are 0 dependencies from the Podfile and 0 total pods installed. [!] [!] The Podfile does not contain any dependencies. boai:BAPDCViewTest boai$
这就成功了,然后再看看你的项目路径里面,是不是多出来很多文件?
如下图:
然后双击***.workspace 文件就可以使用pods了!
好了,大功告成!
转:http://www.cnblogs.com/boai/p/4977976.html
以上是关于cocopods安装使用和安装过程中遇到的问题及解决办法的主要内容,如果未能解决你的问题,请参考以下文章