Malformed version number string--iOS.cocoapod安装报错

最近新换电脑安装cocospod时出现点小问题,安装时一路走下去都OK,到最后pod install时报出一个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 `'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `
'
――― 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)

这就很尴尬了,然后我网上搜了一下还没有解决的方法,于是只能按照提示上github上重新找结果,还好我看到有很多人都有这样的问题,于是按照给出来的解决方案解决了问题。

如何解决

简单来说就是一句话,升级ruby并且重新安装cocoapod


屏幕快照 2018-05-25 下午6.18.59.png

怎么解决

1.终端输入ruby - v ,查看ruby版本,这里我发现自己ruby的版本记为2.3.3。
2.然后输入rvm list known ,查看当前所有ruby版本,发现最新版本已经到2.4 .1。
3.所以重新 rvm install 2.4.1导入最新版,这里需要提醒一下,可以提前把xcode版本和mac版本都升级为最新,不然会卡住(其实也不是卡,终端会自动下载,但总感觉没有自己下载快)。期间安装homebrew记得输入两次回车,不要傻等哦。
4.如果没有问题的话看到 Install of ruby-2.4.1 - #complete 这句话就算是安装成功,可以进行下一步了。
5.接下来重新安装cocoapod,终端输入sudo gem install -n /usr/local/bin cocoapods,这里需要说一点,老版本直接sudo gem install cocoapods就行了,但是新版的mac系统不支持直接进入,所以需要自己设置安装位置。
6.没问题的话最后输入pod setup,这期间可能需要稍微等待一下,最后看到Setup completed就成功了,可以尽情pod install了。

当时cocopod导入的时候出现故障确实挺烦的,网上也没有搜到靠破的解决方案,最后根据报错提示在github issues上找到了问题的解决方案,同时也发现大家都是最近几天才出的问题,所以想要写一下以备别人多走弯路。本人邮箱[email protected],不懂的地方可以加之共勉

你可能感兴趣的:(Malformed version number string--iOS.cocoapod安装报错)