Tag Archives: ios development

[Solved] Mac homebrew error: Error: homebrew-core is a shallow clone.

Mac command line execution:

brew update 

The following error is reported:

Error: 
  homebrew-core is a shallow clone.
To `brew update`, first run:
  git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
This command may take a few minutes to run due to the large size of the repository.
This restriction has been made on GitHub's request because updating shallow
clones is an extremely expensive operation due to the tree layout and traffic of
Homebrew/homebrew-core and Homebrew/homebrew-cask. We don't do this for you
automatically to avoid repeatedly performing an expensive unshallow operation in
CI systems (which should instead be fixed to not use shallow clones). Sorry for
the inconvenience!

The cause of this problem is usually the problem caused by the system update.

Solution: delete the homebrew core and then update it

cd /usr/local/Homebrew/Library/Taps/homebrew
rm -rf homebrew-core
brew upgrade

Cocoapods Install ERROR: Error installing cocoapods: ERROR: Failed to build gem native extension.

Cocoapods installation failed

Complete error message trying to install my problem

Using alamofire needs to be based on cocoapods, but there are many problems in the process of trying to install cocoapods. It has failed for a long time. Finally, the installation is successful only after the on-demand broadcast of the leaders in the group. In fact, sometimes the solution to the problem is very simple. I hope this blog can help you.

Complete error reporting

yusael@air ~ % sudo gem install -n /usr/local/bin cocoapods
Fetching cocoapods-trunk-1.6.0.gem
Fetching cocoapods-search-1.0.1.gem
Fetching cocoapods-plugins-1.0.0.gem
Fetching cocoapods-try-1.2.0.gem
Fetching cocoapods-downloader-1.5.1.gem
Fetching cocoapods-deintegrate-1.0.5.gem
Successfully installed cocoapods-try-1.2.0
Successfully installed cocoapods-trunk-1.6.0
Successfully installed cocoapods-search-1.0.1
Successfully installed cocoapods-plugins-1.0.0
Successfully installed cocoapods-downloader-1.5.1
Successfully installed cocoapods-deintegrate-1.0.5
Building native extensions. This could take a while...
ERROR:  Error installing cocoapods:
	ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.4/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /Library/Ruby/Site/2.6.0 -r ./siteconf20211110-79554-472vcj.rb extconf.rb
checking for 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/2.6/usr/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
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/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/2.6.0/mkmf.rb:585:in `block in try_compile'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:534:in `with_werror'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:585:in `try_compile'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1109:in `block in have_header'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:959:in `block in checking_for'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in `block (2 levels) in postpone'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in `open'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in `block in postpone'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in `open'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:357:in `postpone'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:958:in `checking_for'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/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/2.6.0/extensions/universal-darwin-20/2.6.0/ffi-1.15.4/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.4 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-20/2.6.0/ffi-1.15.4/gem_make.out

Try to install

Steps: first install homebrew, then update ruby, and then install cocoapods

Note: many online blogs require the installation of RVM, in fact, RVM does not have to be </ font>, but is just a way to update ruby

The blog of the boss is directly quoted here. The reference is as follows:

    1. Mac OS system install homebrew Mac OS system update Ruby Mac OS system restart cocoapods

My question

Generally speaking, the installation can be basically completed according to the above process. Here is my problem. My problem is that the version of ruby is too low. Before successful installation, my version is 2.6.3p62. I will update the ruby version to 3.0.2_ After 1, execute: sudo gem install - N/usr/local/bin cocoapods and the installation is successful!

The main problem here is that the latest ruby is updated through homebrew, but it is not necessarily the latest, so the installation fails.

(in fact, in the article of the boss cited above, it is written to configure the latest Ruby environment variables, but I didn’t read it carefully at the beginning)

Here are two ways to configure Ruby environment variables:

Method 1:

echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc

Method 2:

echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile

Check whether the ruby version is updated through Ruby - V and try to install it later

Error: RPC failed; HTTP 504 curl 22 the requested URL returned error: 504 gateway time out

The following error is reported when using git clone Code:

Cloning into ‘FanHeIOSV2’…

error: RPC failed; HTTP 504 curl 22 The requested URL returned error: 504 Gateway Time-out

fatal: The remote end hung up unexpectedly

The solution is to add — depath = 1:1

git clone –depth=1 https://git.oschina.net/xxxxxx.git  

Command CompileSwift failed with a nonzero exit code

recently when I was doing ios development I had this problem:

Command CompileSwift failed with a nonzero exit code

the key is that there is no error in the code, and then the project will run normally, so why would there be such a strange error in the compilation?A random Internet search, said to change the contents of the PodFile, I am a small new, do not dare to change the podFile thing, in case something new problem. After a few final searches, you can simply press the following shortcut combination:

shift + commond + k

The

command is available as clean build folder, which is also available on the xcode toolbar product. After analysis, this error should be caused by the compilation cache of Xcode, but there is no problem with the project code itself and it can run normally. As long as the previous compilation cache is cleared, it will be ok to recompile and run.

problem solved!