ios NSURLSession AFN CocoaPods

  目录:

  一、AFN网络请求框架

  二、CocoaPods

一、AFN网络请求框架

简介: AFN一套操作网络的第三方框架

        NSURLCOnnection ios 2.0之后就有

        NSURLSession ios 7.0只有才有

        默认支持序列化和反序列化json但是xml需要自己解析

        优秀的错误处理机制

        封装了Reachability,网络有关的框架

        支持https

     git地址:https://github.com/AFNetworking/AFNetworking

二、CocoaPods

      1.安装:

              查看源(及下载的地址):gem sources -l

              设置源: gem sources -a https://gems.ruby-china.com/

              删除源: gem sources --remove https://rubygems.org/

              安装:sudo gem install cocoapods

             

             搜索 pod search SDWebImage

             切换到项目的根目录  echo "pod 'SDWebImage'">Podfile

             安装pod :pod install

             升级: pod update

    

            安装遇到的问题:

            ERROR: Error installing cocoapods:
            ERROR: Failed to build gem native extension.

            mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/include/ruby.h

            参考地址:https://blog.csdn.net/u013538542/article/details/104660924

            自己博客地址地址:https://www.cnblogs.com/huihuizhang/p/12802689.html

      Homebrew国内如何自动安装(国内地址)

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

           参考地址:https://zhuanlan.zhihu.com/p/111014448

           Xcode插件之Alcatraz:

解决升级失效方法: 

1、获取UUID: defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID

2、

find ~/Library/Application Support/Developer/Shared/Xcode/Plug-ins -name Info.plist -maxdepth 3 | xargs -I{} defaults write {} DVTPlugInCompatibilityUUIDs -array-add 7265231C-39B4-402C-89E1-16167C4CC990

3、

defaults delete com.apple.dt.Xcode DVTPlugInManagerNonApplePlugIns-Xcode-7.1,(这里是xcode的版本号)

4、打开Xcode后选择第一个选项LoadXXX

 

安装

CocoaPods 升级1.8.4的坑 CDN: trunk Repo update failed
由于项目是用CocoaPods管理,CocoaPods 1.8将CDN切换为默认的spec repo源,并附带一些增强功能!CDN支持最初是在1.7版本中引入的,最终在1.7.2中完成。 它旨在大大加快初始设置和依赖性分析。
解决办法:
(1)podfile添加source 'https://github.com/CocoaPods/Specs.git'
(2)pod repo list 查看一下源列表
(3)pod repo remove trunk 移除trunk源

当执行 pod install 或者 pod update 后出现 Cloning spec repo cocoapods from https://github.com/CocoaPods/Specs.git 卡住情况,如图:

Unable to add a source with url `https://github.com/CocoaPods/Specs.git` named `cocoapods`.
You can try adding it manually in `/Users/zhangyanan/.cocoapods/repos` or via `pod repo add`.

参考地址:https://www.jianshu.com/p/f43b5964f582

 

 

 

         

原文地址:https://www.cnblogs.com/huihuizhang/p/12801893.html