CocoaPods 出現LoadError - cannot load such file -- nanaimo錯誤解決辦法
如果經常使用 CocoaPods 進行個人類庫的提交和更新,那麼肯定會遇到這樣的一個錯誤。如題:LoadError - cannot load such file -- nanaimo,翻譯過來就是 LoadError - 無法加載此類文件 - nanaimo。該錯誤產生的時機一般是在驗證 .podspec 文件的時候。具體的錯誤呈現形式是這樣的:
benpaobaodeiMac-2:WZYUnlimitedScrollView bpb$ pod lib lint -> WZYUnlimitedScrollView ――― MARKDOWN TEMPLATE ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ### Command ``` /usr/local/bin/pod lib lint ``` ### Report * What did you do? * What did you expect to happen? * What happened instead? ### Stack ``` CocoaPods : 1.2.0.beta.1 Ruby : ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16] RubyGems : 2.0.14.1 Host : Mac OS X 10.12.1 (16B2555) Xcode : 8.2.1 (8C1002) Git : git version 2.10.1 (Apple Git-78) Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib Repositories : master - https://github.com/CocoaPods/Specs.git @ 3d3d5f5d2fbb80e043adfd3ad3357a10845cf349 ``` ### Plugins ``` cocoapods-deintegrate : 1.0.1 cocoapods-plugins : 1.0.0 cocoapods-search : 1.0.0 cocoapods-stats : 1.0.0 cocoapods-trunk : 1.1.1 cocoapods-try : 1.1.0 ``` ### Error ``` LoadError - cannot load such file -- nanaimo /Library/Ruby/Gems/2.0.0/gems/xcodeproj-1.4.1/lib/xcodeproj/project.rb:353:in `block in save' /Library/Ruby/Gems/2.0.0/gems/xcodeproj-1.4.1/lib/xcodeproj/project.rb:353:in `open' /Library/Ruby/Gems/2.0.0/gems/xcodeproj-1.4.1/lib/xcodeproj/project.rb:353:in `save' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.0.beta.1/lib/cocoapods/validator.rb:412:in `create_app_project' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.0.beta.1/lib/cocoapods/validator.rb:300:in `block in perform_extensive_analysis' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.0.beta.1/lib/cocoapods/validator.rb:295:in `each' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.0.beta.1/lib/cocoapods/validator.rb:295:in `perform_extensive_analysis' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.0.beta.1/lib/cocoapods/validator.rb:79:in `validate' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.0.beta.1/lib/cocoapods/command/lib/lint.rb:62:in `block in run' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.0.beta.1/lib/cocoapods/command/lib/lint.rb:50:in `each' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.0.beta.1/lib/cocoapods/command/lib/lint.rb:50:in `run' /Library/Ruby/Gems/2.0.0/gems/claide-1.0.1/lib/claide/command.rb:334:in `run' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.0.beta.1/lib/cocoapods/command.rb:50:in `run' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.0.beta.1/bin/pod:55:in `<top (required)>' /usr/local/bin/pod:23:in `load' /usr/local/bin/pod:23:in `<main>' ``` ――― TEMPLATE END ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― [!] Oh no, an error occurred. Search for existing GitHub issues similar to yours: https://github.com/CocoaPods/CocoaPods/search?q=cannot+load+such+file+--+nanaimo&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... - LoadError - cannot load such file -- nanaimo https://github.com/CocoaPods/CocoaPods/issues/6281 [closed] [12 comments] 2 days ago - help! cannot load such file -- nanaimo https://github.com/CocoaPods/CocoaPods/issues/6312 [closed] [6 comments] 6 weeks ago - LoadError - cannot load such file -- nanaimo https://github.com/CocoaPods/CocoaPods/issues/6214 [closed] [30 comments] 4 weeks ago and 10 more at: https://github.com/cocoapods/cocoapods/search?q=cannot%20load%20such%20file%20--%20nanaimo&type=Issues&utf8=✓
上述錯誤,可以有兩種方式進行解決。大家可以分別嘗試,總有一種適合你。
方式一,重新安裝 CocoaPods 的類庫。
先清空 CocoaPods 的緩存:
$ sudo rm -rf ~/.cocoapods/repos/master $ sudo rm -fr ~/Library/Caches/CocoaPods/
再重新安裝 CocoaPods 的類庫:
$ pod setup
注意,細心的童鞋可能發現。上面兩行清楚緩存的語句不太一樣。分別是 rm -rf 和 rm -fr,它們其實是沒有區別的,表示強制(f:不提示)刪除文件和目錄(r:刪除)
但方式一可能用起來不會那麼順暢,該錯誤產生的大多數原因還是應該用方式二來解決。
方式二,對 nanaimo 進行刪除並重新加載
$ sudo gem uninstall nanaimo $ sudo gem install nanaimo
運行上面兩行代碼的結果:
benpaobaodeiMac-2:WZYUnlimitedScrollView bpb$ sudo gem uninstall nanaimo Password: Select gem to uninstall: 1. nanaimo-0.2.2 2. nanaimo-0.2.3 3. All versions > 3 Successfully uninstalled nanaimo-0.2.2 You have requested to uninstall the gem: nanaimo-0.2.3 xcodeproj-1.4.1 depends on nanaimo (~> 0.2.0) If you remove this gem, these dependencies will not be met. Continue with Uninstall? [yN] y Successfully uninstalled nanaimo-0.2.3 benpaobaodeiMac-2:WZYUnlimitedScrollView bpb$ sudo gem install nanaimo Fetching: nanaimo-0.2.3.gem (100%) Successfully installed nanaimo-0.2.3 Parsing documentation for nanaimo-0.2.3 Installing ri documentation for nanaimo-0.2.3 1 gem installed
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!