Unable to add a source with url https://github.com/CocoaPods/Specs.git
named cocoapods
.
Error scenarios
The following error occurred while downloading a dependency using Pod Install
Cloning spec repo `cocoapods` from `https://github.com/CocoaPods/Specs.git` [!] Unable to add asource with url `https://github.com/CocoaPods/Specs.git` named `cocoapods`.
You can try adding it manually in `/Users/ado/.cocoapods/repos` or via `pod repo add`.
Copy the code
The solution
This is because cocoapods source code on Github, sometimes domestic access is not very stable, so we can use domestic mirror source to solve. The mirror image of Tsinghua University is used below
$ cd ~/.cocoapods/repos
$ pod repo remove master
$ git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git master
Copy the code
Then replace the first line of your project’s podfile with the following code
source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'
Copy the code
Finally, use POD Install. Reference: Tsinghua University CoocoaPods mirror
Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers
Error scenarios
The following error appears when you install cocoapods using the gem install cocoapods.
ERROR: Error installing cocoapods: ERROR: Failed to build gem native extension. current directory: / Library/Ruby/Gems/server/Gems/ffi - 1.15.3 / ext/ffi_c/System/Library/Frameworks/Ruby framework Versions / 2.6 / usr/bin/Ruby - I/System/Library/Frameworks/Ruby framework Versions / 2.6 / usr/lib/Ruby/server - r. / siteconf20210711-1964 - ncgneq. Rb extconf.rb checkingfor ffi.h... *** 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
--without-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 = / System/Library/Frameworks/ruby framework Versions / / usr/bin / $2.6 (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/System/Library/Frameworks/Ruby framework Versions / 2.6 / usr/lib/Ruby/server/MKMF rb: 467:in `try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from / System/Library/Frameworks/Ruby framework Versions / 2.6 / usr/lib/Ruby/server/MKMF rb: 585: in ` block in try_compile 'The from/System/Library/Frameworks/Ruby framework Versions / 2.6 / usr/lib/Ruby/server/MKMF rb: 534:in `with_werror'the from/System/Library/Frameworks/Ruby framework Versions / 2.6 / usr/lib/Ruby/server/MKMF rb: 585: in ` try_compile'The from/System/Library/Frameworks/Ruby framework Versions / 2.6 / usr/lib/Ruby/server/MKMF rb: 1109:in `block in have_header'the from/System/Library/Frameworks/Ruby framework Versions / 2.6 / usr/lib/Ruby/server/MKMF rb: 959: in ` block in checking_for'The from/System/Library/Frameworks/Ruby framework Versions / 2.6 / usr/lib/Ruby/server/MKMF rb: 361:in `block (2 levels) in postpone'the from/System/Library/Frameworks/Ruby framework Versions / 2.6 / usr/lib/Ruby/server/MKMF rb: 331: in ` open'The from/System/Library/Frameworks/Ruby framework Versions / 2.6 / usr/lib/Ruby/server/MKMF rb: 361:in `block in postpone'the from/System/Library/Frameworks/Ruby framework Versions / 2.6 / usr/lib/Ruby/server/MKMF rb: 331: in ` open'The from/System/Library/Frameworks/Ruby framework Versions / 2.6 / usr/lib/Ruby/server/MKMF rb: 357:in `postpone'the from/System/Library/Frameworks/Ruby framework Versions / 2.6 / usr/lib/Ruby/server/MKMF rb: 958: in ` checking_for'The from/System/Library/Frameworks/Ruby framework Versions / 2.6 / usr/lib/Ruby/server/MKMF rb: 1108:in `have_header'
from extconf.rb:10: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: / Library/Ruby/Gems/server/extensions/universal - Darwin - 19 / server/ffi - 1.15.3 / MKMF log extconf failed, The exit code 1 Gem files will remain installed in/Library/Ruby/Gems/server/Gems/ffi - 1.15.3 for inspection. The Results logged To/Library/Ruby/Gems/server/extensions/universal - Darwin - 19 / server/ffi - 1.15.3 / gem_make. OutCopy the code
The solution
After searching online, it is found that many directory structures have changed since 10.15, which may cause some development libraries to be unable to find the header file. MacOS_SDK_headers_for_macOS is not available after 10.15. So here we do not use the system built-in Ruby to install cocoapods. Use RVM to install the new version of Ruby, and then install Cocoapods.
Install RVM
# installation
curl -sSL https://get.rvm.io | bash -s stable
# Refresh environment
source ~/.bash_profile
Copy the code
Query the RVM version to check whether the RVM is successfully installed
rvm -v
Copy the code
Install ruby
RVM install 2.7.4Copy the code
Check whether Ruby is installed successfully
ruby -v
If the version number appears below #, it means success
Copy the code
Install cocoapods
If you want to specify the installation version, add the -v version number at the end
sudo gem install -n /usr/local/ bin cocoapods -v 1.9.4Copy the code
Verify that the installation is successful
pod --version
# Version number indicates success
Copy the code
requirements_osx_brew_libs_install
Error scenarios
The following error occurred while installing Ruby using RVM
Error running 'requirements_osx_brew_libs_install autoconf automake libtool pkg-config coreutils libyaml libksba readline zlib [email protected] ',
please read /Users/ado/.rvm/log/ 1626011972 _ruby - 2.7.1 / package_install_autoconf_automake_libtool_pkg - config_coreutils_libyaml_libksba_readline_zlib_open [email protected] Requirements installation failed with status: 1.Copy the code
The solution
Open the above error log file, found that homebrew over the problem. So just change the homebrew source to a domestic mirror source. Here we use the mirror image of USTC
Replace the git
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
Copy the code
Replace the core
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
Copy the code
Replace the Bottles
ZSH # bash = ZSH # bash = ZSH # bash = ZSH HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' > > ~ /. Following the source ~ /. Following the way # ZSH echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc source ~/.zshrcCopy the code
Finally, use the RVM install version number to install Ruby normally.