iosflutterxcodefirebaseabseil

I am getting Xcode abseil undefined symbol error


Flutter iOS Build Issue: Undefined Symbols Error in Xcode

I successfully developed a Flutter app on my Windows PC, where it works perfectly on Android devices. Now, I want to run and compile the app on my Mac. However, when I try to build it using Xcode, I encounter an undefined symbols error.

I’ve researched similar issues on GitHub and Stack Overflow and attempted several fixes, including:

Deleting the Podfile.lock Upgrading the CocoaPods version Setting the iOS deployment target to 13.0 in the Podfile Updating all Flutter dependencies Various other methods (which I may have forgotten to list) Unfortunately, none of these have resolved the problem.

Error Output Here are the error details from Xcode:

[   +6 ms] Error (Xcode): Undefined symbol: absl::lts_20240116::CHexEscape(absl::lts_20240116::string_view)

... (truncated for brevity)
           
[        ] Error (Xcode): Linker command failed with exit code 1 (use -v to see invocation)
[   +4 ms] Could not build the application for the simulator.
[        ] Error launching application on iPhone 13.

Current Podfile Configuration This is my current Podfile:


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__))

  # Add Firebase Pods
  pod 'Firebase/Auth'
  pod 'Firebase/Firestore'
  pod 'Firebase/Analytics'
  pod 'Firebase/Core'
  pod 'Firebase/Storage'

  target 'RunnerTests' do
    inherit! :search_paths
    # Add test dependencies here
  end
end

Additional Information Flutter Version: 3.24.3 Xcode Version: 15.3 CocoaPods Version: 1.16.2 I suspect the issue might be related to Abseil libraries, as many undefined symbols reference absl. Is this related to Firebase dependencies, or could it be a linker configuration issue?

Any insights or suggestions to resolve this would be greatly appreciated! Thank you.


Solution

  • I found the solution of this problem if you getting same problem as me you should add these code lines to your pod file :

     if target.name == 'abseil'
      Pod::UI.puts "Workaround: Configuring abseil to use gnu++14 language standard for cocoapods 1.16+ compatibility".yellow
      Pod::UI.puts "            Remove workaround when upstream issue fixed https://github.com/firebase/firebase-ios-sdk/issues/13996".yellow
      target.build_configurations.each do |config|
        config.build_settings['CLANG_CXX_LANGUAGE_STANDARD'] = 'gnu++14'
      end
    end
    

    I found this solution on GitHub you can go there with this link : Github Link