cocopod安装问题 ,按教程每次都何曼婷 只能走到这里里然后就完了,怎么都安装不成功

& & & &在osx 10.11之前cocopods问题不多,但是升级到11之后的版本,之前的cocopods大多用不了,需要重新安装,对于我这种使用测试版系统的技术狂来说,每次都需要重新安装很多东西,
当然,cocopods也避免不了安装很多次了。
& & & &对于新手来说,使用cocopods开发,还是节省了相当多的开发时间,以下便是cocopods安装和安装过程中遇到的问题及解决办法:
1、cocopods 安装:
【注:可以直接从第二步开始安装】
2、出现以下问题,大家不要慌:
1 boai:~ boai$ sudo gem install cocoapods
Could not find a valid gem 'cocoapods' (&= 0), here is why:
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
Could not find a valid gem 'cocoapods' (&= 0), here is why:
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
While executing gem ... (Gem::RemoteFetcher::FetchError)
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
6 Do you want to add this insecure source? [yn]
最后会提示
Do you want to add this insecure source? [yn]
你选择 y就行了然后出现:
http://rubygems.org added to sources
这就说明成功了,就可以执行下面的安装了。
3、安装cocopods
执行下面的语句:
&1 sudo gem install cocoapods&
据说新版本改了,没有验证,大家可以试试看:
sudo gem install -n /usr/local/bin 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
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版本了:
然后会出现下面的代码:
boai:~ boai$ pod
$ pod COMMAND
CocoaPods, the Cocoa library package manager.
Manipulate the CocoaPods cache
Generate a Podfile for the current directory.
Install project dependencies to Podfile.lock versions
Inter-process communication
Develop pods
+ outdated
Show outdated project dependencies
Show available CocoaPods plugins
Manage spec-repositories
Search for pods.
Setup the CocoaPods environment
Manage pod specs
Interact with the CocoaPods API (e.g. publishing new specs)
Try a Pod!
Update outdated project dependencies and create new
Podfile.lock
Show nothing
Show the version of the tool
Show more debugging information
Show output without ANSI codes
Show help banner of specified command
boai:~ boai$
这就安装成功了,就可以正常使用pod了。。。
4、接下来就可以在项目中使用了,
打开终端:
cd 你的项目路径
boai:~ boai$ cd /Users/boai/Documents/博爱项目/BAPDCViewTest
然后:输入touch podfile &或者 pod init (会自动生成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了!
5、新版本pod 安装问题:
podfile升级之后到最新版本,pod里的内容必须明确指出所用第三方库的target,否则会出现The dependency `` is not used in any concrete target这样的错误。
以下从三个步骤陈述:
4.1. Podfile升级
查看pod版本:
pod --version
&pod 升级(此时是升级到1.0.0.beta.2版本):
sudo gem install cocoapods --pre
4.2. 错误内容:
我的Podfile的内容是:
pod &SDWebImage&, &3.6&
pod install后出现错误The dependency `` is not used in any concrete target
pod install
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/universal-darwin14/rbconfig.rb:213: warning: Insecure world writable dir /Applications/Cocos/tools/ant/bin in PATH, mode 040777
Re-creating CocoaPods due to major version update.
Updating local specs repositories
Analyzing dependencies
The dependency `SDWebImage (= 3.6)` is not used in any concrete target.
4.3. 修改方法:
Podfile内容更改:
4.3.1 双击双击***.workspace 文件,打开项目
4.3.2 拉到最下面,找到pods,打开后点击podfile文件,
4.3.3 在podfile里面添加所需要的三方库
最终的podfile 文件规范内容为下:
# Uncomment this line to define a global platform for your project
# platform :ios, '8.0'
# Uncomment this line if you're using Swift
# use_frameworks!# 注意:xcodeproj '***.xcodeproj'
这句新版本必须要写上,***为你的工程名字,最下面记得要加上
xcodeproj 'BABaseProject.xcodeproj'
# 去掉由pod引入的第三方库的警告,需要更新命令才生效
inhibit_all_warnings!
target 'BABaseProject' do
# 对系统原生的AutoLayout 的 NSLayoutConstraints类的封装,优雅的链式语法,GitHub 排名第三
pod 'Masonry', '~& 0.6.4'
# 两个都是自动布局框架
pod 'SDAutoLayout', '~& 1.31'
# 自定义button框架
pod 'BAButton', '~& 1.0.1'
target 'BABaseProjectTests' do
target 'BABaseProjectUITests' do
&4.3.4 完成podfile 的内容更改后,记得 cmd + s 保存更改,然后打开终端
4.3.5 &在终端中cd 项目路径,打开项目后,输入:&
pod install --verbose --no-repo-update
pod update --verbose --no-repo-update
pod install --no-repo-update
pod update --no-repo-update
然后看你的项目路径pod下面, 是不是已经添加了你所需要的三方库呢?
5、最后给大家点推荐内容:
5.1、一个基于 MVVM 和 MVC 设计模式的基本项目框架,项目用到的各种类,各种封装,各种三方库的综合项目,欢迎大家使用!
有了一个基于 MVVM 和 MVC 设计模式的基本项目框架,以后开发项目再也不用担心自己搭建框架了!
5.2、完全实现的自定义的类库&
博爱的博客:&
博爱的博客园:&
博爱的简书:&
简书专题链接:/collections/250078/submissions
好了,大功告成!
阅读(...) 评论()安装IOS第三方管理库&CocoaPods遇到的一些问题以及解决办法
很早就听说
CocoaPods了,但是一直没有来得及使用它。只是听说它很强大,在开发iOS项目的时候,可以用它来轻松的管理一些第三方的库。比如说,你的项目中用到了AFNetWork、ASI或者SDWebImage等第三方库,如果你的项目过大,那么你可能要用到第三方库就比较多,如果单纯的通过手动去下载和管理这些库的话,会比较麻烦,因为这些库随时可能会更新,那么你就不得不将原来的这些删除掉,下载最新的第三方库进行替换,每次都这样操作的话,势必显得很麻烦。那么CocoaPods就帮我们很好的解决了这个问题,可以通过CocoaPods来轻松的管理各个第三方库。
以下操作,都需要在终端中进行操作!
关于CocoaPods的下载和安装:首先,在安装CocoaPods之前,您的系统中要安装ruby环境,关于如何安装ruby的话,还是从网上查查资料吧。对此没有做过多的了解,因为我的mac本身已经自动安装了ruby。不过需要先进行升级ruby,保持ruby为最新的。输入的命令如下:
sudo gem update --system
升级完成以后,就可以安装CocoaPods了。
安装CocoaPods的命令行如下:
sudo gem install cocoapods
安装成功以后,会有 Successfully installed cocoaPods的提示。不过我在用pod
setup命令的时候,遇到了如下的错误提示:
xcrun: error: active developer path
("/Applications/Xcode.app/Contents/Developer") does not exist, use
xcode-select to change
/Library/Ruby/Gems/2.0.0/gems/claide-0.7.0/lib/claide/command.rb:343:in
`help!': [!] CocoaPods requires git version 1.7.5 or newer. Please
update git. (CLAide::Help)
首先,从错误提示看,是我的git版本过低造成的,我就去升级了我的git。不过安装git最新版本以后,我输入了git
--version查看git的版本的时候,还是提示这个错误。从网上搜了一下关于xcrun: error: active
developer path ("/Applications/Xcode.app/Contents/Developer") does
not exist, use xcode-select to change的问题。从网上找到了解决的办法:
mac 命令行里 编译 链接 出现xcrun: error: active developer path
mac cc 编译出现
xcrun: error: active developer path ("/Volumes/Xcode/Xcode.app/Contents/Developer") does not exist, use xcode-select to change
在命令行里输入
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
就可以解决里
按照别人的这种方法,进行了操作,可是还是提示这个错误。想了好久,不知道错在哪里。后来突然想到,应该是路径不对,没有找到Xcode的路径。因为这里
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer是Xcode.app。而我把Xcode的名字改为了Xcode6.1。觉得应该是它的问题,就在终端中输入了:sudo xcode-select -switch /Applications/Xcode6.1.app/Contents/Developer这次没有错误提示了。再次输入pod setup的时候,提示我:Setup completed
输入:git --version 也成功了。
提示:git version 1.9.3 (Apple Git-50)
好了,基本上大功告成了,CocoaPods已经安装成功了。
操作一下看看,CocoaPods如何使用呢。搜索一下关于Reachability这个库。
输入命令:pod search Reachability
搜索结果如下:我们可以看到关于Reachability的一些信息。
-& CYReachability (0.2.0)
&& Reachability for chewing.
&& pod 'CYReachability', '~& 0.2.0'
&& - Homepage: /chewyong/CYReachability
&& - Source:&& /chewyong/CYReachability.git
&& - Versions: 0.2.0, 0.1.0 [master repo]
-& FXReachability (1.3)
&& Lightweight reachability class for Mac and iOS.
&& pod 'FXReachability', '~& 1.3'
&& - Homepage: /nicklockwood/FXReachability
&& - Source:&& /nicklockwood/FXReachability.git
&& - Versions: 1.3, 1.2, 1.1.1, 1.1, 1.0 [master repo]
-& GCNetworkReachability (1.3.2)
&& GCNetworkReachability monitors the network state on iOS and OS X devices.
&& Supports ARC, GCD, Blocks, IPv4/IPv6 and OS X/iOS.
&& pod 'GCNetworkReachability', '~& 1.3.2'
&& - Homepage: /GlennChiu/GCNetworkReachability
&& - Source:&& /GlennChiu/GCNetworkReachability.git
&& - Versions: 1.3.2, 1.3.0, 1.2.1 [master repo]
-& JTSReachability (1.1.0)
&& Adaptation of Apple's Reachability with some block-based conveniences.
&& pod 'JTSReachability', '~& 1.1.0'
&& - Homepage: /jaredsinclair/JTSReachability
&& - Source:&& /jaredsinclair/JTSReachability.git
&& - Versions: 1.1.0, 1.0.2, 1.0.1 [master repo]
-& KSReachability (1.4)
&& A better iOS & Mac reachability for a modern age.
&& pod 'KSReachability', '~& 1.4'
&& - Homepage: /kstenerud/KSReachability
&& - Source:&& /kstenerud/KSReachability.git
&& - Versions: 1.4, 1.3, 1.1, 1.0, 0.0.1 [master repo]
-& MCTReachability (1.0.0)
&& MCTReachability is a replacement for Reachability
&& pod 'MCTReachability', '~& 1.0.0'
&& - Homepage: /ministrycentered/MCTReachability
&& - Source:&& /ministrycentered/MCTReachability.git
&& - Versions: 1.0.0 [master repo]
-& NPReachability (0.2.0)
&& Reachability without the suck.
&& pod 'NPReachability', '~& 0.2.0'
&& - Homepage: /Abizern/NPReachability
&& - Source:&& /Abizern/NPReachability.git
&& - Versions: 0.2.0, 0.1.0 [master repo]
-& Reachability (3.1.1)
&& ARC and GCD Compatible Reachability Class for iOS and OS X. Drop in
&& replacement for Apple Reachability.
&& pod 'Reachability', '~& 3.1.1'
&& - Homepage: /tonymillion/Reachability
&& - Source:&& /tonymillion/Reachability.git
&& - Versions: 3.1.1, 3.1.0, 3.0.0 [master repo]
-& Reachability-RACExtensions (0.1.0)
&& Reachability in Reactive way!
&& pod 'Reachability-RACExtensions', '~& 0.1.0'
&& - Homepage: /kaiinui/Reachability-RACExtensions
&& - Source:&& /kaiinui/Reachability-RACExtensions.git
&& - Versions: 0.1.0 [master repo]
-& SCNetworkReachability (2.0.0)
&& Flexible network reachability with blocks for iOS and OS X.
&& pod 'SCNetworkReachability', '~& 2.0.0'
&& - Homepage: /belkevich/reachability-ios
&& - Source:&& /belkevich/reachability-ios.git
&& - Versions: 2.0.0, 1.2.0, 1.0.1, 1.0.0 [master repo]
&& - Sub specs:&& - SCNetworkReachability/Core (2.0.0)&& -
&& SCNetworkReachability/Multithreading (2.0.0)&& - SCNetworkReachability/Shared
&& (2.0.0)&& - SCNetworkReachability/Compatibility (2.0.0)&& -
&& SCNetworkReachability/All (2.0.0)
-& SGVReachability (1.0.0)
&& Simple reachability wrapper for iOS.
&& pod 'SGVReachability', '~& 1.0.0'
&& - Homepage: /sanekgusev/SGVReachability
&& - Source:&& /sanekgusev/SGVReachability.git
&& - Versions: 1.0.0 [master repo]
-& STMReactiveReachability (1.0.0)
&& ReactiveCocoa extensions for Reachability
&& pod 'STMReactiveReachability', '~& 1.0.0'
&& - Homepage: /stefanomondino/STMReactiveReachability
&& - Source:&& /stefanomondino/STMReactiveReachability.git
&& - Versions: 1.0.0, 0.1.0 [master repo]
-& VCLReachability (1.2.0)
&& VCLReachability is a network reachability library for iOS. It is designed to
&& help you interface with network activity.
&& pod 'VCLReachability', '~& 1.2.0'
&& - Homepage: /VerticodeLabs/VCLReachability
&& - Source:&& /VerticodeLabs/VCLReachability.git
&& - Versions: 1.2.0, 1.0.2, 1.0.1 [master repo]
-& VPPReachability (0.1.0)
&& VPPReachability Library for iOS simplifies access to the status of a given
&& hostname.
&& pod 'VPPReachability', '~& 0.1.0'
&& - Homepage: /vicpenap/VPPReachability
&& - Source:&& /vicpenap/VPPReachability.git
&& - Versions: 0.1.0 [master repo]
因此Reachability支持CocoaPods。
关于如何在项目中加入这些类库,都是参照这两个博客来的,感谢他们的分享!
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。cocoaPods安装步骤
1.升级Ruby环境sudo gem update –system2.安装CocoaPods时我们要访问cocoapods.org,用淘宝的RubyGems镜像来代替官方版本,执行以下命令:gem sources --remove https://rubygems.org///等有反应之后再敲入以下命令gem sources -ahttps://ruby.taobao.org/&3.为了验证你的Ruby镜像是并且仅是taobao,可以用以下命令查看:gem sources –l只有在终端中出现下面文字才表明你上面的命令是成功的:&span style=&font-family:SimSfont-size:14&&*** CURRENT SOURCES ***&/span&&span style=&font-family:SimSfont-size:14&& &/span&&span style=&font-family:SimSfont-size:14&&http://ruby.taobao.org/&/span&4.安装Cocoapods,在终端输入命令sudo gem install&cocoa pods5.在项目中创建cocoapodvim PodfilePodfile的内容:#&最低支持的&iOS&版本platform :ios, '8.0'# Swift&项目需要将框架转换为&frameworks&才能使用use_frameworks!#添加第三方库的targettarget “test” do#&框架列表pod 'AFNetworking’, ‘3.1.0’#记得要加上endend之后就可以利用CocoPods下载AFNetworking类库了。还是在终端中的当前项目目录下,运行以下命令:#安装pod install#设置pod setup&&&&& //这步需要较长时间,可以用命令du -sh *查看进度6.pod命令汇总# 第一次使用安装框架$ pod install&# 今后升级、添加、删除框架,或者框架不好用$ pod update# 搜索框架$ pod search XXX# 在项目文件夹下创建默认的 Podfile$ pod init7.安装中遇到的问题安装cocoa pods时,在终端执行pod search第三方框架时出错:[!] Unable to find a pod with name, author, summary, ordescriptionmatching `AFNetworking`&解决方案:执行rm ~/Library/Caches/CocoaPods/search_index.json&&&&&&&&&然后再执行pod search第三方框架&执行pod install时报错:[!] The dependency `AFNetworking` is not used in any concrete target.&Pod file文件内容:#最低支持的 iOS 版本platform :ios, '8.0'# Swift项目需要将框架转换为 frameworks才能使用use_frameworks!#框架列表pod 'AFNetworking’, ‘3.1.0’解决方案:在Podfile文件内容中加上:target &RWTFlickrSearch& do,记得在最后要加上end&修改后的Podfile:#最低支持的 iOS 版本platform :ios, '8.0'# Swift项目需要将框架转换为 frameworks才能使用use_frameworks!&#添加第三方库的targettarget “test” do & & & &// test是项目的target&#框架列表pod 'AFNetworking’, ‘3.1.0’&#记得要加上endend
最新教程周点击榜
微信扫一扫

我要回帖

更多关于 cocopod 慢 的文章

 

随机推荐