无法使用cocoapods解决方式

初始化pod文件失败

$ pod init

-bash: /usr/local/bin/pod: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby: bad interpreter: No such file or directory

重新下载cocoapods失败

$sudo gem install cocoapods

Fetching: concurrent-ruby-1.0.5.gem (100%)
Successfully installed concurrent-ruby-1.0.5
Fetching: i18n-0.9.1.gem (100%)
Successfully installed i18n-0.9.1
Fetching: thread_safe-0.3.6.gem (100%)
Successfully installed thread_safe-0.3.6
Fetching: tzinfo-1.2.4.gem (100%)
Successfully installed tzinfo-1.2.4
Fetching: activesupport-4.2.10.gem (100%)
Successfully installed activesupport-4.2.10
Fetching: nap-1.1.0.gem (100%)
Successfully installed nap-1.1.0
Fetching: fuzzy_match-2.0.4.gem (100%)
Successfully installed fuzzy_match-2.0.4
Fetching: cocoapods-core-1.4.0.gem (100%)
Successfully installed cocoapods-core-1.4.0
Fetching: claide-1.0.2.gem (100%)
Successfully installed claide-1.0.2
Fetching: cocoapods-deintegrate-1.0.2.gem (100%)
Successfully installed cocoapods-deintegrate-1.0.2
Fetching: cocoapods-downloader-1.1.3.gem (100%)
Successfully installed cocoapods-downloader-1.1.3
Fetching: cocoapods-plugins-1.0.0.gem (100%)
Successfully installed cocoapods-plugins-1.0.0
Fetching: cocoapods-search-1.0.0.gem (100%)
Successfully installed cocoapods-search-1.0.0
Fetching: cocoapods-stats-1.0.0.gem (100%)
Successfully installed cocoapods-stats-1.0.0
Fetching: netrc-0.11.0.gem (100%)
Successfully installed netrc-0.11.0
Fetching: cocoapods-trunk-1.3.0.gem (100%)
Successfully installed cocoapods-trunk-1.3.0
Fetching: cocoapods-try-1.1.0.gem (100%)
Successfully installed cocoapods-try-1.1.0
Fetching: molinillo-0.6.4.gem (100%)
Successfully installed molinillo-0.6.4
Fetching: CFPropertyList-2.3.6.gem (100%)
Successfully installed CFPropertyList-2.3.6
Fetching: colored2-3.1.2.gem (100%)
Successfully installed colored2-3.1.2
Fetching: nanaimo-0.2.3.gem (100%)
Successfully installed nanaimo-0.2.3
Fetching: xcodeproj-1.5.4.gem (100%)
ERROR: While executing gem ... (TypeError)
no implicit conversion of nil into String
me:te JunJie$ sudo gem install -n /usr/local/bin cocoapods --pre
ERROR: While executing gem ... (TypeError)
no implicit conversion of nil into String

查看源

$gem sources -l

*** CURRENT SOURCES ***

添加源

$gem source -a https://gems.ruby-china.org/

https://gems.ruby-china.org/ added to sources

更新gem

$sudo gem update --system

Updating rubygems-update
Fetching: rubygems-update-2.6.14.gem (100%)
Successfully installed rubygems-update-2.6.14
Parsing documentation for rubygems-update-2.6.14
Installing ri documentation for rubygems-update-2.6.14
Installing darkfish documentation for rubygems-update-2.6.14
Done installing documentation for rubygems-update after 43 seconds
Parsing documentation for rubygems-update-2.6.14
Done installing documentation for rubygems-update after 0 seconds
Installing RubyGems 2.6.14
RubyGems 2.6.14 installed
Parsing documentation for rubygems-2.6.14
Installing ri documentation for rubygems-2.6.14

=== 2.6.14 / 2017-10-09

Security fixes:

  • Whitelist classes and symbols that are in loaded YAML.
    See CVE-2017-0903 for full details.
    Fix by Aaron Patterson.

=== 2.6.13 / 2017-08-27

Security fixes:

  • Fix a DNS request hijacking vulnerability.
    Fix by Samuel Giddins.
  • Fix an ANSI escape sequence vulnerability.
    Fix by Evan Phoenix.
  • Fix a DOS vulernerability in the query command.
    Fix by Samuel Giddins.
  • Fix a vulnerability in the gem installer that allowed
    a malicious gem to overwrite arbitrary files.
    Fix by Samuel Giddins.

