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 Visual Studio App Center’s retiring

But sadly….you’re not. See how to make the switch to Sentry for all your crash reporting needs.

Read more

Top comments (0)

Sentry mobile image

Improving mobile performance, from slow screens to app start time

Based on our experience working with thousands of mobile developer teams, we developed a mobile monitoring maturity curve.

Read more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay