Rehmat Singh Gill
Rehmat Singh Gill

Reputation: 609

Error Running Flutter App on iOS after moving to M1 Mac

I recently moved my projects to my M1 MacBook Pro. But I get the following error when running flutter run on iPhone 12 Pro Max Simulator.

    Resolving dependencies of `Podfile`

    ――― MARKDOWN TEMPLATE
    ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

    ### Command

    ```
    /opt/homebrew/Cellar/cocoapods/1.10.1/libexec/bin/pod install --verbose
    ```

    ### Report

    * What did you do?

    * What did you expect to happen?

    * What happened instead?


    ### Stack

    ```
       CocoaPods : 1.10.1
            Ruby : ruby 2.6.3p62 (2019-04-16 revision 67580)
            [universal.x86_64-darwin20]
        RubyGems : 3.0.3
            Host : macOS 11.1 (20C69)
           Xcode : 12.3 (12C33)
             Git : git version 2.24.3 (Apple Git-128)
    Ruby lib dir :
    /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib
    Repositories : 
    ```

    ### Plugins

    ```
    cocoapods-deintegrate : 1.0.4
    cocoapods-plugins     : 1.0.0
    cocoapods-search      : 1.0.0
    cocoapods-trunk       : 1.5.0
    cocoapods-try         : 1.2.0
    ```

    ### Podfile

    ```ruby
    # Uncomment this line to define a global platform for your project
    # platform :ios, '9.0'

    # CocoaPods analytics sends network stats synchronously affecting flutter
    build latency.
    ENV['COCOAPODS_DISABLE_STATS'] = 'true'

    project 'Runner', {
      'Debug' => :debug,
      'Profile' => :release,
      'Release' => :release,
    }

    def flutter_root
      generated_xcode_build_settings_path = File.expand_path(File.join('..',
      'Flutter', 'Generated.xcconfig'), __FILE__)
      unless File.exist?(generated_xcode_build_settings_path)
        raise "#{generated_xcode_build_settings_path} must exist. If you're
        running pod install manually, make sure flutter pub get is executed
        first"
      end

      File.foreach(generated_xcode_build_settings_path) do |line|
        matches = line.match(/FLUTTER_ROOT\=(.*)/)
        return matches[1].strip if matches
      end
      raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}.
      Try deleting Generated.xcconfig, then run flutter pub get"
    end

    require File.expand_path(File.join('packages', 'flutter_tools', 'bin',
    'podhelper'), flutter_root)

    flutter_ios_podfile_setup

    target 'Runner' do
      use_frameworks!
      use_modular_headers!

      flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
    end

    post_install do |installer|
      installer.pods_project.targets.each do |target|
        flutter_additional_ios_build_settings(target)
      end
    end
    ```

    ### Error

    ```
    LoadError - dlsym(0x7f84b630ab40, Init_ffi_c): symbol not found -
    /Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/lib/ffi_c.bundle
    /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/ru
    bygems/core_ext/kernel_require.rb:54:in `require'
    /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/ru
    bygems/core_ext/kernel_require.rb:54:in `require'
    /Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/lib/ffi.rb:6:in `rescue in <top
    (required)>'
    /Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/lib/ffi.rb:3:in `<top (required)>'
    /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/ru
    bygems/core_ext/kernel_require.rb:54:in `require'
    /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/ru
    bygems/core_ext/kernel_require.rb:54:in `require'
    /Library/Ruby/Gems/2.6.0/gems/ethon-0.12.0/lib/ethon.rb:2:in `<top
    (required)>'
    /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/ru
    bygems/core_ext/kernel_require.rb:54:in `require'
    /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/ru
    bygems/core_ext/kernel_require.rb:54:in `require'
    /Library/Ruby/Gems/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus.rb:2:in `<top
    (required)>'
    /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/ru
    bygems/core_ext/kernel_require.rb:54:in `require'
    /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/ru
    bygems/core_ext/kernel_require.rb:54:in `require'
    /opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/coco
    apods/sources_manager.rb:74:in `cdn_url?'
    /opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/coco
    apods/sources_manager.rb:36:in `create_source_with_url'
    /opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/coco
    apods/sources_manager.rb:21:in `find_or_create_source_with_url'
    /opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/coco
    apods/installer/analyzer.rb:178:in `block in sources'
    /opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/coco
    apods/installer/analyzer.rb:177:in `map'
    /opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/coco
    apods/installer/analyzer.rb:177:in `sources'
    /opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/coco
    apods/installer/analyzer.rb:1073:in `block in resolve_dependencies'
    /opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/coco
    apods/user_interface.rb:64:in `section'
    /opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/coco
    apods/installer/analyzer.rb:1072:in `resolve_dependencies'
    /opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/coco
    apods/installer/analyzer.rb:124:in `analyze'
    /opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/coco
    apods/installer.rb:414:in `analyze'
    /opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/coco
    apods/installer.rb:239:in `block in resolve_dependencies'
    /opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/coco
    apods/user_interface.rb:64:in `section'
    /opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/coco
    apods/installer.rb:238:in `resolve_dependencies'
    /opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/coco
    apods/installer.rb:160:in `install!'
    /opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/coco
    apods/command/install.rb:52:in `run'
    /Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in
    `run'
    /opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/coco
    apods/command.rb:52:in `run'
    /opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/bin/pod:
    55:in `<top (required)>'
    /opt/homebrew/Cellar/cocoapods/1.10.1/libexec/bin/pod:23:in `load'
    /opt/homebrew/Cellar/cocoapods/1.10.1/libexec/bin/pod:23:in `<main>'
    ```
    Error output from CocoaPods:
↳

    [!] Automatically assigning platform `iOS` with version `9.0` on target
    `Runner` because no platform was specified. Please specify a platform for
    this target in your Podfile. See
    `https://guides.cocoapods.org/syntax/podfile.html#platform`.

I tried creating a new flutter app and running it and it worked well, but when I added my dependencies to pubspec.yaml it again showed the same error.

My dependency list

Run on MacBook Pro (M1)

Upvotes: 1

Views: 4427

Answers (1)

fartem
fartem

Reputation: 2531

You need to install ffi dependency manually. Here is the same issue on GitHub: https://github.com/flutter/flutter/issues/70796. Also, if you have troubles with build or run you app on M1, visit to Wiki page on GitHub with usage guide and this issue for tracking current support phase for new macs.

Upvotes: 6

Related Questions