erorr when run flutter code on ios emulator

Viewed 34

I have problem when run code on IOS Emulator and I didn't know how to solve it, and this problem comes after add shared preferences package

Launching lib/main.dart on iPhone 13 in debug mode...
    Running pod install...
    CocoaPods' output:
    ↳
          Preparing
    
        Analyzing dependencies
    
        Inspecting targets to integrate
          Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)
    
        Fetching external sources
        -> Fetching podspec for `Flutter` from `Flutter`
        -> Fetching podspec for `shared_preferences_ios` from `.symlinks/plugins/shared_preferences_ios/ios`
    
        Resolving dependencies of `Podfile`
    
    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': dlopen(/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle, 0x0009): tried: '/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e))) - /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle (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/cocoapods-1.11.3/lib/cocoapods/command.rb:52:in `run'
            from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/bin/pod:55:in `<top (required)>'
            from /usr/local/bin/pod:23:in `load'
            from /usr/local/bin/pod:23:in `<main>'
    
    Error: To set up CocoaPods for ARM macOS, run:
      arch -x86_64 sudo gem install ffi
    
    Error running pod install
    Error launching application on iPhone 13.
1 Answers

Apparently you have an M1 Mac. You can either use Rosetta (https://support.apple.com/en-us/HT211861) to launch your terminal and run

sudo gem install ffi

or use the non-rosetta terminal and HomeBrew to install cocoapods using

brew install libffi

brew install cocoapods

Related