=== 2.6.12 / 2017-04-30

Bug fixes:

  • Fix test_self_find_files_with_gemfile to sort expected files. Pull
    request #1880 by Kazuaki Matsuo.
  • Fix issue for MinGW / MSYS2 builds and testing. Pull request #1879 by
    MSP-Greg.
  • Fix gem open to open highest version number rather than lowest. Pull
    request #1877 by Tim Pope.
  • Add a test for requiring a default spec as installed by the ruby
    installer. Pull request #1899 by Samuel Giddins.
  • Fix broken --exact parameter to gem command. Pull request #1873 by Jason
    Frey.
  • [Installer] Generate backwards-compatible binstubs. Pull request #1904
    by Samuel Giddins.
  • Fix pre-existing source recognition on add action. Pull request #1883 by
    Jonathan Claudius.
  • Prevent negative IDs in output of #inspect. Pull request #1908 by Vít
    Ondruch.
  • Allow Gem.finish_resolve to respect already-activated specs. Pull
    request #1910 by Samuel Giddins.

=== 2.6.11 / 2017-03-16

Bug fixes:

  • Fixed broken tests on ruby-head. Pull request #1841 by
    SHIBATA Hiroshi.
  • Update vendored Molinillo to 0.5.7. Pull request #1859 by Samuel
    Giddins.
  • Avoid activating Ruby 2.5 default gems when possible. Pull request #1843
    by Samuel Giddins.
  • Use improved resolver sorting algorithm. Pull request #1856 by
    Samuel Giddins.

=== 2.6.10 / 2017-01-23

Bug fixes:

  • Fix require calling the wrong gem method when it is overridden.
    Pull request #1822 by Samuel Giddins.

=== 2.6.9 / 2017-01-20

Bug fixes:

  • Allow initializing versions with empty strings. Pull request #1767 by
    Luis Sagastume.
  • Fix TypeError on 2.4. Pull request #1788 by Nobuyoshi Nakada.
  • Don't output mkmf.log message if compilation didn't fail. Pull request

    1808 by Jeremy Evans.

  • Fixed broken links and overzealous URL encoding in gem server. Pull
    request #1809 by Nicole Orchard.
  • Update vendored Molinillo to 0.5.5. Pull request #1812 by Samuel
    Giddins.
  • RakeBuilder: avoid frozen string issue. Pull request #1819 by Olle
    Jonsson.

=== 2.6.8 / 2016-10-29

Bug fixes:

  • Improve SSL verification failure message. Pull request #1751
    by Eric Hodel.
  • Ensure to_spec falls back on prerelease specs. Pull request

    1755 by André Arko.

  • Update vendored Molinillo to 0.5.3. Pull request #1763 by
    Samuel Giddins.

=== 2.6.7 / 2016-09-26

Bug fixes:

  • Install native extensions in the correct location when using the
    --user-install flag. Pull request #1683 by Noah Kantrowitz.
  • When calling Gem.sources, load sources from configuration
    if present, else use the default sources. Pull request #1699
    by Luis Sagastume.
  • Fail gracefully when attempting to redirect without a Location.
    Pull request #1711 by Samuel Giddins.
  • Update vendored Molinillo to 0.5.1. Pull request #1714 by
    Samuel Giddins.

=== 2.6.6 / 2016-06-22

Bug fixes:

  • Sort installed versions to make sure we install the latest version when
    running gem update --system. As a one-time fix, run
    gem update --system=2.6.6. Pull request #1601 by David Radcliffe.

=== 2.6.5 / 2016-06-21

Minor enhancements:

  • Support for unified Integer in Ruby 2.4. Pull request #1618
    by SHIBATA Hiroshi.
  • Update vendored Molinillo to 0.5.0 for performance improvements.
    Pull request #1638 by Samuel Giddins.

