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

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

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

Okay