天天看點

iOS元件化開發一本地環境配置(一)删除~/Library/Caches/CocoaPods目錄下的search_index.json檔案

首先我們要使用pod支援元件化開發

  • 解決CocoaPods慢的方案(gem和pod repo換源)
  • gem換源 

    $ gem sources --remove https://rubygems.org/ # 移除預設源 

    $ gem sources -a https://gems.ruby-china.org/ # 添加Ruby China鏡像 

    $ gem sources -l 

    確定隻有gems.ruby-china.org源

    pod repo換源 

    $ pod repo 

    預設是GitHub源

    master 

    - Type: git (master) 

    - URL: https://github.com/CocoaPods/Specs.git 

    - Path: /Users/cheng/.cocoapods/repos/master 

    1 repo 

    我們把它換成Coding.net源

  • $ pod repo remove master 

    $ pod repo add master https://git.coding.net/CocoaPods/Specs.git 

    $ pod repo update 

    如果執行pod repo add出現錯誤

  • 錯誤 

    那麼使用以下辦法

    $ git clone https://git.coding.net/CocoaPods/Specs.git ~/.cocoapods/repos/master 

    另外,如果Podfile檔案中有

    source 'https://github.com/CocoaPods/Specs.git' 

    也需要把它換成repo的源,否則依然是使用GitHub源

    上面的步驟都完成後,即可使用

    $ pod install 

    $ pod update 

pod search AFNetworking

出現錯誤:

1、what did you do ?

2、Unable to find a pod with name, author, summary, or descriptionmatching

等錯誤

删除~/Library/Caches/CocoaPods目錄下的search_index.json檔案

pod setup成功後,依然不能pod search,是因為之前你執行pod search生成了search_index.json,此時需要删掉。

終端輸入:rm ~/Library/Caches/CocoaPods/search_index.json

删除成功後,再執行pod search。

pod search MobileKit

[!] An unexpected version directory `Classes` was encountered for the `/Users/zhangpeng/.cocoapods/repos/gitee-peter_zhang-mobilekit/MobileKit` Pod in the `MobileKit` repository.

$ cd /Users/zhangpeng/.cocoapods/repos/

$ ls

master   gitee-peter_zhang-mobilekit.   MobileKitSpec

删除多餘的