After trying to build a mobile application built with CapacitorJS in Mac, I received the following exception when installing dependencies:
LoadError - dlsym(0x7f9c88e27480, Init_ffi_c): symbol not found -
/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.3/lib/ffi_c.bundle
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in
`require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in
`require'
/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.3/lib/ffi.rb:5:in `rescue in <top (required)>'
/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.3/lib/ffi.rb:2:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in
`require'
This exception is thrown specifically on ARM based Macs (M1 Sillicon) when running arch -x86_64 pod install
. The solution to remove this exception from your project is to simply install the FFI gem with the following command:
arch -x86_64 sudo gem install ffi
The Ruby-FFI is a gem for programmatically loading dynamically-linked native libraries, binding functions within them, and calling those functions from Ruby code. After running the command of installation of this gem you will receive and output similar to the following one:
Building native extensions. This could take a while...
Successfully installed ffi-1.15.3
Parsing documentation for ffi-1.15.3
Done installing documentation for ffi after 3 seconds
1 gem installed
Then you should be able to work as usual in your project without this exception.
Happy coding ❤️!