You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
FMT_STRING consteval error with Apple clang 21 (Xcode 26.4) #4740
Compiling the fmt pod via CocoaPods on Xcode 26.4 (Apple clang 21.0.0, clang-2100.0.123.102) fails with:
error: call to consteval function 'fmt::basic_format_string<char, ...>::basic_format_string<FMT_COMPILE_STRING, 0>' is not a constant expression
Errors appear in fmt/include/fmt/format-inl.h at lines 59, 60, 1387, 1391, and 1394 — all call sites of FMT_STRING(...).
Environment
Xcode 26.4, build version 17E192
Apple clang 21.0.0 (clang-2100.0.123.102)
fmt version: bundled with @maplibre/maplibre-react-native via CocoaPods
Root cause
base.h sets FMT_USE_CONSTEVAL 1 for Apple clang ≥ 14 (__apple_build_version__ >= 14000029L), enabling the consteval constructor in basic_format_string. Apple clang 21 is stricter about requiring consteval call sites to themselves be constant expressions, so the FMT_STRING(...) usages in format-inl.h — which are not constant expressions — are rejected.
Workaround
Patch base.h to treat all Apple clang versions the same as < 14 (i.e. FMT_USE_CONSTEVAL 0):
-#elif defined(__apple_build_version__) && __apple_build_version__ < 14000029L+#elif defined(__apple_build_version__)
# define FMT_USE_CONSTEVAL 0 // consteval is broken in Apple clang
Prior art
PR #4703 proposed a fix for this (adding a new threshold for clang 21+) but was closed without merging and without explanation. This issue is a request to reconsider that fix or apply an alternative.
Note: passing -DFMT_CONSTEVAL= or -DFMT_USE_CONSTEVAL=0 via compiler flags does not work, because base.h unconditionally redefines both macros through its own #if/#elif chain, overwriting any -D flag.
As commented on #4703 I wasn't able to repro the issue which is why it was closed, so you'll need to provide repro details. In particular do you get the error when compiling your code or {fmt} and what is the build configuration?
Note: passing -DFMT_CONSTEVAL= or -DFMT_USE_CONSTEVAL=0 via compiler flags does not work, because base.h unconditionally redefines both macros through its own #if/#elif chain, overwriting any -D flag.
This is incorrect. User-provided FMT_USE_CONSTEVAL is checked first and takes precedence over any auto-detection:
Thanks for the clarification. After investigating further:
The fmt version in question is 11.0.2, bundled via React Native's RCT-Folly CocoaPod (which pins fmt = 11.0.2). In that version, FMT_USE_CONSTEVAL is not guarded by #ifdef, so user-provided values via -D flags are overwritten by the detection chain — which is why the preprocessor flag approach didn't work for us. The #ifdef guard was added in 12.1.0, per the 12.1.0 release notes.
So the fix already exists in fmt 12.1.0 — the issue is that React Native hasn't upgraded yet. This is being tracked in:
Apologies for the incorrect root cause analysis in the original report. Feel free to close this issue — the fix is in fmt and the ball is in React Native's court.
Activity
vitaut commentedon Apr 10, 2026
As commented on #4703 I wasn't able to repro the issue which is why it was closed, so you'll need to provide repro details. In particular do you get the error when compiling your code or {fmt} and what is the build configuration?
vitaut commentedon Apr 10, 2026
This is incorrect. User-provided
FMT_USE_CONSTEVALis checked first and takes precedence over any auto-detection:fmt/include/fmt/base.h
Lines 117 to 118 in 9396f77
The root cause is also not quite correct because
FMT_STRING("...")is a constant expression.vitaut commentedon Apr 10, 2026
It is possible that the issue is specific to the older version of {fmt}. Does it reproduce on
main?turban commentedon Apr 10, 2026
Thanks for the clarification. After investigating further:
The fmt version in question is 11.0.2, bundled via React Native's
RCT-FollyCocoaPod (which pinsfmt = 11.0.2). In that version,FMT_USE_CONSTEVALis not guarded by#ifdef, so user-provided values via-Dflags are overwritten by the detection chain — which is why the preprocessor flag approach didn't work for us. The#ifdefguard was added in 12.1.0, per the 12.1.0 release notes.So the fix already exists in fmt 12.1.0 — the issue is that React Native hasn't upgraded yet. This is being tracked in:
Apologies for the incorrect root cause analysis in the original report. Feel free to close this issue — the fix is in fmt and the ball is in React Native's court.
vitaut commentedon Apr 10, 2026
No worries, I'm glad this is fixed already.
Merge branch 'mobile-sdk-11.5.1' into imbox-ios-mobile-sdk-11.5.1
chore(examples): patch fmt consteval for Xcode 26.4 in example-expo-53 (
Fix fmt consteval build error with Xcode 26 (Apple Clang 17+)
fix(bare-rn/ios): force C++17 on fmt/RCT-Folly pods to dodge consteva…
fix(ios): fmt consteval patch only on Xcode 26.4+
fix(deps): bump react-native to 0.83.9 to unblock iOS build on Xcode …
chore(expo-example): upgrade Expo SDK 54 to 55 and React Native 0.81 …
fix(ci): pin Xcode 26.2 for the iOS deploy job (#68)
fix macOS deps build with Apple Clang 21+ and tidy sanitizer flags
Chore: xcode fix for ios builds with old RN (software-mansion#9593)
Bump React Native to 0.86.0-rc.3 in example apps
build(ios): patch fmt for Xcode 26 compatibility
Fix: Xcode 26 build + Start crash, UI polish; bump to 1.9.7 (197)
fmt fix (real): patch fmt base.h to disable consteval on Apple clang
Fix fmt consteval build failure under Xcode 26
fix(ios): build fmt pod as C++17 to fix Xcode 26.4+ consteval error
fix(ios): build fmt pod as C++17 to fix Xcode 26.4+ consteval error
fix: bump macos-example to react-native-macos 0.81.8 for the Xcode 26…
Correct the fmt/Xcode 26 consteval fix: pin CLANG_CXX_LANGUAGE_STANDA…