Skip to content

Commit 38d06b1

Browse files
authored
fix(ios): patch fmt consteval build error on Xcode 26.4+ (#28225)
## **Description** Xcode 26.4 (Apple Clang 21) introduces stricter `consteval` enforcement that breaks the `fmt` library (v11.0.2) bundled via `RCT-Folly`, causing 5 compilation errors in `format-inl.h`. This patches `fmt/base.h` in the Podfile `post_install` block to disable `consteval` for all Apple Clang versions, falling back to `constexpr`. Same approach as the existing Folly coroutines patch. Safe for older Xcode versions — `constexpr` is the default fallback `fmt` already uses on many platforms. Survives `yarn setup` / `pod install` since the patch is re-applied each time. ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: N/A — build breakage on Xcode 26.4+ ## **Manual testing steps** ```gherkin Feature: iOS build with Xcode 26.4 Scenario: developer builds iOS app Given Xcode 26.4 with Apple Clang 21 is installed When developer runs yarn start:ios Then the build completes without fmt consteval errors ``` ## **Screenshots/Recordings** <!-- Not applicable — build fix only --> ### **Before** Build fails with 5 `consteval` errors in `ios/Pods/fmt/include/fmt/format-inl.h` ### **After** Build succeeds ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [ ] I've included tests if applicable - [ ] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Adds a CocoaPods `post_install` patch that rewrites a vendored `fmt` header, which could affect formatting code generation or conflict with future `fmt` updates, but is limited in scope to a single preprocessor toggle during install. > > **Overview** > Prevents Xcode 26.4+ build failures by extending the `Podfile` `post_install` step to patch `fmt/include/fmt/base.h`, forcing `FMT_USE_CONSTEVAL` from `1` to `0` (with a regex tolerant of whitespace/indentation) and handling file permissions similarly to the existing Folly patch. > > Updates `Podfile.lock` with the new `PODFILE CHECKSUM` reflecting the `Podfile` change. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 2c4aba0. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 39ec94f commit 38d06b1

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

ios/Podfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,24 @@ post_install do |installer|
163163
end
164164
end
165165

166+
# Fix fmt compilation error with Xcode 26 / Clang 21 consteval strictness
167+
# Directly disable FMT_USE_CONSTEVAL rather than patching the detection logic.
168+
# Uses regex to handle indented preprocessor directives (e.g. "# define").
169+
Dir.glob(installer.sandbox.root + "fmt/include/fmt/base.h") do |file|
170+
begin
171+
system "chmod +w #{file}"
172+
contents = File.read(file)
173+
modified = contents.gsub(/#\s*define FMT_USE_CONSTEVAL 1/, '#define FMT_USE_CONSTEVAL 0')
174+
if !File.writable?(file)
175+
system "sudo chmod +w #{file}"
176+
end
177+
File.write(file, modified)
178+
system "chmod -w #{file}"
179+
rescue => e
180+
Pod::UI.warn "Failed to modify fmt base.h: #{e.message}"
181+
end
182+
end
183+
166184
# This is necessary for Xcode 14, because it signs resource bundles by default
167185
# when building for devices.
168186
installer.target_installation_results.pod_target_installation_results

ios/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4875,6 +4875,6 @@ SPEC CHECKSUMS:
48754875
Yoga: 728df40394d49f3f471688747cf558158b3a3bd1
48764876
YttriumWrapper: cbddb60c835ebc4232d9f57064084ab30686a18e
48774877

4878-
PODFILE CHECKSUM: 03e4337c8a46ec38235554e231071c616488b29a
4878+
PODFILE CHECKSUM: 41ec3b10789f39c64e75ca60eb74e86257e8f76d
48794879

48804880
COCOAPODS: 1.16.2

0 commit comments

Comments
 (0)