skip to Main Content

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

16

Answers


  1. Chosen as BEST ANSWER

    Edit 2:

    Try update flutter since the issue should be fixed in 3.7.11

    flutter upgrade
    

    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...


  2. post_install do |installer|
      installer.generated_projects.each do |project|
        project.targets.each do |target|
            target.build_configurations.each do |config|
                config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
             end
        end
    end
      installer.pods_project.targets.each do |target|
        flutter_additional_ios_build_settings(target)
      end
    end
    

    Try updating your ios/Podfile. Change 13.0 with the version you have at the top of the file.

    Login or Signup to reply.
  3. Facing this issue as well and went down the same path.

    1. Upgrading the deployment target to 13.0 unfortunately only solves the issue for the debug version of the app. Then, you will at least be able to run it in the simulator again.

    2. Archiving the app (e.g. build ipa to submit to store) will still fail with Xcode 14.3 for now due CocoaPods (Upgrade from xCode 14.2 to 14.3 PhaseScriptExecution failed with a nonzero exit code).
      Unfortunately, the (only?) solution at the moment seems to be downgrading to 14.2 while waiting for a fix from the CocoaPods side (https://github.com/CocoaPods/CocoaPods/issues/11808#issuecomment-1481244508)

    Update
    The issue seems to have been found and fixed (https://github.com/CocoaPods/CocoaPods/pull/11828), but is not yet merged – Hopefully this will happen soon. In the meantime, replacing source="$(readlink "${source}")" with source="$(readlink -f "${source}")" in the …framework.sh files seems to help.

    Login or Signup to reply.
  4. Providing my share of thoughts.

    I’m building for MacOS and the file Xcode was complaining about is libarclite_macosx. So similar scenario.

    The solution is to change the deployment target to RECOMMENDED_MACOSX_DEPLOYMENT_TARGET, which is currently equivalent to MacOS 10.13 for Xcode 14.3.

    This essentially removes the dependency of that unnecessary file because

    the app’s deployment target is modern enough that it can rely on ARC being built in to the system. Indeed, that’s always the case with Xcode 14, where it’s minimum supported deployment target is iOS 11

    Reference:
    https://developer.apple.com/forums/thread/725300

    For your case, I believe that means update the deployment target within Xcode and podfile.

    Login or Signup to reply.
  5. I fixed this by adding the following to the post_install section of my pod file (replace the deployment target with your required):

    installer.generated_projects.each do |project|
        project.targets.each do |target|
          target.build_configurations.each do |config|
            config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
          end
        end
      end
      # Check out: https://github.com/flutter/flutter/issues/123852
      # Workaround for Xcode 14.3:
      system('sed -i '' '44s/readlink/readlink -f/' 'Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh'')
    ...
    
    Login or Signup to reply.
  6. If you’ve updated to xcode 14.3 and above. Do the following:

    Open file project.pbxproj (ios/Pods/Pods.xcodeproj/project.pbxproj) and make sure "IPHONEOS_DEPLOYMENT_TARGET" is set to 11.0 or greater.

    To make changes permanent add target deployment in the podfile as follows:-

    platform :ios, '12.0' # set IPHONEOS_DEPLOYMENT_TARGET for the pods project
    post_install do |installer|
      installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
          config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
        end
      end
    end
    

    Then run "flutter pub get".

    You should be good to go.

    Inspired by @dawnsong

    Login or Signup to reply.
  7. Check the iOS Deployment Target for the installed pod, it should be minimum iOS 11.0.

    Pod (select a pod) -> Build Setting -> Deployment -> iOS Deployment target (minimum 11.0) enter image description here

    Login or Signup to reply.
  8. I just had the same issue when updated my Xcode to 14.3

    I have found a quick workaround by updating iOS Deployment Target of my installed pods. I have set iOS Deployment Target to 11 for the pods that are targeted below 11. This works like a charm but if you reinstall your pods you will need to do this change again as pods will be installed by their default deployment targets.

    Then I have placed install script in to my Podfile as below. Then I run pod install command on command line to reflect the changes. Note I set the deployment target 11 first but I got error because some of my pods needs at least 13, so I have changed it to 13 because It will affect all of your pods.

    target 'YourApp' do
      # Comment the next line if you don't want to use dynamic frameworks
      use_frameworks!
    
      # Pods for YourApp
      pod ...
      pod ...
      
      post_install do |installer|
        installer.generated_projects.each do |project|
          project.targets.each do |target|
            target.build_configurations.each do |config|
              config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
            end
          end
        end
      end
      
    end
    
    Login or Signup to reply.
  9. I’m able to build my project into emulator as well as my own device but unable to archive it to push to AppStore. Knowing that this is a bug in Xcode 14.3, and none of the change minimum requirement or other Podfile modification method, I solved it by using 14.2 and ignore 14.3 for the time being

    Having my Xcode installed from AppStore, the slowest method of all, I used a Xcode version manager that I found from here https://betterprogramming.pub/easily-swith-between-xcode-versions-b36f9f685979

    Long story short here are some snippets of the steps I took

    Step 1: Install Xcode manager and install Xcode 14.2 (It’ll ask for your AppleID credentials)

    gem install xcode-install
    xcversion install 14.2
    xcversion select 14.2
    

    Step 2: Open Xcode-14.2.app from your MacOS Applications folder

    Step 3: If your project works in Xcode 14.2 before then hopefully this will fix it

    Login or Signup to reply.
  10. The Issue is resolved in later Flutter versions
    run
    flutter upgrade and re-initializing the dependencies

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

    if it’s not solve the error follow the steps that mentioned bellow

    Make sure you have update the pod files after that follow the steps mentioned below:

    Step 1

    Track the issue cased by library here in my case I got an error for FMDB file enter image description here

    Step 2

    Change the iOS version on effected pod with dropdown menu (small blue arrow)
    enter image description here

    Step 3

    Change Distribution setting on Target Pod enter image description here

    Rebuild your app again on Xcode.
    and repeat the process until you
    solve all library issues

    Login or Signup to reply.
  11. This works:
    https://dev.to/curtlycritchlow/how-to-fix-missing-file-libarcliteiphonesosaxcode-143-4hki

    which will need to be done each time after you run pod install

    or you can simply add this at the end of Podfile

    post_install do |installer|
        installer.pods_project.targets.each do |target|
          target.build_configurations.each do |config|
            config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
            config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
            config.build_settings['ENABLE_BITCODE'] = 'NO'
          end
        end
      end
    
    Login or Signup to reply.
  12. As I’ve seen the problem was coming from Flutter’s plugins deployment target that is still at 8.0, which is solved by manually updating it to a higher version with Xcode, in case you want to make it automatically, you can put these codes inside ios/Podfile at post_install

      installer.generated_projects.each do |project|
        project.targets.each do |target|
          target.build_configurations.each do |config|
            if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] == '8.0'
              config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
            end
          end
        end
      end
    

    so it will look like this

    post_install do |installer|
      installer.pods_project.targets.each do |target|
        flutter_additional_ios_build_settings(target)
      end
    
      # Here is the code I provide above ==================
      installer.generated_projects.each do |project|
        project.targets.each do |target|
          target.build_configurations.each do |config|
            if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] == '8.0'
              config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
            end
          end
        end
      end
      #Here is the end ===================================
    end
    

    after that run pod install in the ios folder…

    What it does do?
    The code will override every pod’s deployment target that is still at 8.0 into 11.0, by this logic you’ll not bother any plugins that maybe requires a specific deployment target (which is higher than 8.0 for sure)

    Login or Signup to reply.
  13. I had this problem with many of my libraries and I found the solution by changing the minimum deployments of the libraries. I got rid of the build error by updating the minimum deployments from 8.0 to 11.0.

    Login or Signup to reply.
  14. For cordova projects add following line in config.xml under platform ios

    <platform name="ios">
    <preference name="deployment-target" value="11.0" />
    </platform>
    
    Login or Signup to reply.
  15. The originally reported missing libarclite_iphoneos.a compilation failure is caused when when Flutter plugins have a dependency (a CocoaPods pod) with a minimum iOS version < 9.0. It seems Xcode 14.3 removed a library from its toolchain required to build these lower versions. Flutter 3.7.11 has a workaround for both iOS and macOS.
    More details in https://github.com/flutter/flutter/issues/124340.

    The other (unrelated) issue being discussed in these answers is the failure to archive an iOS or macOS app. This was due to a different Xcode 14.3 behavior change that broke a CocoaPods script https://github.com/CocoaPods/CocoaPods/issues/11808. There is a workaround in Flutter tracked in https://github.com/flutter/flutter/issues/123890 and available in Flutter 3.7.10.

    If you are seeing either issue, please run flutter upgrade to get the latest version of Flutter with these fixes. If you are still seeing issues, please file a new GitHub issue and myself or another Flutter maintainer will take a look.

    Login or Signup to reply.
  16. You can follow the below steps to fix this:

    1. Make sure you have flutter version 3.7.10 or above installed on your machine.
    2. For most people only doing the above step and then rebuilding after deleting the podfile, podfile.lock, pods directory, and pubspec.lock file should fix it.
    3. If it still didn’t fixed for you, it could be the reason that you may have some packages with iOS deployment target set to 10 or below. To fix this, go to the bottom of the podfile and replace the below code
    post_install do |installer|
      installer.pods_project.targets.each do |target|
        flutter_additional_ios_build_settings(target)
      end
    end
    

    with code

    post_install do |installer|
      installer.generated_projects.each do |project|
        project.targets.each do |target|
          target.build_configurations.each do |config|
            config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
          end
        end
      end
      installer.pods_project.targets.each do |target|
        flutter_additional_ios_build_settings(target)
      end
    end
    

    and rebuild. This should fix it for sure.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search