chore: support newer c++ versions#724
Conversation
WalkthroughAdds a CocoaPods post_install hook in Podfile to conditionally patch Pods/gRPC-Core/src/core/lib/promise/detail/basic_seq.h by replacing "Traits::template CallSeqFactory" with "Traits::CallSeqFactory" when the file exists, ensuring writability before in-place edit. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Dev as Developer
participant CP as CocoaPods (pod install)
participant Hook as post_install Hook
participant FS as File System
Dev->>CP: Run pod install
CP->>Hook: Invoke post_install
alt gRPC-Core basic_seq.h exists
Hook->>FS: Make file writable
Hook->>FS: Read file contents
Hook->>FS: Replace "Traits::template CallSeqFactory" with "Traits::CallSeqFactory"
Hook->>FS: Write updated contents
Note right of Hook: Conditional patch applied
else File missing
Hook-->>CP: No-op
end
CP-->>Dev: Installation complete
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
Podfile (3)
110-118: Make the patch safer, idempotent, and path-robustHarden the edit to only write when a change is actually made, and resolve the Pods root via the installer to avoid path drift. Also limit removal of the
templatedisambiguator to cases where it isn’t followed by<(so we don’t break legitimateFoo::template Bar<...>uses if they ever appear).Apply:
- # Fix gRPC-Core template syntax issue with newer Xcode - grpc_file = 'Pods/gRPC-Core/src/core/lib/promise/detail/basic_seq.h' - if File.exist?(grpc_file) - # Make file writable before modifying - File.chmod(0644, grpc_file) - text = File.read(grpc_file) - new_contents = text.gsub(/Traits::template CallSeqFactory/, 'Traits::CallSeqFactory') - File.write(grpc_file, new_contents) - end + # Fix gRPC-Core template syntax issue with newer Xcode + pods_root = installer.sandbox.root.to_s + grpc_paths = Dir[File.join(pods_root, 'gRPC-Core/src/core/lib/promise/detail/basic_seq.h')] + grpc_paths.each do |grpc_file| + next unless File.exist?(grpc_file) + text = File.read(grpc_file) + # Only strip the disambiguator when it's not followed by '<' + patched = text.gsub(/Traits::template\s+(CallSeqFactory)\b(?!\s*</), 'Traits::\1') + next if patched == text + File.chmod(0644, grpc_file) unless File.writable?(grpc_file) + File.write(grpc_file, patched) + puts "Patched gRPC-Core template disambiguator in #{grpc_file}" + end
110-118: Scope the patch to affected toolchains (optional)To reduce churn on unaffected setups, you can gate the patch on the local Xcode version (e.g., only apply for Xcode 16.x where the parser tightened this rule). This is optional but keeps noise down for other developer machines and CI images.
Example:
xcode_ver = `xcodebuild -version 2>/dev/null`.to_s[/Xcode\s+(\d+\.\d+)/, 1] needs_patch = xcode_ver && Gem::Version.new(xcode_ver) >= Gem::Version.new('16.0') if needs_patch # ... run the patch logic ... else puts "Skipping gRPC-Core patch for Xcode #{xcode_ver}" endContext: Reports cluster around Xcode 16.x toolchains. (stackoverflow.com, github.com)
110-118: Longer-term: manage this as a formal CocoaPods patch for traceabilityIf this persists until upstream updates the pod, consider using cocoapods-patches for a reproducible, diff-based patch with a link to the upstream issue. It improves discoverability and makes removal straightforward when the pod is updated.
High level steps:
- Add the cocoapods-patches plugin and a small patch file targeting basic_seq.h.
- Annotate with the gRPC issue URL for future cleanup.
References:
- Upstream tracker for this specific parse error. (github.com)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (1)
Podfile.lockis excluded by!**/*.lock
📒 Files selected for processing (1)
Podfile(1 hunks)
🔇 Additional comments (2)
Podfile (2)
110-118: Stopgap fix is reasonable; matches known Xcode 16 gRPC-Core parsing issueThis in-place patch aligns with community-reported workarounds for Xcode 16’s “A template argument list is expected after a name prefixed by the template keyword” error in gRPC’s basic_seq.h. Replacing
Traits::template CallSeqFactorywithTraits::CallSeqFactoryis consistent with upstream reports.References:
- Stack Overflow reports the exact fix in basic_seq.h under Xcode 16.0.x, recommending the same replacement. (stackoverflow.com)
- gRPC upstream issue tracks this with the identical code context under basic_seq.h. (github.com)
110-118: Consider whether CheckResultAndRunNext needs the same fixSome copies of basic_seq.h also use
Traits::template CheckResultAndRunNext(...)with parentheses (no<...>). If present in the version you’re pulling, Apple Clang in Xcode 16 may flag the same parse error there too. You might want to extend the guarded replacement to include it.If needed, adjust the regex once to cover both symbols:
- patched = text.gsub(/Traits::template\s+(CallSeqFactory)\b(?!\s*</), 'Traits::\1') + patched = text.gsub(/Traits::template\s+(CallSeqFactory|CheckResultAndRunNext)\b(?!\s*</), 'Traits::\1')References:
- Upstream issue shows both
CheckResultAndRunNextandCallSeqFactoryin the failing region. (github.com)- Another public reproduction includes both lines with
templatebefore a call expression. (stackoverflow.forums.wiki)
Issue being fixed or feature implemented
Fix some build process items
What was done?
How Has This Been Tested?
Breaking Changes
Checklist:
For repository code-owners and collaborators only
Summary by CodeRabbit