Bug fixes:

  • Raise an explicit error if Signer#sign is called with no certs. Pull
    request #1605 by Daniel Berger.
  • Update update_bundled_ca_certificates utility script for directory
    nesting. Pull request #1583 by James Wen.
  • Fix broken symlink support in tar writer (+ fix broken test). Pull
    request #1578 by Cezary Baginski.
  • Remove extension directory before (re-)installing. Pull request #1576
    by Jeremy Hinegardner.
  • Regenerate test CA certificates with appropriate extensions. Pull
    request #1611 by rhenium.
  • Rubygems does not terminate on failed file lock when not superuser. Pull
    request #1582 by Ellen Marie Dash.
  • Fix tar headers with a 101 character name. Pull request #1612 by Paweł
    Tomulik.
  • Add Gem.platform_defaults to allow implementations to override defaults.
    Pull request #1644 by Charles Oliver Nutter.
  • Run Bundler tests on TravisCI. Pull request #1650 by Samuel Giddins.

=== 2.6.4 / 2016-04-26

Minor enhancements:

  • Use Gem::Util::NULL_DEVICE instead of hard coded strings. Pull request #1588
    by Chris Charabaruk.
  • Use File.symlink on MS Windows if supported. Pull request #1418
    by Nobuyoshi Nakada.

Bug fixes:

  • Redact uri password from error output when gem fetch fails. Pull request

    1565 by Brian Fletcher.

  • Suppress warnings. Pull request #1594 by Nobuyoshi Nakada.
  • Escape user-supplied content served on web pages by gem server to avoid
    potential XSS vulnerabilities. Samuel Giddins.

=== 2.6.3 / 2016-04-05

Minor enhancements:

  • Lazily calculate Gem::LoadError exception messages. Pull request #1550
    by Aaron Patterson.
  • New fastly cert. Pull request #1548 by David Radcliffe.
  • Organize and cleanup SSL certs. Pull request #1555 by James Wen.
  • [RubyGems] Make deprecation message for paths= more helpful. Pull
    request #1562 by Samuel Giddins.
  • Show default gems when using "gem list". Pull request #1570 by Luis
    Sagastume.

Bug fixes:

  • Stub ordering should be consistent regardless of how cache is populated.
    Pull request #1552 by Aaron Patterson.
  • Handle cases when the @@stubs variable contains non-stubs. Pull request

    1558 by Per Lundberg.

  • Fix test on Windows for inconsistent temp path. Pull request #1554 by
    Hiroshi Shirosaki.
  • Fix Gem.find_spec_for_exe picks oldest gem. Pull request #1566 by
    Shinichi Maeshima.
  • [Owner] Fallback to email and userid when owner email is missing. Pull
    request #1569 by Samuel Giddins.
  • [Installer] Handle nil existing executable. Pull request #1561 by Samuel
    Giddins.
  • Allow two digit version numbers in the tests. Pull request #1575 by unak.

=== 2.6.2 / 2016-03-12

Bug fixes:

  • Fix wrong version of gem activation for bin stub. Pull request #1527 by
    Aaron Patterson.
  • Speed up gem activation failures. Pull request #1539 by Aaron Patterson.
  • Fix platform sorting in the resolver. Pull request #1542 by Samuel E.
    Giddins.
  • Ensure we unlock the monitor even if try_activate throws. Pull request

    1538 by Charles Oliver Nutter.

=== 2.6.1 / 2016-02-28

Bug fixes:

  • Ensure default_path and home are set for paths. Pull request #1513
    by Aaron Patterson.
  • Restore but deprecate support for Array values on Gem.paths=. Pull
    request #1514 by Aaron Patterson.
  • Fix invalid gem file preventing gem install from working. Pull request

    1499 by Luis Sagastume.

=== 2.6.0 / 2016-02-26

Minor enhancements:

  • RubyGems now defaults the gem push to the gem's "allowed_push_host"
    metadata setting. Pull request #1486 by Josh Lane.
  • Update bundled Molinillo to 0.4.3. Pull request #1493 by Samuel E. Giddins.
  • Add version option to gem open command. Pull request #1483 by Hrvoje
    Šimić.
  • Feature/add silent flag. Pull request #1455 by Luis Sagastume.
  • Allow specifying gem requirements via env variables. Pull request #1472
    by Samuel E. Giddins.

