[objective_c] Link Foundation in the native support library #3782
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.46) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.46 · 474 lines diff across 5 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.369
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3782"
general
weight: 0.35
liamappelbe
Description
The ObjC bindings load classes through their
OBJC_CLASS_$_Foosymbols, resolved via theobjective_c.dylibhandle, and fall back toobjc_getClasswhen that lookup throws (#3344). The native support library is linked with-undefined dynamic_lookupand no frameworks, so it only depends onlibSystem:As a result
dlsymcan never find a built-in Foundation class through that handle, and the first use of every Foundation class inpackage:objective_c(NSArray,NSString, ...) throws anArgumentErrorthatgetClasscatches before falling back:The result is still correct, but a debugger that breaks on all exceptions stops at app startup on any Flutter app that uses
path_provider(viapath_provider_foundation), with no way to skip just this exception.This PR links the support library against Foundation, so these symbols resolve through the dylib's dependencies, to the same class pointers
objc_getClassreturns. The dylib's own classes (DOBJC*) still resolve as before, and the fallback is kept for other frameworks.Related Issues
Follow-up to #3344 (which fixed #3338). There is no separate issue for this; happy to file one if preferred.
Testing
test/internal_test.dartthat resolvesOBJC_CLASS_$_NSArraythroughpackage:objective_c/objective_c.dyliband compares it withgetClass('NSArray'). It fails onmainwith theArgumentErrorabove and passes with this change.objective_c.yamlandffigen.ymllocally (macOS 27, Xcode 27.1, Flutter 3.47.9 / Dart 3.13.7):-
pkgs/objective_c:dart format --set-exit-if-changed,flutter analyze --fatal-infos, the snippet check anddart test(152 tests) pass.-
example/command_line:dart run lib/main.dartworks.-
example/flutter_app:flutter build macos,flutter build ios --no-codesignandxcodebuild analyze(warnings as errors) succeed.otool -Lon the bundledobjective_c.frameworknow lists Foundation for both macOS slices and iOS.-
pkgs/ffigen:dart testgives the same result with and without this change: 901 passed, 1 failed (verify_bindings_testforsdk_variable_test.dart, a bindings diff from the Xcode 27.1 SDK).Note: with the Xcode 27.1 SDK,
test/generate_code_test.dartregeneratesobjective_c_bindings_generated.dartwith a few newdeprecated 27.0.0annotations. That is unrelated to this change and not included.PR Checklist
dart tool/ci.dart --alllocally and resolved all issues identified. (It doesn't coverpkgs/objective_corpkgs/ffigen, so I also ran their workflow jobs, see Testing. Everything passes except 4swift2objcintegration tests, whose expected output differs with the local Xcode 27.1 Swift, and theswift2objcapitool missing-export check. This PR doesn't touchswift2objc, which doesn't depend onobjective_c.)CHANGELOG.mdfor the relevant packages.