cocoapods常见错误记录

[2017-03-30]

搜索插件pod search AFNetworking,出现下列错误:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
JSON::ParserError - A JSON text must at least contain two octets!
/Users/sun/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/json/common.rb:156:in `initialize'
/Users/sun/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/json/common.rb:156:in `new'
/Users/sun/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/json/common.rb:156:in `parse'
/Users/sun/.rvm/gems/ruby-2.3.0/gems/cocoapods-core-1.2.0/lib/cocoapods-core/source/manager.rb:251:in `stored_search_index'
/Users/sun/.rvm/gems/ruby-2.3.0/gems/cocoapods-core-1.2.0/lib/cocoapods-core/source/manager.rb:187:in `updated_search_index'
/Users/sun/.rvm/gems/ruby-2.3.0/gems/cocoapods-core-1.2.0/lib/cocoapods-core/source/manager.rb:118:in `search_by_name'
/Users/sun/.rvm/gems/ruby-2.3.0/gems/cocoapods-search-1.0.0/lib/cocoapods-search/command/search.rb:87:in `local_search'
/Users/sun/.rvm/gems/ruby-2.3.0/gems/cocoapods-search-1.0.0/lib/cocoapods-search/command/search.rb:63:in `run'
/Users/sun/.rvm/gems/ruby-2.3.0/gems/claide-1.0.1/lib/claide/command.rb:334:in `run'
/Users/sun/.rvm/gems/ruby-2.3.0/gems/cocoapods-1.2.0/lib/cocoapods/command.rb:52:in `run'
/Users/sun/.rvm/gems/ruby-2.3.0/gems/cocoapods-1.2.0/bin/pod:55:in `<top (required)>'
/Users/sun/.rvm/gems/ruby-2.3.0/bin/pod:22:in `load'
/Users/sun/.rvm/gems/ruby-2.3.0/bin/pod:22:in `<main>'
/Users/sun/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
/Users/sun/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'

解决方法

删除空文件~/Library/Caches/CocoaPods/search_index.json,然后重试即可。
参考资料https://github.com/CocoaPods/CocoaPods/issues/5172