Bug fixes:

  • RubyGems now stores gem push credentials under the host you signed-in for.
    Pull request #1485 by Josh Lane.
  • Move coding location to first line. Pull request #1471 by SHIBATA
    Hiroshi.
  • [PathSupport] Handle a regexp path separator. Pull request #1469 by
    Samuel E. Giddins.
  • Clean up the PathSupport object. Pull request #1094 by Aaron Patterson.
  • Join with File::PATH_SEPARATOR in Gem.use_paths. Pull request #1476 by
    Samuel E. Giddins.
  • Handle when the gem home and gem path arent set in the config file. Pull
    request #1478 by Samuel E. Giddins.
  • Terminate TimeoutHandler. Pull request #1479 by Nobuyoshi Nakada.
  • Remove redundant cache. Pull request #1482 by Eileen M. Uchitelle.
  • Freeze Gem::Version@segments instance variable. Pull request #1487 by
    Ben Dean.
  • Gem cleanup is trying to uninstall gems outside GEM_HOME and reporting
    an error after it tries. Pull request #1353 by Luis Sagastume.
  • Avoid duplicated sources. Pull request #1489 by Luis Sagastume.
  • Better description for quiet flag. Pull request #1491 by Luis Sagastume.
  • Raise error if find_by_name returns with nil. Pull request #1494 by
    Zoltán Hegedüs.
  • Find_files only from loaded_gems when using gemdeps. Pull request #1277
    by Michal Papis.

=== 2.5.2 / 2016-01-31

Bug fixes:

  • Fix memoization of Gem::Version#prerelease? Pull request #1125 by Matijs van
    Zuijlen.
  • Handle trailing colons in GEM_PATH, by Damien Robert.
  • Improve the Gemfile gemspec method, fixing #1204 and #1033. Pull request

    1276 by Michael Papis.

  • Warn only once when a gemspec license is invalid. Pull request #1414 by Samuel
    E. Giddins.
  • Check for exact constants before using them, fixing Ruby bug #11940. Pull
    request #1438 by Nobuyoshi Nakada.
  • Fix building C extensions on Ruby 1.9.x on Windows. Pull request #1453 by Marie
    Markwell.
  • Handle symlinks containing ".." correctly. Pull request #1457 by Samuel E.
    Giddins.

Minor enhancements:

  • Add --no-rc flag, which skips loading .gemrc. Pull request #1329 by Luis
    Sagastume.
  • Allow basic auth to be excluded from allowed_push_host. By Josh Lane.
  • Add gem list --exact, which finds gems by string match instead of regex. Pull
    request #1344 by Luis Sagastume.
  • Suggest alternatives when gem license is unknown. Pull request #1443 by Samuel
    E. Giddins.
  • Print a useful error if a binstub expects a newer version of a gem than is
    installed. Pull request #1407 by Samuel E. Giddins.
  • Allow the (supported) s3:// scheme to be used with --source. Pull request

    1416 by Dave Adams.

  • Add --[no-]post-install-message to install and update. Pull request #1162
    by Josef Šimánek.
  • Add --host option to yank, providing symmetry with pull. Pull request

    1361 by Mike Virata-Stone.

  • Update bundled Molinillo to 0.4.1. Pull request #1452 by Samuel E. Giddins.
  • Allow calling build without '.gemspec'. Pull request #1454 by Stephen
    Blackstone.
  • Add support for source option on gems in Gemfile. Pull request #1355 by
    Michael Papis.
  • Function correctly when string literals are frozen on Ruby 2.3. Pull request

    1408 by Samuel E. Giddins.


RubyGems installed the following executables:
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/gem

Ruby Interactive (ri) documentation was installed. ri is kind of like man
pages for ruby libraries. You may access it like this:
ri Classname
ri Classname.class_method
ri Classname#instance_method
If you do not wish to install this documentation in the future, use the
--no-document flag, or set it as the default in your ~/.gemrc file. See
'gem help env' for details.

RubyGems system software updated

卸载cocoapods

$sudo gem uninstall cocoapods

重新安装cocoapods

$ sudo gem install -n /usr/local/bin cocoapods

