Search code examples
iosflutterxcodexcode14flutter-ios-build

Missing file `libarclite_iphoneos.a` in Xcode 14.3 after update flutter and Xcode


I have flutter project, I'm trying to run the iOS version but I get error after I update flutter and Xcode to the latest version, I use firebase core plugin

error:

Could not build the precompiled application for the device.
Error (Xcode): File not found: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphoneos.a

Error (Xcode): Linker command failed with exit code 1 (use -v to see invocation)

Podfile:

# Uncomment this line to define a global platform for your project
# platform :ios, '12.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

I also tried to all installed pods by:

pod deintegrate
rm Podfile.lock
rm -rf Pods

and then update the repositories and install the pods and I still get the same error, should I reninstall xcode?

Flutter packages:

firebase_core: ^2.8.0
firebase_crashlytics: ^3.0.17
firebase_analytics: ^10.1.6
firebase_messaging: ^14.3.0

Any workaround for this? and thank you for your time


Solution

  • New answer (Edit 4)

    if you upgrade your Flutter and cocoa pods and Flutter plugins and still have this issue, A really simple and efficient solution is to edit your Podfile

     platform :ios, '14.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__))
      target 'RunnerTests' do
        inherit! :search_paths
      end
    end
    
    #post_install do |installer|
    #  installer.pods_project.targets.each do |target|
    #    flutter_additional_ios_build_settings(target)
    #  end
    #end
    
    post_install do |installer|
      installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
          if Gem::Version.new(config.build_settings['IPHONEOS_DEPLOYMENT_TARGET']) < Gem::Version.new('13.0')
            config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
          end
        end
        flutter_additional_ios_build_settings(target)
      end
    end
    

    The changes that I made, is to define the platform ios version as a minimum of 14, and make sure all the pods have at least 13 minimum version, otherwise ignore it, the changes are to the second line and the post_install at the very end

    Old answer (Edit 1, 2 and 3)

    I fixed the issue, even though I'm not sure if that is a good solution, run the following:

    flutter clean
    flutter pub get
    cd ios/
    pod deintegrate
    pod install
    pod repo update
    pod install (again)
    

    Just open the ios project inside the flutter project in Xcode, go to Pods in the folders (files) tab, go to the targets, go to the targets (it pod I guess, one dependency) that causes the issue, in my case FMDB and App auth, upgrade the minimum deployments for both from the current version (in my case 9.0) to 13.0 and try run the app again by build it and run it in Xcode or using flutter run with the selected ios device, and the issue should be gone

    however sometimes when you clean the project in flutter (using flutter clean), it will reset those changes, or when you delete the pods and deintegrate Cocapods and re-install the app, all the changes will be reverted back to the default, it not really an efficient solution, but at least you can run the app

    and if the issue is still exists, update the minimum deployment for the pods target again and run the app using Xcode, if you still have the issue, try out the other answers or you can try update cocapods by

    sudo gem install cocoapods
    

    if your mac machine is apple silicon (m1, m2), you also need run

    sudo gem uninstall ffi && sudo gem install ffi -- --enable-libffi-alloc
    

    The official documentation said that

    Edit: This solution idea come to me, all thanks to @Siyu

    If you are from the future, you might want to try to upgrade the packages and cocapods, flutter etc...

    Edit 2:

    Try updating Flutter since the issue should be fixed in 3.7.11

    flutter upgrade
    

    Edit 3:

    The issue comes back again in the flutter 3.10 with some packages, so please use the way I used or try one of the answers and try to understand it, thank you for your time, Good luck