在swift 中引入AFNetworking时遇到的问题



刚开始学习swift,什么都不明白,希望在项目中引用AFNworking,访问网络服务,不知道如何使用,先是直接把文件copy到项目中完全没有用,找了一些 swift调用C 和object_c的例子,试着是要加一个桥接文件,可以成功的调用,但是没有正常的提示符。

在群中问了一下,有人提示 cocoapods,好搜索了一下这个东本,发现了:


CocoaPods安装和使用教程


http://code4app.com/article/cocoapods-install-usage


这个写的非常好,按其中的操作来做,但遇到这样的问题:


[!] /usr/bin/git clone 'https://github.com/CocoaPods/Specs.git' master --depth=1


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-select: error: invalid developer directory '/Applications/Xcode.app/Contents/Developer'

没有目录,又找找,发现问题是出现在Xcode.app这里,我用的是Xcode6-Beta.app修改一下命令如下

sudo xcode-select -switch /Applications/Xcode6-Beta.app/Contents/Developer


成功了:

usertekiMacBook-Air:~ user$ sudo xcode-select -switch /Applications/Xcode6-Beta.app/Contents/Developer

usertekiMacBook-Air:~ user$ pod search AFNetworking

Setting up CocoaPods master repo

Setup completed (read-only access)


再执行
pod search AFNetworking
看到了正常的结果:

AFNetworking (2.3.1)

   A delightful iOS and OS X networking framework.

   pod 'AFNetworking', '~> 2.3.1'

   - Homepage: https://github.com/AFNetworking/AFNetworking

   - Source:   https://github.com/AFNetworking/AFNetworking.git

   - Versions: 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.3.1)

     - AFNetworking/Security (2.3.1)

     - AFNetworking/Reachability (2.3.1)

     - AFNetworking/NSURLConnection (2.3.1)

     - AFNetworking/NSURLSession (2.3.1)

     - AFNetworking/UIKit (2.3.1)



-> AFNetworking+AutoRetry (0.0.3)

   Auto Retries for AFNetworking requests

   pod 'AFNetworking+AutoRetry', '~> 0.0.3'

   - Homepage: https://github.com/shaioz/AFNetworking-AutoRetry

   - Source:   https://github.com/shaioz/AFNetworking-AutoRetry.git

   - Versions: 0.0.3, 0.0.2, 0.0.1 [master repo]



-> AFNetworking+streaming (0.5)

   A very quick extension to AFNetworking that adds stream based parsing

   pod 'AFNetworking+streaming', '~> 0.5'

   - Homepage: https://github.com/deanWombourne/AFNetworking-streaming

   - Source:   https://github.com/deanWombourne/AFNetworking-streaming.git

   - Versions: 0.5, 0.4, 0.3, 0.2, 0.1 [master repo]

   - Sub specs:

     - AFNetworking+streaming/Core (0.5)

     - AFNetworking+streaming/Json (0.5)



-> AFNetworking-MUResponseSerializer (1.0.0)

   Automatically serialize JSON response to your object model. It also works

   with NSManagedObjects.

   pod 'AFNetworking-MUResponseSerializer', '~> 1.0.0'

   - Homepage: https://github.com/Ulianko/AFNetworking-MUResponseSerializer

   - Source:   https://github.com/Ulianko/AFNetworking-MUResponseSerializer.git

   - Versions: 1.0.0 [master repo]



-> AFNetworking-RACExtensions (0.1.4)

   AFNetworking-RACExtensions is a delightful extension to the AFNetworking

   classes for iOS and Mac OS X.

   pod 'AFNetworking-RACExtensions', '~> 0.1.4'

   - Homepage: https://github.com/CodaFi/AFNetworking-RACExtensions

   - Source:   https://github.com/CodaFi/AFNetworking-RACExtensions.git

   - Versions: 0.1.4, 0.1.2, 0.1.1, 0.0.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.2.0)

   Synchronous requests for AFNetworking

   pod 'AFNetworking-Synchronous', '~> 0.2.0'

   - Homepage: https://github.com/paulmelnikow/AFNetworking-Synchronous

   - Source:   https://github.com/paulmelnikow/AFNetworking-Synchronous.git

   - Versions: 0.2.0, 0.1.0 [master repo]



-> AFNetworking2-RACExtensions (0.0.1)

   AFNetworking-RACExtensions is a delightful extension 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]



-> 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 AFNetworking 1.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]

usertekiMacBook-Air:~ user$ 


-------------现在是最新版本了,可以在项目中使用了,继续参考前面的文章使用看看。

你可能感兴趣的:(APPLE)