项目使用cocapod的步骤及注意事项:
(主要是针对之前就安装使用过,但是许久不用,忘掉部分的。关于初次使用cocoapod的使用,网上有许多教程,按照教程,基本没什么问题!!!)
因为之前安装过cocoapod的,所以直接打开终端
1、cd到新建项目所在目录下
2、touch Podfile--创建Podfile文件
3、open -e Podfile--打开这个文件进行编辑
类似:
platform :ios,'8.0'
#use_frameworks!个别需要用到它,比如reactiveCocoa
target'MyApp'do
pod'AFNetworking','~> 2.6'
pod'ORStackView','~> 3.0'
pod'SwiftyJSON','~> 2.3'
end
与之前已经不同!!!PS:里面的 MyApp 记得替换为自己项目的target
参考http://blog.csdn.net/sjl_leaf/article/details/50506057,
4、执行pod install
备注:
我在执行pod search AFNetworking 的时候按常规应该出现AFNetworking的相关描述,但是现在一直报错
――― MARKDOWN TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
### Command
```
/Users/lisas/.rvm/gems/ruby-2.0.0-p643/bin/pod search AFNetworking
```
### Report
* What did you do?
* What did you expect to happen?
* What happened instead?
### Stack
```
CocoaPods : 1.1.0.beta.1
Ruby : ruby 2.0.0p643 (2015-02-25 revision 49749) [x86_64-darwin14.3.0]
RubyGems : 2.6.6
Host : Mac OS X 10.11.4 (15E65)
Xcode : 7.3.1 (7D1014)
Git : git version 2.7.4 (Apple Git-66)
Ruby lib dir : /Users/lisas/.rvm/rubies/ruby-2.0.0-p643/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ 8d70af3101c06dc3cf8abb5b66b77d2dee5555e1
```
### Plugins
```
cocoapods-deintegrate : 1.0.0
cocoapods-plugins : 1.0.0
cocoapods-search : 1.0.0
cocoapods-stats : 1.0.0
cocoapods-trunk : 1.0.0
cocoapods-try : 1.1.0
```
### Podfile
```ruby
platform :ios, '8.0'
target 'MyCocoapodDemo20160712' do
pod 'AFNetworking', '~> 2.6'
pod 'ORStackView', '~> 3.0'
end
```
### Error
```
JSON::ParserError - A JSON text must at least contain two octets!
/Users/lisas/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/json/common.rb:155:in `initialize'
/Users/lisas/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/json/common.rb:155:in `new'
/Users/lisas/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/json/common.rb:155:in `parse'
/Users/lisas/.rvm/gems/ruby-2.0.0-p643/gems/cocoapods-core-1.1.0.beta.1/lib/cocoapods-core/source/manager.rb:251:in
`stored_search_index'
/Users/lisas/.rvm/gems/ruby-2.0.0-p643/gems/cocoapods-core-1.1.0.beta.1/lib/cocoapods-core/source/manager.rb:187:in
`updated_search_index'
/Users/lisas/.rvm/gems/ruby-2.0.0-p643/gems/cocoapods-core-1.1.0.beta.1/lib/cocoapods-core/source/manager.rb:118:in
`search_by_name'
/Users/lisas/.rvm/gems/ruby-2.0.0-p643@global/gems/cocoapods-search-1.0.0/lib/cocoapods-search/command/search.rb:87:in
`local_search'
/Users/lisas/.rvm/gems/ruby-2.0.0-p643@global/gems/cocoapods-search-1.0.0/lib/cocoapods-search/command/search.rb:63:in `run'
/Users/lisas/.rvm/gems/ruby-2.0.0-p643@global/gems/claide-1.0.0/lib/claide/command.rb:334:in `run'
/Users/lisas/.rvm/gems/ruby-2.0.0-p643/gems/cocoapods-1.1.0.beta.1/lib/cocoapods/command.rb:50:in `run'
/Users/lisas/.rvm/gems/ruby-2.0.0-p643/gems/cocoapods-1.1.0.beta.1/bin/pod:55:in `'
/Users/lisas/.rvm/gems/ruby-2.0.0-p643/bin/pod:22:in `load'
/Users/lisas/.rvm/gems/ruby-2.0.0-p643/bin/pod:22:in `'
```
――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
[!] Oh no, an error occurred.
Search for existing GitHub issues similar to yours:
https://github.com/CocoaPods/CocoaPods/search?q=A+JSON+text+must+at+least+contain+two+octets%21&type=Issues
If none exists, create a ticket, with the template displayed above, on:
https://github.com/CocoaPods/CocoaPods/issues/new
Be sure to first read the contributing guide for details on how to properly submit a ticket:
https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md
Don't forget to anonymize any private data!
Looking for related issues on cocoapods/cocoapods...
- pod search not work JSON ParserError
https://github.com/CocoaPods/CocoaPods/issues/5172 [closed] [5 comments]
19 Apr 2016
这个错误 目前也没找到相关的解决方案,但是值得庆幸的是不影响项目中对cocoapod的使用!!
可以参考:
https://github.com/CocoaPods/CocoaPods/issues/5172
应该是~/Library/Caches/CocoaPods/search_index.json这个文件的问题.
可以使用 rm ~/Library/Caches/CocoaPods/search_index.json 删除后再pod search xxx 会自动重建的.