[swiftgen] Add tool to detect classes and modules in a binary (#2639) #3702
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 278 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.337
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3702"
general
weight: 0.35
liamappelbe
<!--
Thanks for filing a pull request!
-->
Description
Why:
When generating Swift bindings,
package:objective_cresolves classes using their fully qualified name (<module>.<ClassName>). If the Swift module is unknown or configured incorrectly, runtime lookups fail withFailedToLoadClassException. Discovering which module a class belongs to previously required manual inspection using Unix pipes (nmandswift demangle).What:
This PR adds a diagnostic tool to automate class and module discovery from compiled binaries:
pkgs/swiftgen/tool/detect_classes.dartto inspect Mach-O binaries (.dylib,.framework, or executables) withnmandswift demangle, extracting_OBJC_CLASS_$_symbols and grouping them by Swift module.FfiGeneratorOptions.visitors(fg.Visitor) in SwiftGen.pkgs/swiftgen/test/detect_classes_test.dart.pkgs/swiftgen/README.mdwith usage instructions, Flutter binary locations, and visitor configuration examples.0.2.1-wipentry inpkgs/swiftgen/CHANGELOG.md.Related Issues
Fixes #2639
PR Checklist
dart tool/ci.dart --alllocally and resolved all issues identified. This ensures the PR is formatted, has no lint errors, and ran all code generators. This applies to the packages part of the toplevelpubspec.yamlworkspace.CHANGELOG.mdfor the relevant packages. (Not needed for small changes such as doc typos).