真實的 iOS / React Native codebase 橫跨多種語言——Swift caller 呼叫被自動橋接的 Objective-C selector、JS 檔經由 RN bridge 呼叫 native module、JSX component 委派給 native view manager。純 tree-sitter 抽取在每個語言邊界就斷了。CodeGraph 把它們接起來,讓 codegraph_explore 端到端連通這些流——call path 與 blast radius 跨過邊界,而不是停在邊界。
| 邊界 | JS / Swift 側 | Native 側 | 做法 |
|---|---|---|---|
| Swift → ObjC | Swift obj.foo(bar:) | ObjC selector -fooWithBar: | @objc auto-bridging 規則(含 init/property/protocol 形式)+ Cocoa preposition 前綴(With/For/By/In/On/At…) |
| ObjC → Swift | ObjC [obj fooWithBar:] | Swift @objc func foo(bar:) | Reverse-bridge 名稱候選;從原始碼驗證 @objc 暴露 |
| RN legacy bridge | JS NativeModules.X.fn(...) | ObjC RCT_EXPORT_METHOD/RCT_REMAP_METHOD · Java/Kotlin @ReactMethod | 解析 macro/annotation 宣告,建 JS-name → native-method map |
| RN TurboModules | JS import M from './NativeM'; M.fn(...) | 符合 Codegen spec 的 native impl | 把 Native<X>.ts spec interface 當 ground truth |
| RN native → JS events | JS new NativeEventEmitter(...).addListener('e', cb) | ObjC [self sendEventWithName:@"e" body:...] · Swift sendEvent(withName: "e", ...) · Java/Kotlin .emit("e", ...) | 依字面 event name 合成跨語言事件通道 |
| Expo Modules | JS requireNativeModule('X').fn(...) | Swift / Kotlin Module { Name("X"); AsyncFunction("fn") { ... } } | 解析 Expo DSL 字面值;synthetic method 節點用既有 name-match 解析 |
| Fabric view components | JSX <MyView prop={v}/> | TS Codegen spec + native impl class | Spec → component 節點;慣例名稱+suffix(View/ComponentView/Manager/ViewManager)橋到 native |
| Legacy Paper view managers | JSX <MyView prop={v}/> | ObjC RCT_EXPORT_VIEW_PROPERTY · Java/Kotlin @ReactProp | 與 Fabric 相同——Paper 時代宣告也產 component + property 節點 |
每個 bridge 產出的邊都標 provenance:'heuristic',且 metadata.synthesizedBy: 設為穩定 channel 名(如 swift-objc-bridge、rn-event-channel、fabric-native-impl、expo-module-extract)——agent 一眼就能看出某個 hop 是怎麼進圖的。
| Bridge | Small | Medium | Large |
|---|---|---|---|
| Swift ↔ ObjC | Charts | realm-swift | Wikipedia-iOS |
| RN legacy bridge | AsyncStorage | react-native-svg | react-native-firebase |
| RN native → JS events | RNGeolocation | — | react-native-firebase |
| Expo Modules | expo-haptics | expo-camera | expo SDK sweep(7 packages) |
| Fabric / Paper views | react-native-segmented-control | react-native-screens | react-native-skia |