66

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

mokagio
  • 16,391
  • 3
  • 51
  • 58
Ahmed Hnewa
  • 1,185
  • 1
  • 4
  • 14
  • Duplicate of https://stackoverflow.com/questions/75574268/missing-file-libarclite-iphoneos-a-xcode-14-3 – Paul Beusterien Apr 03 '23 at 23:53
  • Here you can find the best approach to fix this issue: https://stackoverflow.com/a/75924853/7048924 – Edimar Martins Apr 05 '23 at 12:50
  • 2
    This issue should now be fixed in `Flutter 3.7.10`: https://github.com/flutter/flutter/wiki/Hotfixes-to-the-Stable-Channel#3710-apr-05-2023 – Clifton Labrum Apr 06 '23 at 04:44
  • 3
    I am the Flutter maintainer who fixed both of the issues that are being confused in these SO answers, both caused by changes of behavior in Xcode 14.3. The originally reported missing `libarclite_iphoneos` was fixed in Flutter 3.7.11 https://github.com/flutter/flutter/issues/124340. The other unrelated issue is the failure to archive, which was tracked in https://github.com/flutter/flutter/issues/123890 and fixed in Flutter 3.7.10. In either case, remove any changes you've made to your Podfile and run `flutter upgrade`. – Jenn Apr 12 '23 at 21:55
  • So why not close it @PaulBeusterien? – miken32 May 13 '23 at 18:30
  • Does this answer your question? [Missing file libarclite\_iphoneos.a (Xcode 14.3)](https://stackoverflow.com/questions/75574268/missing-file-libarclite-iphoneos-a-xcode-14-3) – miken32 May 13 '23 at 18:31

19 Answers19

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

Damia Fuentes
  • 5,308
  • 6
  • 33
  • 65
J. Taiga
  • 605
  • 1
  • 4
  • 8
  • 5
    I will try, but can you please explain what's happening here in details? Thank you for your time – Ahmed Hnewa Mar 31 '23 at 16:40
  • 3
    it solves compile issue (we using 11.0 as it's our minimum requirement) , build but then fails on archive with ```ios/../../../IntermediateBuildFilesPath/UninstalledProducts/iphoneos/openssl_grpc.f ramework" failed: No such file or directory (2)``` – Romk1n Mar 31 '23 at 18:46
  • Why this wax not issue on Xcode 14.3? – Ahmed Hnewa Mar 31 '23 at 19:03
  • 5
    I tried this and it works, but I'm not sure if this is a good solution, I'm not a native ios developer, and I'm only familiar with flutter and native android, so can you explain to us what is going on? what is the problem, why is it happening, and how did you solve it? thank you very much for your time – Ahmed Hnewa Mar 31 '23 at 19:51
  • 1
    Change 13.0 with the version you have at the top of the file. For instance, for me it was 13.7. – Damia Fuentes Apr 06 '23 at 00:43
  • I am the Flutter maintainer who fixed this issue. Please do not edit your Podfile as described in this answer. Instead, please run `flutter upgrade` to get the workaround to the Xcode 14.3 behavior change in Flutter 3.7.11 https://github.com/flutter/flutter/issues/124340. – Jenn Apr 12 '23 at 21:57
26

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|
    target.build_configurations.each do |config|
      if Gem::Version.new(config.build_settings['IPHONEOS_DEPLOYMENT_TARGET']) < Gem::Version.new('11.0')
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
      end
    end
    flutter_additional_ios_build_settings(target)
  end
end

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

Edit 3:

The issue come back again in the flutter 3.10 with some packages, so please use the way I show bellow

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

Ahmed Hnewa
  • 1,185
  • 1
  • 4
  • 14
  • This Xcode 14.3 behavior changes was worked around in Flutter 3.7.11, not 3.7.10 https://github.com/flutter/flutter/issues/124340. – Jenn Apr 12 '23 at 21:59
  • 2
    Thanks for this - I just want to add that I did a flutter upgrade then an arch -x86_64 pod install (on M1) and that's all that was needed as of April 17 2023 – jwehrle Apr 18 '23 at 03:07
20

Update: 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

Mashood .H
  • 926
  • 6
  • 16
  • 3
    This change will work temporarily, but will be overwritten the next time `pod install` is called by the Flutter tooling (if you run `flutter clean`, add a new plugin to your pubspec, etc). Instead of manually updating, run `flutter upgrade` to get the Xcode 14.3 behavior change workaround in Flutter 3.7.11 https://github.com/flutter/flutter/issues/124340. – Jenn Apr 12 '23 at 22:04
  • 1
    I have a problem in 3.10.0 and this works – ishak May 16 '23 at 13:21
  • Didn't work for me in Flutter 3.10.0 but It seems that issue was fixed in Flutter 3.10.1, at least for me! https://github.com/flutter/flutter/issues/124529 – pbertsch May 18 '23 at 02:28
  • yeah I've mentioned that at the top of the answer it's resolve in newer versions – Mashood .H May 18 '23 at 23:29
7

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.

  • I updated my testing iPhone to 16.4 and it's not compatible with Xcode 14.2 – Ahmed Hnewa Mar 31 '23 at 19:43
  • 2
    hello, could you tell please in more detail what exactly it means replacing source="$(readlink "${source}")" with source="$(readlink -f "${source}")" where to change it and how ? and how can it be done? – songhee24 Apr 03 '23 at 08:29
  • @songhee24 in your project go to Pods -> Targets Support Files -> Pods-YourApp -> Pods-YourApp-frameworks in that file search and replace like OP says – Pasosta Apr 04 '23 at 18:08
  • 1
    Issues archiving the app are unrelated to the original `libarclite_iphoneos` (which should be fixed with 3.7.11). This was due to an 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. – Jenn Apr 12 '23 at 22:02
6

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.

Jenn
  • 3,143
  • 1
  • 24
  • 28
3

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)

  • 2
    I am the Flutter maintainer who fixed this issue. Please do not edit your Podfile as described in this answer. Instead, please run `flutter upgrade` to get the workaround to the Xcode 14.3 behavior change in Flutter 3.7.11 https://github.com/flutter/flutter/issues/124340. – Jenn Apr 12 '23 at 22:07
  • Hey, I'm agree, BUT I have updated to flutter 3.7.12 and the issue does not get solved for me. – Robert Apikyan Apr 30 '23 at 16:47
2

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

Bandish Kumar
  • 1,557
  • 1
  • 9
  • 13
2
cd /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/

sudo mkdir arc
cd  arc
sudo git clone https://github.com/kamyarelyasi/Libarclite-Files.git .

sudo chmod +x *

It's worked for me.

1

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

emnzava
  • 67
  • 5
  • Hi, can you please explain what does this change do in term for any flutter developer can understand? why the issue happen anyway, we are here to understand what are we doing and not just solve issues and get it work, thank you for your time. – Ahmed Hnewa Apr 04 '23 at 00:54
1

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
1

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

karhoong
  • 11
  • 1
1

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.

talhagg
  • 21
  • 1
1

For cordova projects add following line in config.xml under platform ios

<platform name="ios">
<preference name="deployment-target" value="11.0" />
</platform>
Ali Exalter
  • 420
  • 2
  • 8
  • 13
1

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.

Milan Agarwal
  • 427
  • 2
  • 15
0

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.

Siyu
  • 11,187
  • 4
  • 43
  • 55
  • There is no RECOMMENDED_MACOSX_DEPLOYMENT_TARGET in ios project, only on mac os project, so do you suggest to manually upgrade it? like 13 or 14? because I did for the pod file and project and runner target to 14 and I still get the exists same error – Ahmed Hnewa Apr 02 '23 at 00:26
  • @AhmedHnewa For iOS you'll need its iOS counterpart, `RECOMMENDED_IOS_DEPLOYMENT_TARGET` or manually set it to its equivalent value. Check your pod file as well as the project configuration in Xcode – Siyu Apr 02 '23 at 16:51
  • 1
    @Siyu can you give more info on what you did to get this working for macOS, I am running into this issue currently and this is the only reference to it I can find. – Jonas Smith Apr 03 '23 at 18:49
  • 1
    @JonasSmith Change the deployment target to `RECOMMENDED_MACOSX_DEPLOYMENT_TARGET` in the project settings for all your build targets. If you use a package manager, you may need to change the corresponding settings there as well. – Siyu Apr 04 '23 at 19:49
0

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\'')
...
Chris
  • 19
  • 5
  • Thank you but can you explain what you did with this change? – Ahmed Hnewa Apr 03 '23 at 15:59
  • No problem, look for this line in your podfile `post_install do |installer| `. Under that add what I put above. And replace `IPHONEOS_DEPLOYMENT_TARGET` with the required version. e.g. 13.0 – Chris Apr 04 '23 at 16:19
  • You're ensuring all your pods are set to 14.0 and then adding in the recommended workaround as CocoaPods has a bug at the moment. – Chris Apr 04 '23 at 16:21
0

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
0

I found this solution on Apple Developer Forum, it seems to be related to the new XCode version (14.3) that use the relative path for framework's Pods.

(in my case APPNAME is RUNNER)

Find the Pods-APPNAME-frameworks.sh file in ios/Pods/Target Support Files/Pods-APPNAME/Pods-APPNAME-frameworks.sh:

Replace:

if [ -L "${source}" ]; then
  echo "Symlinked..."
  source="$(readlink "${source}")"
fi

with:

  if [ -L "${source}" ]; then
    echo "Symlinked..."
    source="$(readlink -f "${source}")"
  fi

Note that -f was added.

b00leant
  • 116
  • 1
  • 8
0
post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
    end
  end
end

Just update the development target for all integrated pods > run pod install > rerun the project

Phan Kiet
  • 91
  • 1
  • 3