最近新?lián)Q電腦安裝cocospod時(shí)出現(xiàn)點(diǎn)小問題,安裝時(shí)一路走下去都OK,到最后pod install時(shí)報(bào)出一個(gè)s[!] Oh no, an error occurred.具體如下圖厅篓,
ArgumentError - Malformed version number string
/Library/Ruby/Site/2.3.0/rubygems/version.rb:209:in `initialize'
/Library/Ruby/Site/2.3.0/rubygems/version.rb:200:in `new'
/Library/Ruby/Site/2.3.0/rubygems/version.rb:200:in `new'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.2/lib/cocoapods/generator/xcconfig/aggregate_xcconfig.rb:123:in `embedded_content_settings'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.2/lib/cocoapods/generator/xcconfig/aggregate_xcconfig.rb:68:in `generate'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.2/lib/cocoapods/generator/xcconfig/aggregate_xcconfig.rb:39:in `save_as'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.2/lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb:112:in `update_changed_file'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.2/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb:96:in `block in create_xcconfig_file'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.2/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb:93:in `each'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.2/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb:93:in `create_xcconfig_file'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.2/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb:18:in `block in install!'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.2/lib/cocoapods/user_interface.rb:142:in `message'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.2/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb:14:in `install!'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.2/lib/cocoapods/installer/xcode/pods_project_generator.rb:181:in `block (2 levels) in install_libraries'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.2/lib/cocoapods/installer/xcode/pods_project_generator.rb:179:in `each'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.2/lib/cocoapods/installer/xcode/pods_project_generator.rb:179:in `block in install_libraries'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.2/lib/cocoapods/user_interface.rb:142:in `message'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.2/lib/cocoapods/installer/xcode/pods_project_generator.rb:167:in `install_libraries'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.2/lib/cocoapods/installer/xcode/pods_project_generator.rb:65:in `generate!'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.2/lib/cocoapods/installer.rb:184:in `block in generate_pods_project'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.2/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.2/lib/cocoapods/installer.rb:183:in `generate_pods_project'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.2/lib/cocoapods/installer.rb:119:in `install!'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.2/lib/cocoapods/command/install.rb:41:in `run'
/Library/Ruby/Gems/2.3.0/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.2/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.2/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=Malformed+version+number+string+&type=Issues](https://github.com/CocoaPods/CocoaPods/search?q=Malformed+version+number+string+&type=Issues)
If none exists, create a ticket, with the template displayed above, on:
[https://github.com/CocoaPods/CocoaPods/issues/new](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](https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md)
Don't forget to anonymize any private data!
Looking for related issues on cocoapods/cocoapods...
* Malformed version number string
[#7765](https://github.com/CocoaPods/CocoaPods/issues/7765) [open] [12 comments]
4 hours ago
* ArgumentError - Malformed version number string $(inherited)
[#6634](https://github.com/CocoaPods/CocoaPods/issues/6634) [closed] [5 comments]
20 hours ago
* help!
[#7763](https://github.com/CocoaPods/CocoaPods/issues/7763) [closed] [2 comments]
15 hours ago
and 31 more at:
[https://github.com/cocoapods/cocoapods/search?q=Malformed%20version%20number%20string%20&type=Issues&utf8=?](https://github.com/cocoapods/cocoapods/search?q=Malformed%20version%20number%20string%20&type=Issues&utf8=%E2%9C%93)
這就很尷尬了艺糜,然后我網(wǎng)上搜了一下還沒有解決的方法,于是只能按照提示上github上重新找結(jié)果蝠嘉,還好我看到有很多人都有這樣的問題缴允,于是按照給出來的解決方案解決了問題。
如何解決
簡(jiǎn)單來說就是一句話珍德,升級(jí)ruby并且重新安裝cocoapod
怎么解決
1.終端輸入ruby - v 练般,查看ruby版本,這里我發(fā)現(xiàn)自己ruby的版本記為2.3.3锈候。
2.然后輸入rvm list known 薄料,查看當(dāng)前所有ruby版本,發(fā)現(xiàn)最新版本已經(jīng)到2.4 .1泵琳。
3.所以重新 rvm install 2.4.1導(dǎo)入最新版摄职,這里需要提醒一下,可以提前把xcode版本和mac版本都升級(jí)為最新获列,不然會(huì)卡坠仁小(其實(shí)也不是卡,終端會(huì)自動(dòng)下載击孩,但總感覺沒有自己下載快)迫悠。期間安裝homebrew記得輸入兩次回車,不要傻等哦巩梢。
4.如果沒有問題的話看到 Install of ruby-2.4.1 - #complete 這句話就算是安裝成功创泄,可以進(jìn)行下一步了。
5.接下來重新安裝cocoapod括蝠,終端輸入sudo gem install -n /usr/local/bin cocoapods鞠抑,這里需要說一點(diǎn),老版本直接sudo gem install cocoapods就行了忌警,但是新版的mac系統(tǒng)不支持直接進(jìn)入搁拙,所以需要自己設(shè)置安裝位置。
6.沒問題的話最后輸入pod setup,這期間可能需要稍微等待一下感混,最后看到Setup completed就成功了端幼,可以盡情pod install了。
當(dāng)時(shí)cocopod導(dǎo)入的時(shí)候出現(xiàn)故障確實(shí)挺煩的弧满,網(wǎng)上也沒有搜到靠破的解決方案婆跑,最后根據(jù)報(bào)錯(cuò)提示在github issues上找到了問題的解決方案,同時(shí)也發(fā)現(xiàn)大家都是最近幾天才出的問題庭呜,所以想要寫一下以備別人多走彎路滑进。本人郵箱1441704523@qq.com,不懂的地方可以加之共勉