DEV Community

Thiago Massari Guedes
Thiago Massari Guedes

Posted on

Using flutter with native resources on apple silicon processors

If you are building a flutter application for apple processors using Silicon processors (M1+) and dealing with native packages for things such as playing a sound, you maybe encountered this error:

Error output from CocoaPods:
↳
    /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file --
    ffi_c (LoadError)
        from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /Library/Ruby/Gems/2.6.0/gems/ffi-1.17.0-x86_64-darwin/lib/ffi.rb:5:in `rescue in <top (required)>'
        from /Library/Ruby/Gems/2.6.0/gems/ffi-1.17.0-x86_64-darwin/lib/ffi.rb:2:in `<top (required)>'
        from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
...

Error: To set up CocoaPods for ARM macOS, run:
  sudo gem uninstall ffi && sudo gem install ffi -- --enable-libffi-alloc
Enter fullscreen mode Exit fullscreen mode

You probably realised that running sudo gem uninstall ffi && sudo gem install ffi -- --enable-libffi-alloc will not work. You are going to get the same error.

The solution I found was to use cocoapods from brew.

For that, run:

sudo gem uninstall cocoapods
brew install cocoapods
brew link cocoapods
Enter fullscreen mode Exit fullscreen mode

Last thing, as I am quite new to flutter and some of the Apple ecosystem, if anyone has a better suggestion, I am all ears.

Link to the author blog: Using flutter with native resources on apple silicon processors

Sentry blog image

The countdown to March 31 is on.

Make the switch from app center suck less with Sentry.

Read more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay