{"id":218,"date":"2025-11-25T16:18:36","date_gmt":"2025-11-25T08:18:36","guid":{"rendered":"https:\/\/www.52runoob.com\/?p=218"},"modified":"2025-11-25T16:18:36","modified_gmt":"2025-11-25T08:18:36","slug":"mac-%e6%96%b0%e7%94%b5%e8%84%91%e5%ae%89%e8%a3%85cocoapods%e6%8a%a5%e9%94%99ruby%e7%89%88%e6%9c%ac%e8%bf%87%e4%bd%8e","status":"publish","type":"post","link":"https:\/\/www.52runoob.com\/index.php\/2025\/11\/25\/mac-%e6%96%b0%e7%94%b5%e8%84%91%e5%ae%89%e8%a3%85cocoapods%e6%8a%a5%e9%94%99ruby%e7%89%88%e6%9c%ac%e8%bf%87%e4%bd%8e\/","title":{"rendered":"Mac \u65b0\u7535\u8111\u5b89\u88c5cocoapods\u62a5\u9519ruby\u7248\u672c\u8fc7\u4f4e"},"content":{"rendered":"\n<p>\u4e0b\u9762\u7ed9\u4f60\u4e00\u4efd <strong>Mac \u65b0\u7535\u8111\u5b89\u88c5 CocoaPods \u62a5 Ruby \u7248\u672c\u8fc7\u4f4e<\/strong> \u7684\u5b8c\u6574\u89e3\u51b3\u65b9\u6848\uff08\u6700\u65b0\u7248 macOS\u3001M1\/M2\/M3 \u82af\u7247\u5747\u9002\u7528\uff09\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83c\udf4e \u4e3a\u4ec0\u4e48\u4f1a\u62a5 Ruby \u7248\u672c\u8fc7\u4f4e\uff1f<\/h1>\n\n\n\n<p>macOS \u81ea\u5e26\u7cfb\u7edf Ruby\uff08\u4f4d\u7f6e\u5728 <code>\/usr\/bin\/ruby<\/code>\uff09\uff0c\u7248\u672c\u901a\u5e38\u662f <strong>2.6\u30012.7<\/strong>\uff0c\u5df2\u7ecf\u505c\u66f4\u3002<br>\u800c <strong>CocoaPods \u9700\u8981 Ruby \u2265 3.0<\/strong>\uff08\u4f9d\u8d56\u65b0\u7248 openssl\u3001ffi \u7b49\u5e93\uff09\u3002<\/p>\n\n\n\n<p>\u56e0\u6b64\u5fc5\u987b\u5b89\u88c5 <strong>\u65b0\u7248 Ruby<\/strong>\uff08Homebrew \u6216 rbenv \u90fd\u53ef\u4ee5\uff09\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\u2705 \u6700\u63a8\u8350\u65b9\u6848\uff08\u6700\u7a33\u6700\u5e72\u51c0\uff09<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4f7f\u7528 Homebrew \u5b89\u88c5 Ruby\uff08\u5b8c\u5168\u66ff\u4ee3\u7cfb\u7edf Ruby\uff09<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1\ufe0f\u20e3 \u5b89\u88c5 Ruby<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nbrew install ruby\n\n<\/pre><\/div>\n\n\n<p>\u6700\u65b0\u7248\u672c\u5927\u6982\u662f <code>3.3.x<\/code>\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">2\ufe0f\u20e3 \u914d\u7f6e PATH\uff08\u5173\u952e\uff0c\u5426\u5219\u4ecd\u4f1a\u8c03\u7528\u7cfb\u7edf Ruby\uff09<\/h3>\n\n\n\n<p>\u628a Homebrew Ruby \u8bbe\u4e3a\u9ed8\u8ba4 Ruby\uff1a<\/p>\n\n\n\n<p><strong>zsh \u7528\u6237\uff08macOS \u9ed8\u8ba4\uff09<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\necho &#039;export PATH=&quot;\/opt\/homebrew\/opt\/ruby\/bin:$PATH&quot;&#039; &gt;&gt; ~\/.zshrc\necho &#039;export LDFLAGS=&quot;-L\/opt\/homebrew\/opt\/ruby\/lib&quot;&#039; &gt;&gt; ~\/.zshrc\necho &#039;export CPPFLAGS=&quot;-I\/opt\/homebrew\/opt\/ruby\/include&quot;&#039; &gt;&gt; ~\/.zshrc\nsource ~\/.zshrc\n\n<\/pre><\/div>\n\n\n<p><strong>Intel Mac<\/strong><br>\u8def\u5f84\u4f1a\u662f <code>\/usr\/local\/opt\/ruby\/bin<\/code><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">3\ufe0f\u20e3 \u786e\u8ba4 Ruby \u7248\u672c\u53d8\u6210 3.x<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nruby -v\n\n<\/pre><\/div>\n\n\n<p>\u5982\u679c\u4f9d\u7136\u663e\u793a <code>2.x<\/code> \u2192 PATH \u6ca1\u914d\u597d\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">4\ufe0f\u20e3 \u4f7f\u7528 Homebrew Ruby \u5b89\u88c5 CocoaPods<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ngem install cocoapods\n\n<\/pre><\/div>\n\n\n<p>\u5982\u7f51\u7edc\u95ee\u9898\uff0c\u53ef\u4ee5\u52a0\u56fd\u5185\u6e90\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ngem sources --add https:\/\/gems.ruby-china.com\/ --remove https:\/\/rubygems.org\/\ngem install cocoapods\n\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\u26a0\ufe0f \u5e38\u89c1\u9519\u8bef &amp; \u89e3\u51b3<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">\u274c \u201cError: ruby not found\u201d \u6216 ruby \u7248\u672c\u4f9d\u7136\u662f 2.x<\/h2>\n\n\n\n<p>\u8bf4\u660e PATH \u4e0d\u751f\u6548<br>\u2192 <strong>\u91cd\u65b0\u68c0\u67e5 Homebrew \u5b89\u88c5\u8def\u5f84<\/strong><\/p>\n\n\n\n<p>\u67e5\u770b brew Ruby \u5b89\u88c5\u4f4d\u7f6e\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nbrew --prefix ruby\n\n<\/pre><\/div>\n\n\n<p>\u7136\u540e\u628a\u5b83\u52a0\u5165 PATH\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\necho &#039;export PATH=&quot;$(brew --prefix ruby)\/bin:$PATH&quot;&#039; &gt;&gt; ~\/.zshrc\nsource ~\/.zshrc\n\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u274c \u201cffi \u7f16\u8bd1\u5931\u8d25\u201d \/ \u201copenssl \u4f9d\u8d56\u7f3a\u5931\u201d<\/h2>\n\n\n\n<p>\u6267\u884c\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nbrew install openssl\nbrew install libffi\n\n<\/pre><\/div>\n\n\n<p>\u7136\u540e\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ngem install cocoapods -- --use-system-libraries\n\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u274c &#8220;Permission denied @ dir_s_mkdir&#8221;\uff08\u6743\u9650\u9519\u8bef\uff09<\/h2>\n\n\n\n<p>\u4f7f\u7528 sudo \u4f1a\u7834\u574f Ruby \u73af\u5883\uff0c<strong>\u4e0d\u8981 sudo gem install<\/strong>\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u4f60\u5df2\u7ecf\u7528\u8fc7 sudo\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo gem uninstall cocoapods\nsudo chown -R $(whoami) \/Library\/Ruby\n\n<\/pre><\/div>\n\n\n<p>\u7136\u540e\u91cd\u65b0\u7528 brew Ruby \u5b89\u88c5\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83d\ude80 \u66f4\u9ad8\u7ea7\u65b9\u6848\uff08\u53ef\u9009\uff09<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">\u65b9\u6848 B\uff1a\u4f7f\u7528 <code>rbenv<\/code> \u7ba1\u7406\u591a\u4e2a Ruby \u7248\u672c<\/h2>\n\n\n\n<p>\u5982\u679c\u4f60\u8fd8\u505a\u5176\u4ed6 Ruby \u5f00\u53d1\uff0c\u53ef\u4ee5\u7528\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nbrew install rbenv ruby-build\nrbenv install 3.3.0\nrbenv global 3.3.0\n\n<\/pre><\/div>\n\n\n<p>\u4e4b\u540e\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ngem install cocoapods\n\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83c\udf89 \u6700\u7ec8\u5b8c\u6574\u547d\u4ee4\uff08\u4f60\u53ef\u4ee5\u590d\u5236\u4e00\u5957\u8dd1\u5b8c\uff09<\/h1>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nbrew install ruby\necho &#039;export PATH=&quot;\/opt\/homebrew\/opt\/ruby\/bin:$PATH&quot;&#039; &gt;&gt; ~\/.zshrc\necho &#039;export LDFLAGS=&quot;-L\/opt\/homebrew\/opt\/ruby\/lib&quot;&#039; &gt;&gt; ~\/.zshrc\necho &#039;export CPPFLAGS=&quot;-I\/opt\/homebrew\/opt\/ruby\/include&quot;&#039; &gt;&gt; ~\/.zshrc\nsource ~\/.zshrc\n\ngem sources --add https:\/\/gems.ruby-china.com\/ --remove https:\/\/rubygems.org\/\ngem install cocoapods\n\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>\u4e0b\u9762\u7ed9\u4f60\u4e00\u4efd Mac \u65b0\u7535\u8111\u5b89\u88c5 CocoaPods \u62a5 Ruby \u7248\u672c\u8fc7\u4f4e \u7684&#8230; <a class=\"more-link\" href=\"https:\/\/www.52runoob.com\/index.php\/2025\/11\/25\/mac-%e6%96%b0%e7%94%b5%e8%84%91%e5%ae%89%e8%a3%85cocoapods%e6%8a%a5%e9%94%99ruby%e7%89%88%e6%9c%ac%e8%bf%87%e4%bd%8e\/\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-218","post","type-post","status-publish","format-standard","hentry","category-ruby"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/218","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/comments?post=218"}],"version-history":[{"count":1,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/218\/revisions"}],"predecessor-version":[{"id":219,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/218\/revisions\/219"}],"wp:attachment":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/media?parent=218"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/categories?post=218"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/tags?post=218"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}