首先是看了文章:
http://code4app.com/article/cocoapods-install-usage |
http://www.uml.org.cn/mobiledev/201411072.asp
一、检测以及配置Ruby环境
之后按照文章所说的步骤操作,完成工作后,将自己遇到的问题记录一下,因为系统版本不一样可能遇到的问题不一样,还有就是记录一遍可以加深自己的印象,
首先MAC系统已经有Ruby环境可以直接在终端输入命令:
sudo gem install cocoapods 安装cocoapods但是我这边报错如下:
ERROR: While executing gem ...(Gem::DependencyError)
Unable to resolve dependencies: cocoapodsrequires cocoapods-core (= 0.35.0), xcodeproj (~> 0.20.2),cocoapods-downloader (~> 0.8.0), cocoapods-try (~> 0.4.2),cocoapods-trunk (~> 0.4.1), molinillo (~> 0.1.2)
网上搜博文说是 Ruby环境版本问题解决方法是:在终端输入命令行:
gem update --system 报新错:
Updatingrubygems-update
Fetching:rubygems-update-2.4.6.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the/Library/Ruby/Gems/2.0.0 directory.
据说是执行该命令行没有权限:于是在该命令行前加sudo:为:
sudo gem update--system
执行如下:
Updatingrubygems-update
Fetching:rubygems-update-2.4.6.gem (100%)
Successfullyinstalled rubygems-update-2.4.6
Parsingdocumentation for rubygems-update-2.4.6
Installing ridocumentation for rubygems-update-2.4.6
Installingdarkfish documentation for rubygems-update-2.4.6
InstallingRubyGems 2.4.6
RubyGems 2.4.6installed
Parsingdocumentation for rubygems-2.4.6
Installing ridocumentation for rubygems-2.4.6
=== 2.4.6 /2014-02-05
Bug fixes:
* Fixed resolvinggems with both upper and lower requirement boundaries.
Issue #1141 by Jakub Jirutka.
* Moved extensiondirectory after require_paths to fix missing constant bugs
in some gems with C extensions. Issue #784 by André Arko, pull request
#1137 by Barry Allard.
* UseGem::Dependency#requirement when adding a dependency to an existing
dependency instance. Pull request #1101 by Josh Cheek.
* Fixed warningof shadowed local variable in Gem::Specification. Pull request
#1109 by Rohit Arondekar
*Gem::Requirement should always sort requirements before coercion to Hash.
Pull request #1139 by Eito Katagiri.
* The `gem open`command should change the current working directory before
opening the editor. Pull request #1142 by Alex Wood.
* Ensure quotesare stripped from the Windows launcher script used to install
gems. Pull request #1115 by Youngjun Song.
* Fixed errorswhen writing to NFS to to 0444 files. Issue #1161 by Emmanuel
Hadoux.
* Removed deadcode in Gem::StreamUI. Pull request#1117 by mediaslave24.
* Fixedtypos. Pull request #1096 by hakeda.
* Relaxed CMakedependency for RHEL 6 and CentOS 6. Pullrequest #1124 by Vít
Ondruch.
* Relaxed Psychdependency. Pull request #1128 by VítOndruch.
=== 2.4.5 /2014-12-03
Bug fixes:
* Improved speedof requiring gems. (Around 25% for a 60gem test). Pull
request #1060 by unak.
* RubyGems nolonger attempts to look up gems remotely with the --local flag.
Pull request #1084 by Jeremy Evans.
* Executablestubs use the correct gem version when RUBYGEMS_GEMDEPS is
active. Issue #1072 by Michael Kaiser-Nyman.
* Fixed handlingof pinned gems in lockfiles with versions. Issue #1078 by
Ian Ker-Seymer.
* Fixed handlingof git@example:gem.git URIs. Issue #1054by Mogutan Mogu.
* Fixed handlingof platforms retrieved from the dependencies API. Issue
#1058 and patch suggestion by tux-mind.
* RubyGems nowsuggests a copy-pasteable `gem pristine` command when
extensions are missing. Pull request #1057 by Shannon Skipper.
* Improved errorsfor long file names when packaging. Pullrequest #1016 by
Piotrek Bator.
* `gem pristine`now skips gems cannot be found remotely. Pull request #1064
by Tuomas Kareinen.
* `gem pristine`now caches gems to the proper directory. Pull request #1064
by Tuomas Kareinen.
* `gem pristine`now skips bundled gems properly. Pullrequest #1064 by
Tuomas Kareinen.
* Improvedinteroperability of Vagrant with RubyGems. Pull request #1057 by
Vít Ondruch.
* RenamedCONTRIBUTING to CONTRIBUTING.rdoc to allow markup. Pull request
#1090 by Roberto Miranda.
* Switched from#partition to #reject as only one collection is used. Pull
request #1074 by Tuomas Kareinen.
* Fixedinstallation of gems on systems using memory-mapped files. Pull
request #1038 by Justin Li.
* Fixed bug inGem::Text#min3 where `a == b < c`. Pull request #1026 by
fortissimo1997.
* Fixeduninitialized variable warning in BasicSpecification. Pull request
#1019 by Piotr Szotkowski.
* Removedunneeded exception handling for cyclic dependencies. Pull request
#1043 by Jens Wille.
* Fixed groupedexpression warning. Pull request #1081by André Arko.
* Fixed handlingof platforms when writing lockfiles.
=== 2.4.4 /2014-11-12
Bug fixes:
* Add alternateRoot CA for upcoming certificate change. Fixes #1050 by
Protosac
=== 2.4.3 /2014-11-10
Bug fixes:
* Fix redefineMirrorCommand issue. Pull request #1044 by @akr.
* Fix typo inplatform= docs. Pull request #1048 by@jasonrclark
* Add root SSLcertificates for upcoming certificate change. Fixes #1050 by
Protosac
=== 2.4.2 /2014-10-01
This release wassponsored by Ruby Central.
Bug fixes:
* RubyGems nowcorrectly matches wildcard no_proxy hosts. Issue #997 by
voelzemo.
* Added supportfor missing git_source method in the gem dependencies API.
* Fixed handlingof git gems with an alternate install directory.
* Lockfiles willno longer be truncated upon resolution errors.
* Fixed messagingfor `gem owner -a`. Issue #1004 by AaronPatterson, Ryan
Davis.
* Removedmeaningless ensure. Pull request #1003by gogotanaka.
* Improvedwording of --source option help. Pullrequest #989 by Jason Clark.
* Emptybuild_info files are now ignored. Issue#903 by Adan Alvarado.
* Gem::Installerignores dependency checks when installing development
dependencies. Issue #994 by Jens Willie.
* `gem update`now continues after dependency errors. Issue #993 by aaronchi.
* RubyGems nolonger warns about semantic version dependencies for the 0.x
range. Issue #987 by Jeff Felchner, pull request #1006 by Hsing-Hui Hsu.
* Added minimallock to allow multithread installation of gems. Issue #982
and pull request #1005 by Yorick Peterse
* RubyGems nowconsiders prerelease dependencies as it did in earlier versions
when --prerelease is given. Issue #990 by Jeremy Tryba.
* Updatedcapitalization in README. Issue #1010 byBen Bodenmiller.
* Fixedactivating gems from a Gemfile for default gems. Issue #991 by khoan.
* Fixed windowsstub script generation for Cygwin. Issue#1000 by Brett
DiFrischia.
* Allow gembindir and ruby.exe to live in separate diretories. Pull request
#942 by Ian Flynn.
* Fixed handlingof gemspec in gem dependencies files to match Bundler
behavior. Issue #1020 by Michal Papis.
* Fixed `gemupdate` when updating to prereleases. Issue #1028 by Santiago
Pastorino.
* RubyGems nowfails immediately when a git reference cannot be found instead
of spewing git errors. Issue #1031 by Michal Papis
=== 2.4.1 /2014-07-17
Bug fixes:
* RubyGems cannow be updated on Ruby implementations that do not support
vendordir in RbConfig::CONFIG. Issue #974 by net1957.
=== 2.4.0 /2014-07-16
Minorenhancements:
* The contentscommand now supports a --show-install-dir option that shows
only the directory the gem is installedin. Feature request #966 by Akinori
MUSHA.
* Added a--build-root option to the install command for packagers. Pull
request #965 by Marcus Rückert.
* Added vendorgem support to RubyGems. Packagemanagers may now install gems
in Gem.vendor_dir with the --vendor option togem install. Issue #943 by
Marcus Rückert.
Bug fixes:
* Kernel#gem nowrespects the prerelease flag when activating gems.
Previously this behavior was undefined whichcould lead to bugs when a
prerelease version was unintentionallyactivated. Bug #938 by Joe Ferris.
* RubyGems nowprefers gems from git over installed gems. This allows gems
from git to override an installed gem withthe same name and version. Bug
#944 by Thomas Kriechbaumer.
* Fixed handlingof git gems in a lockfile with unversioned dependencies. Bug
#940 by Michael Kaiser-Nyman.
* The rubydirective in a gem dependencies file is ignored when installing.
Bug #941 by Michael Kaiser-Nyman.
* Added open tolist of builtin commands (`gem open` now works). Reported by
Espen Antonsen.
* `gem open` nowworks with command-line editors. Pullrequest #962 by Tim
Pope.
* `gem install-g` now respects `--conservative`. Pullrequest #950 by Jeremy
Evans.
* RubyGemsreleases announcements now now include checksums. Bug #939 by
Alexander E. Fischer.
* RubyGems nowexpands ~ in $PATH when checking if installed executables will
be runnable. Pull request #945 by Alex Talker.
* Fixed `geminstall -g --explain`. Issue #947 byLuis Lavena. Patch by
Hsing-Hui Hsu.
* RubyGems locksless during gem activation. Pull request#951 by Aaron
Patterson and Justin Searls, #969 by JeremyTryba.
* Kernel#gem isnow thread-safe. Pull request #967 byAaron Patterson.
* RubyGems nowhandles spaces in directory names for some parts of extension
building. Pull request #949 by Tristan Hill.
* RubyGems nolonger defines an empty Date class. PullRequest #948 by Benoit
Daloze.
* RubyGemsrespects --document options for `gem update` again. Bug 946 by
jonforums. Patch by Hsing-Hui Hsu.
* RubyGems generatesdocumentation again with --ignore-dependencies. Bug #961
by Pulfer.
* RubyGems caninstall extensions across partitions now. Pull request #970 by
Michael Scherer.
* `-s` is nowshort for `--source` which resolves an ambiguity with
--no-suggestions. Pull request #955 by Alexander Kahn.
* Added extratest for ~> for 0.0.X versions. Pullrequest #958 by Mark
Lorenz.
* Fixed typo ingem updated help. Pull request #952 byPer Modin.
* Clarified thatthe gem description should not be excessively long. Part of
bug #956 by Renier Morales.
* Hiddocumentation of outdated test_files related methods in Specification.
Guides issue #90 by Emil Soman.
* RubyGems nowfalls back to the old index if therubygems.org API fails
during gem resolution.
------------------------------------------------------------------------------
RubyGemsinstalled the following executables:
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/gem
Ruby Interactive(ri) documentation was installed. ri is kind of like man
pages for rubylibraries. You may access it like this:
ri Classname
ri Classname.class_method
ri Classname#instance_method
If you do notwish to install this documentation in the future, use the
--no-documentflag, or set it as the default in your ~/.gemrc file. See
'gem help env'for details.
RubyGems systemsoftware updated
最后一句说明:Ruby 已经更新。
二、安装cocoapods
这时候再输入命令行:
sudo gem install cocoapods
进行安装cocoapods,输入电脑密码后就会出现如下:
Fetching:i18n-0.6.11.gem (100%)
Successfullyinstalled i18n-0.6.11
Fetching:multi_json-1.10.1.gem (100%)
Successfullyinstalled multi_json-1.10.1
Fetching:activesupport-3.2.19.gem (100%)
Successfullyinstalled activesupport-3.2.19
Fetching:nap-0.8.0.gem (100%)
Successfullyinstalled nap-0.8.0
Fetching: json_pure-1.8.1.gem(100%)
Successfullyinstalled json_pure-1.8.1
Fetching:fuzzy_match-2.0.4.gem (100%)
Successfullyinstalled fuzzy_match-2.0.4
Fetching:cocoapods-core-0.33.1.gem (100%)
Successfullyinstalled cocoapods-core-0.33.1
Fetching:claide-0.6.1.gem (100%)
Successfullyinstalled claide-0.6.1
Fetching:colored-1.2.gem (100%)
Successfullyinstalled colored-1.2
Fetching:xcodeproj-0.17.0.gem (100%)
Building nativeextensions. This could take a while...
[!] You are usingthe prebuilt binary version of the xcodeproj gem.
Successfullyinstalled xcodeproj-0.17.0
Fetching:cocoapods-downloader-0.6.1.gem (100%)
Successfullyinstalled cocoapods-downloader-0.6.1
Fetching:cocoapods-plugins-0.2.0.gem (100%)
Successfullyinstalled cocoapods-plugins-0.2.0
Fetching:cocoapods-try-0.3.0.gem (100%)
Successfullyinstalled cocoapods-try-0.3.0
Fetching:netrc-0.7.7.gem (100%)
Successfullyinstalled netrc-0.7.7
Fetching:cocoapods-trunk-0.1.4.gem (100%)
Successfullyinstalled cocoapods-trunk-0.1.4
Fetching: escape-0.0.4.gem(100%)
Successfullyinstalled escape-0.0.4
Fetching:open4-1.3.4.gem (100%)
Successfullyinstalled open4-1.3.4
Fetching:cocoapods-0.33.1.gem (100%)
CHANGELOG:
## 0.33.1
##### Bug Fixes
* Fix `pod speclint` for `json` podspecs.
[Fabio Pelosin][irrationalfab]
[#2157](https://github.com/CocoaPods/CocoaPods/issues/2157)
* Fixeddownloader issues related to `json` podspecs.
[Fabio Pelosin][irrationalfab]
[#2158](https://github.com/CocoaPods/CocoaPods/issues/2158)
* Fixed `--no-ansi`flag in help banners.
[Fabio Pelosin][irrationalfab]
[#34](https://github.com/CocoaPods/CLAide/issues/34)
Successfullyinstalled cocoapods-0.33.1
Parsingdocumentation for i18n-0.6.11
Installing ridocumentation for i18n-0.6.11
Parsingdocumentation for multi_json-1.10.1
Installing ridocumentation for multi_json-1.10.1
Parsingdocumentation for activesupport-3.2.19
unable to convert"\x80" from ASCII-8BIT to UTF-8 forlib/active_support/values/unicode_tables.dat, skipping
Installing ridocumentation for activesupport-3.2.19
Parsingdocumentation for nap-0.8.0
Installing ridocumentation for nap-0.8.0
Parsingdocumentation for json_pure-1.8.1
Installing ridocumentation for json_pure-1.8.1
Parsingdocumentation for fuzzy_match-2.0.4
Installing ridocumentation for fuzzy_match-2.0.4
Parsingdocumentation for cocoapods-core-0.33.1
Installing ridocumentation for cocoapods-core-0.33.1
Parsingdocumentation for claide-0.6.1
Installing ridocumentation for claide-0.6.1
Parsingdocumentation for colored-1.2
Installing ridocumentation for colored-1.2
Parsingdocumentation for xcodeproj-0.17.0
Installing ridocumentation for xcodeproj-0.17.0
Parsingdocumentation for cocoapods-downloader-0.6.1
Installing ridocumentation for cocoapods-downloader-0.6.1
Parsingdocumentation for cocoapods-plugins-0.2.0
Installing ridocumentation for cocoapods-plugins-0.2.0
Parsingdocumentation for cocoapods-try-0.3.0
Installing ridocumentation for cocoapods-try-0.3.0
Parsingdocumentation for netrc-0.7.7
Installing ri documentationfor netrc-0.7.7
Parsingdocumentation for cocoapods-trunk-0.1.4
Installing ridocumentation for cocoapods-trunk-0.1.4
Parsingdocumentation for escape-0.0.4
Installing ridocumentation for escape-0.0.4
Parsingdocumentation for open4-1.3.4
Installing ridocumentation for open4-1.3.4
Parsingdocumentation for cocoapods-0.33.1
Installing ridocumentation for cocoapods-0.33.1
18 gems installed
说明cocopods安装成功了。
三、接下来就是用cocoapods导入第三方类库
导入之前需要先检测一下第三方类库是否支持cocoapods,检测方法AFNetworking举例:
pod search AFNetworking
如下:
Setting upCocoaPods master repo
CocoaPods0.36.0.rc.1 is available.
To update use:gem install cocoapods\n
Setup completed(read-only access)
->AFNetworking (2.5.1)
A delightful iOS and OS X networkingframework.
pod 'AFNetworking', '~> 2.5.1'
- Homepage:https://github.com/AFNetworking/AFNetworking
- Source: https://github.com/AFNetworking/AFNetworking.git
- Versions: 2.5.1, 2.5.0, 2.4.1, 2.4.0,2.3.1, 2.3.0, 2.2.4, 2.2.3, 2.2.2, 2.2.1, 2.2.0, 2.1.0, 2.0.3,
2.0.2, 2.0.1, 2.0.0, 2.0.0-RC3, 2.0.0-RC2,2.0.0-RC1, 1.3.4, 1.3.3, 1.3.2, 1.3.1, 1.3.0, 1.2.1, 1.2.0,
1.1.0, 1.0.1, 1.0, 1.0RC3, 1.0RC2, 1.0RC1,0.10.1, 0.10.0, 0.9.2, 0.9.1, 0.9.0, 0.7.0, 0.5.1 [master
repo]
- Sub specs:
- AFNetworking/Serialization (2.5.1)
-AFNetworking/Security (2.5.1)
- AFNetworking/Reachability (2.5.1)
- AFNetworking/NSURLConnection (2.5.1)
- AFNetworking/NSURLSession (2.5.1)
- AFNetworking/UIKit (2.5.1)
->AFNetworking+AutoRetry (0.0.5)
Auto Retries for AFNetworking requests
pod 'AFNetworking+AutoRetry', '~> 0.0.5'
- Homepage:https://github.com/shaioz/AFNetworking-AutoRetry
- Source: https://github.com/shaioz/AFNetworking-AutoRetry.git
- Versions: 0.0.5, 0.0.4, 0.0.3, 0.0.2,0.0.1 [master repo]
->AFNetworking+Ext (1.1)
AFNetworking的封装, 并提供一个 UIImageView+DYLoading cache infileSystem+memory
pod 'AFNetworking+Ext', '~> 1.1'
- Homepage:https://github.com/junhaiyang/AFNetworkingExt
- Source: https://github.com/junhaiyang/AFNetworkingExt.git
- Versions: 1.1, 1.0, 0.5, 0.4, 0.3 [masterrepo]
- Sub specs:
- AFNetworking+Ext/Base (1.1)
-AFNetworking+Ext/AFCustomRequestOperation (1.1)
-AFNetworking+Ext/AFDownloadRequestOperation (1.1)
- AFNetworking+Ext/AFTextResponseSerializer(1.1)
- AFNetworking+Ext/example (1.1)
- AFNetworking+Ext/UIKit (1.1)
-AFNetworking+Ext/UIKit/UIImageView+DYLoading (1.1)
->AFNetworking+ImageActivityIndicator (1.0.1)
AFNetworking+ImageActivityIndicator makes iteasy to show an activity indicator while an image view's
image is loading using AFNetworking.
pod 'AFNetworking+ImageActivityIndicator','~> 1.0.1'
- Homepage:https://github.com/JRG-Developer/AFNetworking-ImageActivityIndicator
- Source: https://github.com/JRG-Developer/AFNetworking-ImageActivityIndicator.git
- Versions: 1.0.1, 1.0.0 [master repo]
->AFNetworking+SingleBlock (0.0.1)
Categories that aggregate the success andfailure block in one single solution
pod 'AFNetworking+SingleBlock', '~>0.0.1'
- Homepage:https://github.com/acerbetti/AFNetworking-SingleBlock
- Source: https://github.com/acerbetti/AFNetworking-SingleBlock.git
- Versions: 0.0.1 [master repo]
->AFNetworking+streaming (0.6)
A very quick extension to AFNetworking thatadds stream based parsing
pod 'AFNetworking+streaming', '~> 0.6'
- Homepage:https://github.com/deanWombourne/AFNetworking-streaming
- Source: https://github.com/deanWombourne/AFNetworking-streaming.git
- Versions: 0.6, 0.5, 0.4, 0.3, 0.2, 0.1[master repo]
- Sub specs:
- AFNetworking+streaming/Core (0.6)
- AFNetworking+streaming/Json (0.6)
->AFNetworking-MUResponseSerializer (1.0.1)
Automatically serialize JSON response toyour object model. It also works with NSManagedObjects
pod 'AFNetworking-MUResponseSerializer','~> 1.0.1'
- Homepage:https://github.com/Ulianko/AFNetworking-MUResponseSerializer
- Source: https://github.com/Ulianko/AFNetworking-MUResponseSerializer.git
- Versions: 1.0.1, 1.0.0 [master repo]
->AFNetworking-RACExtensions (0.1.6)
AFNetworking-RACExtensions is a delightfulextension to the AFNetworking classes for iOS and Mac OS X.
pod 'AFNetworking-RACExtensions', '~>0.1.6'
- Homepage:https://github.com/CodaFi/AFNetworking-RACExtensions
- Source: https://github.com/CodaFi/AFNetworking-RACExtensions.git
- Versions: 0.1.6, 0.1.4, 0.1.2, 0.1.1,0.0.1 [master repo]
->AFNetworking-RACRetryExtensions (0.1.1)
AFNetworking-RACRetryExtensions is anextension to the AFNetworking classes for iOS and Mac OS X that
adds the auto-retry ability.
pod 'AFNetworking-RACRetryExtensions','~> 0.1.1'
- Homepage: https://github.com/legoless/AFNetworking-RACRetryExtensions
- Source: https://github.com/legoless/AFNetworking-RACRetryExtensions.git
- Versions: 0.1.1 [master repo]
->AFNetworking-ReactiveCocoa (0.0.2)
Make AFNetworking reactive.
pod 'AFNetworking-ReactiveCocoa', '~>0.0.2'
- Homepage:https://github.com/uasi/AFNetworking-ReactiveCocoa
- Source: https://github.com/uasi/AFNetworking-ReactiveCocoa.git
- Versions: 0.0.2, 0.0.1 [master repo]
->AFNetworking-Synchronous (0.3.1)
Synchronous requests for AFNetworking
pod 'AFNetworking-Synchronous', '~>0.3.1'
- Homepage:https://github.com/paulmelnikow/AFNetworking-Synchronous
- Source: https://github.com/paulmelnikow/AFNetworking-Synchronous.git
- Versions: 0.3.1, 0.3.0, 0.2.0, 0.1.0[master repo]
- Sub specs:
- AFNetworking-Synchronous/1.x (0.3.1)
- AFNetworking-Synchronous/2.x (0.3.1)
->AFNetworking2-RACExtensions (0.0.1)
AFNetworking-RACExtensions is a delightfulextension to the AFNetworking classes for iOS and Mac OS X.
pod 'AFNetworking2-RACExtensions', '~>0.0.1'
- Homepage:https://github.com/knshiro/AFNetworking-RACExtensions
- Source: https://github.com/knshiro/AFNetworking-RACExtensions.git
- Versions: 0.0.1 [master repo]
->AFNetworkingHelper (0.1.4)
A short wrapper written over AFNetworkinglibrary.
pod 'AFNetworkingHelper', '~> 0.1.4'
- Homepage:https://github.com/RainingClouds/AFNetworkingHelper
- Source: https://github.com/RainingClouds/AFNetworkingHelper.git
- Versions: 0.1.4, 0.1.3, 0.1.2, 0.1.1,0.1.0 [master repo]
->CollectionUtils-AFNetworking (1.0.1)
CollectionUtils additions for AFNetworking.
pod 'CollectionUtils-AFNetworking', '~>1.0.1'
- Homepage:https://github.com/kishikawakatsumi/CollectionUtils
-Source: https://github.com/kishikawakatsumi/CollectionUtils.git
- Versions: 1.0.1, 1.0.0 [master repo]
->CollectionUtils-AFNetworking-1.3 (1.0.1)
CollectionUtils additions for AFNetworking1.3.x.
pod 'CollectionUtils-AFNetworking-1.3','~> 1.0.1'
- Homepage:https://github.com/kishikawakatsumi/CollectionUtils
- Source: https://github.com/kishikawakatsumi/CollectionUtils.git
- Versions: 1.0.1, 1.0.0 [master repo]
->HYVConfiguratorAFNetworking-Mantle (0.3.1)
Configurator for using AFNetworking withMantle
pod 'HYVConfiguratorAFNetworking-Mantle','~> 0.3.1'
- Homepage:https://github.com/LilushFess/HYVConfiguratorAFNetworking-Mantle.git
- Source: https://github.com/LilushFess/HYVConfiguratorAFNetworking-Mantle.git
- Versions: 0.3.1, 0.3.0, 0.2.1, 0.2.0,0.1.4, 0.1.3.2, 0.1.3.1, 0.1.3, 0.1.2.2, 0.1.2, 0.1.1.42, 0.1.0
[master repo]
->Haneke+AFNetworking (0.2.0)
Haneke extension to use AFNetworking todownload images.
pod 'Haneke+AFNetworking', '~> 0.2.0'
- Homepage:https://github.com/Haneke/Haneke-AFNetworking
- Source: https://github.com/Haneke/Haneke-AFNetworking.git
- Versions: 0.2.0 [master repo]
->PromiseKit-AFNetworking (0.1.5)
PromiseKit extensions for AFNetworking
pod 'PromiseKit-AFNetworking', '~> 0.1.5'
- Homepage:https://github.com/csotiriou/AFNetworking-PromiseKit/
- Source: https://github.com/csotiriou/AFNetworking-PromiseKit.git
- Versions:0.1.5, 0.1.4, 0.1.3, 0.1.2, 0.1.1 [master repo]
会出现很多与AFNetworking相关的类库。这就说明AFNetworking是支持cocopods的。
四、检测第三方类库支持cocoapos之后,用cocoapods下载并导入该库。
按照文档创建一新poject
CocoaPodsDemo
至于CocoaPods为什么能下载AFNetworking,是因为有个名称为Podfile的文件来控制CocoaPods该下载什么(注意,一定得是这个文件名,而且没有后缀)。你创建一个Podfile文件,然后在里面添加你需要下载的类库,也就是告诉CocoaPods,可以下载这个。每个项目只需要一个Podfile文件。
在终端输入命令:
cd .xcodeproj所在路径,先找到工程文件所在文件夹,
再输入:
vim podfile
创建podfile文件
在终端会出现
~
~
~
~
~
~
~
podfile[New File]
输入命令i,变为可输入模式
会变成
~
~
~
~
---------------INSERT---------------
接着可以输入:
platform :ios, '7.0'
pod"AFNetworking", "~> 2.0"
输入完成后为
platform :ios, '7.0'
pod"AFNetworking", "~> 2.0"
~
~
~
~
---------------INSERT---------------
此时先点击键盘上“Esc(退出键)”退出输入模式,在终端底部输入:wq就可以退出并保存了,此时在项目所在文件夹可以看到podfile文件
如图:
双击podfile如图:
说明已经将“需要安装AFNetworking”告知给cocoa pods,此时在终端输入命令行:
pod install
如下:
Analyzingdependencies
CocoaPods0.36.0.rc.1 is available.
To update use:gem install cocoapods\n
Downloadingdependencies
InstallingAFNetworking (2.5.1)
Generating Podsproject
Integratingclient project
[!] From now onuse `CocoaPodsDemo.xcworkspace`.
说明安装成功,最后一句说明,从现在开始需要双击`CocoaPodsDemo.xcworkspace`.来打开项目,而并非.xcodeproj
安装完之后项目文件夹里会多出两个文件如图:
双击.workspace如图:
如图说明AFNetworking已经成功导入项目中,这时可以在适当地方导入头文件
#import <AFNetworking.h>
编译应该不会报错,所以感谢原文帮忙解决下载、导入、以及配置第三方类库的问题,省去很多麻烦可以更好管理第三方类库。
四、在已有运行已有podfile文件的项目,中关于库更新问题
如果运行下载的项目报错的话,
打开终端cd找到项目所在路径,输入命令行进行更新第三方库的操作:
pod update
更新之后再执行:
pod install
成功之后双击.workspace就可以运行项目了。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)