Skip to content

fix(fmt): patch base.h consteval gate via prepare_command for Xcode 26.x#2961

Closed
tvinhas wants to merge 2 commits into
microsoft:0.83-mergefrom
tvinhas:fix-fmt-consteval-xcode-26
Closed

fix(fmt): patch base.h consteval gate via prepare_command for Xcode 26.x#2961
tvinhas wants to merge 2 commits into
microsoft:0.83-mergefrom
tvinhas:fix-fmt-consteval-xcode-26

Conversation

@tvinhas

@tvinhas tvinhas commented May 13, 2026

Copy link
Copy Markdown

Summary

Patches fmt 11.0.2's include/fmt/base.h via the podspec's prepare_command to widen the existing "Apple clang < 14 consteval broken" gate so it catches all Apple clang. Xcode 26.x ships a stricter consteval evaluator than fmt 11.0.2
expects; the bundled FMT_STRING macro reaches basic_format_string's consteval constructor and the compiler refuses with:

Pods/fmt/include/fmt/format-inl.h:59:24: error: call to consteval function
'fmt::basic_format_string<...>::basic_format_string<FMT_COMPILE_STRING, 0>'
is not a constant expression

(Multiple sites: lines 59, 60, 1387, 1391, 1394, ...)

This blocks every pod install + xcodebuild cycle on Xcode 26.x for any consumer of react-native-macos — including RNTester-macOS on 0.83-merge and microsoft/react-native-test-app's example-macos.

Why prepare_command (and not xcconfig -D)

An earlier version of this PR set GCC_PREPROCESSOR_DEFINITIONS = "$(inherited) FMT_USE_CONSTEVAL=0" in pod_target_xcconfig. That approach does not actually work: fmt's config chain at base.h:113-132 has no #ifndef FMT_USE_CONSTEVAL guard and unconditionally redefines the macro to 1 on any compiler that sets __cpp_consteval. The -D from the compile command line gets overwritten by the time basic_format_string's decorator is processed.
Verified locally: the macro lands in the generated xcconfig, but compile still fails with the same consteval errors.

Patching the source is the only path that survives clang's preprocessor passes. The existing "Apple clang < 14" branch on base.h:122-123 already disables consteval for compilers fmt's authors consider broken; widening it to catch all
Apple clang versions extends that fix to Xcode 26.x and falls back to fmt's constexpr path, which compiles cleanly. The constexpr path is fmt's documented fallback and is already battle-tested for MSVC < VS2019 16.10, GCC < 10, and Apple
clang < 14.

The sed -i.bak edit:

defined(apple_build_version) && apple_build_version < 14000029L
→ defined(apple_build_version)

Minimal, mechanical, reversible. Long-term fix is a fmt 11.1+ bump (fmt's own upstream addressed this in subsequent releases); this is the workaround until that bump lands.

Test Plan

  • Before: xcodebuild -workspace packages/rn-tester/RNTesterPods.xcworkspace -scheme RNTester-macOS -configuration Debug -destination 'generic/platform=macOS' ARCHS=arm64 build on 0.83-merge fails at CompileC .../fmt.build/.../format.o with the consteval errors above. Reproducible on any Xcode 26.x.
  • After: Same xcodebuild produces ** BUILD SUCCEEDED **. Additionally validated against microsoft/react-native-test-app's example-macos via a local Verdaccio publish: pod install + xcodebuild -scheme Example both green,
    produces a 44 MB ReactTestApp.app linking hermesvm.framework.
  • The patched base.h:122 line on a clean checkout reads #elif defined(__apple_build_version__) (no version constraint), and FMT_USE_CONSTEVAL resolves to 0 for all Apple clang.

Related

The xcconfig GCC_PREPROCESSOR_DEFINITIONS approach doesn't actually work:
fmt's base.h:113-132 chain has no #ifndef guard and unconditionally
redefines FMT_USE_CONSTEVAL=1 on any compiler that sets __cpp_consteval.
Patching base.h via prepare_command is the only path that survives the
preprocessor.
Validated locally on Xcode 26.5: pod install + xcodebuild succeed against
both packages/rn-tester and microsoft/react-native-test-app's example-macos.
@tvinhas tvinhas changed the title fix(fmt): set FMT_USE_CONSTEVAL=0 in fmt.podspec for Xcode 26.x compatibility fix(fmt): patch base.h consteval gate via prepare_command for Xcode 26.x May 13, 2026
@Saadnajmi Saadnajmi closed this Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants