【IOS】pod安装和使用pod install --no-repo-update

来源:互联网 发布:淘宝百合花名妆真假 编辑:程序博客网 时间:2024/05/20 12:52

/* 使用pod的步骤 (1)cd到.xcodeproj所在的目录 (2)touch podfile 新建pod文件并open podfile 打开pod文件【BuDeJie】改为自己工程名source ‘https://github.com/CocoaPods/Specs.git’ platform :ios,’8.0’  target 'BuDeJie' do pod 'AFNetworking','~>3.0' end (3)pod install --no-repo-update (4)关闭当前所有xcode工程,然后用.xcworkspace重新打开工程 (5)代码中导入#import <AFNetworking/AFNetworking.h> (6)调用AFHTTPSessionManager  */- (IBAction)getBtn:(id)sender {    NSLog(@"GET");    //1.创建请求会话管理者    AFHTTPSessionManager *mgr = [AFHTTPSessionManager manager];    mgr.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/plain"];    //3.发送请求    [mgr GET:@"http://192.168.1.102:8080/test.json" parameters:nil progress:nil success:^(NSURLSessionDataTask *_Nonnull task, id _Nullable responseObject){                NSLog(@"成功%@", responseObject);            } failure:^(NSURLSessionDataTask *_Nonnull task, NSError * _Nonnull error){                NSLog(@"失败%@", error);    }];}



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


http://www.code4app.com/article/cocoapods-install-usagemacs-Mac-mini:~ mac$ gem sources -l\*** CURRENT SOURCES ***\\https://rubygems.org/\https://ruby.taobao.org/\macs-Mac-mini:~ mac$ gem sources --remove https://rubygems.org/\https://rubygems.org/ removed from sources\macs-Mac-mini:~ mac$ gem sources -l\*** CURRENT SOURCES ***\\https://ruby.taobao.org/\macs-Mac-mini:~ mac$ sudo gem install cocoapods\Password:\Fetching: thread_safe-0.3.6.gem (100%)\Successfully installed thread_safe-0.3.6\Fetching: tzinfo-1.2.3.gem (100%)\Successfully installed tzinfo-1.2.3\Fetching: minitest-5.10.3.gem (100%)\Successfully installed minitest-5.10.3\Fetching: activesupport-4.2.9.gem (100%)\Successfully installed activesupport-4.2.9\Fetching: nap-1.1.0.gem (100%)\Successfully installed nap-1.1.0\Fetching: fuzzy_match-2.0.4.gem (100%)\Successfully installed fuzzy_match-2.0.4\Fetching: cocoapods-core-1.3.1.gem (100%)\Successfully installed cocoapods-core-1.3.1\Fetching: claide-1.0.2.gem (100%)\Successfully installed claide-1.0.2\Fetching: cocoapods-deintegrate-1.0.1.gem (100%)\Successfully installed cocoapods-deintegrate-1.0.1\Fetching: cocoapods-downloader-1.1.3.gem (100%)\Successfully installed cocoapods-downloader-1.1.3\Fetching: cocoapods-plugins-1.0.0.gem (100%)\Successfully installed cocoapods-plugins-1.0.0\Fetching: cocoapods-search-1.0.0.gem (100%)\Successfully installed cocoapods-search-1.0.0\Fetching: cocoapods-stats-1.0.0.gem (100%)\Successfully installed cocoapods-stats-1.0.0\Fetching: netrc-0.7.8.gem (100%)\Successfully installed netrc-0.7.8\Fetching: cocoapods-trunk-1.2.0.gem (100%)\Successfully installed cocoapods-trunk-1.2.0\Fetching: cocoapods-try-1.1.0.gem (100%)\Successfully installed cocoapods-try-1.1.0\Fetching: molinillo-0.5.7.gem (100%)\Successfully installed molinillo-0.5.7\Fetching: CFPropertyList-2.3.5.gem (100%)\Successfully installed CFPropertyList-2.3.5\Fetching: colored2-3.1.2.gem (100%)\Successfully installed colored2-3.1.2\Fetching: nanaimo-0.2.3.gem (100%)\Successfully installed nanaimo-0.2.3\Fetching: xcodeproj-1.5.2.gem (100%)\Successfully installed xcodeproj-1.5.2\Fetching: escape-0.0.4.gem (100%)\Successfully installed escape-0.0.4\Fetching: fourflusher-2.0.1.gem (100%)\Successfully installed fourflusher-2.0.1\Fetching: gh_inspector-1.0.3.gem (100%)\Successfully installed gh_inspector-1.0.3\Fetching: ruby-macho-1.1.0.gem (100%)\Successfully installed ruby-macho-1.1.0\Fetching: cocoapods-1.3.1.gem (100%)\Successfully installed cocoapods-1.3.1\Parsing documentation for thread_safe-0.3.6\Installing ri documentation for thread_safe-0.3.6\Parsing documentation for tzinfo-1.2.3\Installing ri documentation for tzinfo-1.2.3\Parsing documentation for minitest-5.10.3\Installing ri documentation for minitest-5.10.3\Parsing documentation for activesupport-4.2.9\unable to convert "\\x84" from ASCII-8BIT to UTF-8 for lib/active_support/values/unicode_tables.dat, skipping\Installing ri documentation for activesupport-4.2.9\Parsing documentation for nap-1.1.0\Installing ri documentation for nap-1.1.0\Parsing documentation for fuzzy_match-2.0.4\Installing ri documentation for fuzzy_match-2.0.4\Parsing documentation for cocoapods-core-1.3.1\Installing ri documentation for cocoapods-core-1.3.1\Parsing documentation for claide-1.0.2\Installing ri documentation for claide-1.0.2\Parsing documentation for cocoapods-deintegrate-1.0.1\Installing ri documentation for cocoapods-deintegrate-1.0.1\Parsing documentation for cocoapods-downloader-1.1.3\Installing ri documentation for cocoapods-downloader-1.1.3\Parsing documentation for cocoapods-plugins-1.0.0\Installing ri documentation for cocoapods-plugins-1.0.0\Parsing documentation for cocoapods-search-1.0.0\Installing ri documentation for cocoapods-search-1.0.0\Parsing documentation for cocoapods-stats-1.0.0\Installing ri documentation for cocoapods-stats-1.0.0\Parsing documentation for netrc-0.7.8\Installing ri documentation for netrc-0.7.8\Parsing documentation for cocoapods-trunk-1.2.0\Installing ri documentation for cocoapods-trunk-1.2.0\Parsing documentation for cocoapods-try-1.1.0\Installing ri documentation for cocoapods-try-1.1.0\Parsing documentation for molinillo-0.5.7\Installing ri documentation for molinillo-0.5.7\Parsing documentation for CFPropertyList-2.3.5\Installing ri documentation for CFPropertyList-2.3.5\Parsing documentation for colored2-3.1.2\Installing ri documentation for colored2-3.1.2\Parsing documentation for nanaimo-0.2.3\Installing ri documentation for nanaimo-0.2.3\Parsing documentation for xcodeproj-1.5.2\Installing ri documentation for xcodeproj-1.5.2\Parsing documentation for escape-0.0.4\Installing ri documentation for escape-0.0.4\Parsing documentation for fourflusher-2.0.1\Installing ri documentation for fourflusher-2.0.1\Parsing documentation for gh_inspector-1.0.3\Installing ri documentation for gh_inspector-1.0.3\Parsing documentation for ruby-macho-1.1.0\Installing ri documentation for ruby-macho-1.1.0\Parsing documentation for cocoapods-1.3.1\Installing ri documentation for cocoapods-1.3.1\26 gems installed\macs-Mac-mini:~ mac$ pod --version\1.3.1\macs-Mac-mini:~ mac$ \}


pod使用

http://www.jianshu.com/p/1222dd6c4271

cd到.xcodeproj所在的目录
touch podfile 新建pod文件
open podfile 打开pod文件

source ‘https://github.com/CocoaPods/Specs.git’platform :ios,’8.0’target 'BuDeJie' dopod 'AFNetworking','~>3.0'  end
搜索需要导入框架描述
pod install --no-repo-update   安装第三方框架(pod --help)
关闭当前所有xcode工程,然后用.xcworkspace重新打开工程(只要使用了cocoapods,之后只能用.xcworkspace打开工程)
代码中导入#import <AFNetworking/AFNetworking.h>

macs-Mac-mini:BuDeJie mac$ vi podfile macs-Mac-mini:BuDeJie mac$ vi podfile macs-Mac-mini:BuDeJie mac$ pod install --no-repo-updateAnalyzing dependenciesDownloading dependenciesInstalling AFNetworking (3.1.0)Generating Pods projectIntegrating client project[!] Please close any current Xcode sessions and use `BuDeJie.xcworkspace` for this project from now on.Sending statsPod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.[!] Smart quotes were detected and ignored in your Podfile. To avoid issues in the future, you should not use TextEdit for editing it. If you are not using TextEdit, you should turn off smart quotes in your editor of choice.macs-Mac-mini:BuDeJie mac$ lsBuDeJieBuDeJie.xcworkspacePodsBuDeJie.xcodeprojPodfile.lockpodfile

//从服务器读取json数据进行解析-(void)loadAdData{                   //1.创建请求会话管理者                   AFHTTPSessionManager *mgr = [AFHTTPSessionManager manager];                   //2.拼接参数                   NSMutableDictionary *parameters = [NSMutableDictionary dictionary];                   parameters[@"code2"] = code2;                   //3.发送请求                   [mgr GET:@"http://mobads.baidu.com/cpro/ui/mads.php" parameters:parameters progress:nil success:^(NSURLSessionDataTask *_Nonnull task, id _Nullable responseObject){                                      NSLog(@"%@", responseObject);                                      } failure:^(NSURLSessionDataTask *_Nonnull task, NSError * _Nonnull error){                                      NSLog(@"%@", error);                   }];}