Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined symbols "absl::lts_20240116::CHexEscape(absl::lts_20240116::string_view)" #8103

Closed
mikehardy opened this issue Oct 30, 2024 · 4 comments
Labels
blocked: firebase-sdk Pending a confirmed fix landing on the official native sdk's (iOS/Android). impact: build-error Behaviour causing build failure Needs Attention platform: ios plugin: firestore Firebase Cloud Firestore resolution: solution-provided

Comments

@mikehardy
Copy link
Collaborator

mikehardy commented Oct 30, 2024

[Maintainer update]: cocoapods 1.16.2 and xcodeproj 1.27 were released that reverted the breaking change that caused this problem, if you update to these now-current versions everything will work

If you experience an iOS build failure during the link step with a bunch of errors that look like this:

Undefined symbols for architecture arm64
❌ "absl::lts_20240116::CHexEscape(absl::lts_20240116::string_view)", referenced from:

It is not coming from this library, it is upstream issue firebase/firebase-ios-sdk#13996

It is related to an interaction between cocoapods 1.16+ and the abseil library from firebase-ios-sdk.

You can either:

1- downgrade your ruby gems to cocoapods 1.15.2 and xcodeproj 1.25.0 or
2- use a post_install workaround in your Podfile that changes one build setting back to what it was prior to cocoapods 1.16+ and allows the build to work

Here is the workaround if you are interested, note you may already have a post_install section, so you would just use the inner part(s):

[note: this was edited to be gnu++14 not c++14]

post_install do |installer|
  installer.pods_project.targets.each do |target|
    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
  end
end

You will need to run pod install again after adding this, so that it executes and updates the build setting

@mikehardy mikehardy added platform: ios impact: build-error Behaviour causing build failure plugin: firestore Firebase Cloud Firestore blocked: firebase-sdk Pending a confirmed fix landing on the official native sdk's (iOS/Android). resolution: solution-provided labels Oct 30, 2024
@mikehardy mikehardy pinned this issue Oct 30, 2024
@stephentuso
Copy link

For anyone using expo managed workflow - I added it in a plugin:

fix-rn-firebase.plugin.js

const { withDangerousMod, withPlugins } = require("@expo/config-plugins");
const {
  mergeContents,
} = require("@expo/config-plugins/build/utils/generateCode");
const fs = require("fs");
const path = require("path");

async function readFileAsync(path) {
  return fs.promises.readFile(path, "utf8");
}

async function saveFileAsync(path, content) {
  return fs.promises.writeFile(path, content, "utf8");
}

const withFixBuildSettings = (c) => {
  return withDangerousMod(c, [
    "ios",
    async (config) => {
      const file = path.join(config.modRequest.platformProjectRoot, "Podfile");
      const contents = await readFileAsync(file);
      await saveFileAsync(file, fixBuildSettings(contents));
      return config;
    },
  ]);
};

const fixSrc = `
    installer.pods_project.targets.each do |target|
      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
    end
`;

function fixBuildSettings(src) {
  return mergeContents({
    tag: `rn-firebase-fix-build`,
    src,
    newSrc: fixSrc,
    anchor: /post_install do \|installer\|/,
    offset: 1,
    comment: "#",
  }).contents;
}

module.exports = (config) => withPlugins(config, [withFixBuildSettings]);

npm i --save-dev @expo/config-plugins if you haven't already and add that file to your expo plugins list

@mikehardy
Copy link
Collaborator Author

@stephentuso with the just-released cocoapods 1.16.2 and xcodeproj 1.27 no workarounds are necessary for this issue - they reverted the breaking change

I'm going to close it, as current versions are now working fine

@mikehardy mikehardy changed the title workaround below - Undefined symbols "absl::lts_20240116::CHexEscape(absl::lts_20240116::string_view)" Undefined symbols "absl::lts_20240116::CHexEscape(absl::lts_20240116::string_view)" Nov 2, 2024
@ics-vandit
Copy link

CLANG_CXX_LANGUAGE_STANDARD

this is not working for me

@mikehardy
Copy link
Collaborator Author

mikehardy commented Nov 5, 2024

@ics-vandit the issue is closed. Current versions of cocoapods / xcodeproj require no fix
Thus no one should require a fix nor a workaround nor anything other than: update your cocoapods + xcodeproj gems / installation to current (that is, cocoapods 1.16.2+ and xcodeproj 1.27+)

@invertase invertase locked as resolved and limited conversation to collaborators Nov 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocked: firebase-sdk Pending a confirmed fix landing on the official native sdk's (iOS/Android). impact: build-error Behaviour causing build failure Needs Attention platform: ios plugin: firestore Firebase Cloud Firestore resolution: solution-provided
Projects
None yet
Development

No branches or pull requests

3 participants