Не удается установить cocoapods в macOS

#ruby #rubygems #cocoapods #homebrew

Вопрос:

sudo gem install cocoapods

дает:

 Building native extensions. This could take a while...
ERROR:  Error installing cocoapods:
    ERROR: Failed to build gem native extension.

    current directory: /usr/local/lib/ruby/gems/3.0.0/gems/ffi-1.15.1/ext/ffi_c
/usr/local/opt/ruby/bin/ruby -I /usr/local/Cellar/ruby/3.0.1/lib/ruby/3.0.0 -r ./siteconf20210523-1321-ljqyqc.rb extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/local/Cellar/ruby/3.0.1/bin/$(RUBY_BASE_NAME)
    --with-ffi_c-dir
    --without-ffi_c-dir
    --with-ffi_c-include
    --without-ffi_c-include=${ffi_c-dir}/include
    --with-ffi_c-lib
    --without-ffi_c-lib=${ffi_c-dir}/lib
    --enable-system-libffi
    --disable-system-libffi
    --with-libffi-config
    --without-libffi-config
    --with-pkg-config
    --without-pkg-config
/usr/local/Cellar/ruby/3.0.1/lib/ruby/3.0.0/mkmf.rb:471:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /usr/local/Cellar/ruby/3.0.1/lib/ruby/3.0.0/mkmf.rb:564:in `try_link0'
    from /usr/local/Cellar/ruby/3.0.1/lib/ruby/3.0.0/mkmf.rb:582:in `try_link'
    from /usr/local/Cellar/ruby/3.0.1/lib/ruby/3.0.0/mkmf.rb:684:in `try_ldflags'
    from /usr/local/Cellar/ruby/3.0.1/lib/ruby/3.0.0/mkmf.rb:1851:in `pkg_config'
    from extconf.rb:9:in `system_libffi_usable?'
    from extconf.rb:42:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /usr/local/lib/ruby/gems/3.0.0/extensions/x86_64-darwin-20/3.0.0/ffi-1.15.1/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /usr/local/lib/ruby/gems/3.0.0/gems/ffi-1.15.1 for inspection.
Results logged to /usr/local/lib/ruby/gems/3.0.0/extensions/x86_64-darwin-20/3.0.0/ffi-1.15.1/gem_make.out
 

Ответ №1:

Пожалуйста, откройте настройки в Xcode и выберите инструменты командной строки.

введите описание изображения здесь