Successfully installed xcodeproj-1.5.4
Fetching: escape-0.0.4.gem (100%)
Successfully installed escape-0.0.4
Fetching: fourflusher-2.0.1.gem (100%)
Successfully installed fourflusher-2.0.1
Fetching: gh_inspector-1.0.3.gem (100%)
Successfully installed gh_inspector-1.0.3
Fetching: ruby-macho-1.1.0.gem (100%)
Successfully installed ruby-macho-1.1.0
Fetching: cocoapods-1.4.0.gem (100%)
Successfully installed cocoapods-1.4.0
Parsing documentation for xcodeproj-1.5.4
Installing ri documentation for xcodeproj-1.5.4
Parsing documentation for escape-0.0.4
Installing ri documentation for escape-0.0.4
Parsing documentation for fourflusher-2.0.1
Installing ri documentation for fourflusher-2.0.1
Parsing documentation for gh_inspector-1.0.3
Installing ri documentation for gh_inspector-1.0.3
Parsing documentation for ruby-macho-1.1.0
Installing ri documentation for ruby-macho-1.1.0
Parsing documentation for cocoapods-1.4.0
Installing ri documentation for cocoapods-1.4.0
Done installing documentation for xcodeproj, escape, fourflusher, gh_inspector, ruby-macho, cocoapods after 8 seconds
6 gems installed
me:te JunJie$ pod setup
Setting up CocoaPods master repo
$ /usr/bin/git -C /Users/weijunjie/.cocoapods/repos/master fetch origin
--progress
remote: Counting objects: 1001712, done.
remote: Compressing objects: 100% (245/245), done.
Receiving objects: 100% (1001712/1001712), 159.27 MiB | 31.00 KiB/s, done.
remote: Total 1001712 (delta 35411), reused 35301 (delta 35301), pack-reused 966150
Resolving deltas: 100% (663514/663514), completed with 3845 local objects.
From https://github.com/CocoaPods/Specs
83e8a706fb5..15b1c89c5fc master -> origin/master

  • [new branch] backz -> origin/backz
  • [new branch] predates_sharding_branch -> origin/predates_sharding_branch
  • [new branch] swift_version_support -> origin/swift_version_support
  • [new tag] v0.32.1 -> v0.32.1
    $ /usr/bin/git -C /Users/weijunjie/.cocoapods/repos/master rev-parse
    --abbrev-ref HEAD
    master
    $ /usr/bin/git -C /Users/weijunjie/.cocoapods/repos/master reset --hard
    origin/master
    Checking out files: 100% (327026/327026), done.
    HEAD is now at 15b1c89c5fc [Add] WKWebViewController 1.0.0
    warning: inexact rename detection was skipped due to too many files.
    Setup completed

搞定

$ pod search sdwebimage

SDWebImage (4.2.3)
Asynchronous image downloader with cache support with an UIImageView
category.
pod 'SDWebImage', '~> 4.2.3'

  • Homepage: https://github.com/rs/SDWebImage
  • Source: https://github.com/rs/SDWebImage.git
  • Versions: 4.2.3, 4.2.2, 4.2.1, 4.2.0, 4.1.2, 4.1.1, 4.1.0, 4.0.0,
    4.0.0-beta2, 4.0.0-beta, 3.8.2, 3.8.1, 3.8.0, 3.7.6, 3.7.5, 3.7.4, 3.7.3,
    3.7.2, 3.7.1, 3.7.0, 3.6, 3.5.4, 3.5.2, 3.5.1, 3.5, 3.4, 3.3, 3.2, 3.1, 3.0,
    2.7.4, 2.7, 2.6, 2.5, 2.4 [master repo]
  • Subspecs:
    • SDWebImage/Core (4.2.3)
    • SDWebImage/MapKit (4.2.3)
    • SDWebImage/GIF (4.2.3)
    • SDWebImage/WebP (4.2.3)

总结:

电脑版本升级后,cocoapods无法使用,淘宝的镜像无法使用,需要设置镜像为gem source -a https://gems.ruby-china.org/,更新gem,卸载cocoapods,在安装cocoapods即可!

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 194,524评论 5 460
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 81,869评论 2 371
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 141,813评论 0 320
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 52,210评论 1 263
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 61,085评论 4 355
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 46,117评论 1 272
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 36,533评论 3 381
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 35,219评论 0 253
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 39,487评论 1 290
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 34,582评论 2 309
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 36,362评论 1 326
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,218评论 3 312
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 37,589评论 3 299
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 28,899评论 0 17
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,176评论 1 250
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 41,503评论 2 341
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 40,707评论 2 335

推荐阅读更多精彩内容