2026-05-28 reflect-skip: #if SKIP vs SKIP_BRIDGE definitive rule
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
title: Reflect — Skip Fuse (SwiftUI/Kotlin)
|
title: Reflect — Skip Fuse (SwiftUI/Kotlin)
|
||||||
created: '2026-05-23'
|
created: '2026-05-23'
|
||||||
updated: '2026-05-23'
|
updated: '2026-05-28'
|
||||||
type: tech
|
type: tech
|
||||||
namespace: personal
|
namespace: personal
|
||||||
tags: [reflect, swift, kotlin, ios, android, pitfalls]
|
tags: [reflect, swift, kotlin, ios, android, pitfalls]
|
||||||
@@ -30,3 +30,15 @@ require explicit Kotlin stubs until Skip's transpilation coverage catches up.
|
|||||||
- [ ] Create matching Kotlin stub in `android/src/.../views/`
|
- [ ] Create matching Kotlin stub in `android/src/.../views/`
|
||||||
- [ ] Register in Android router/factory
|
- [ ] Register in Android router/factory
|
||||||
- [ ] Run `./gradlew build` to verify no missing class errors
|
- [ ] Run `./gradlew build` to verify no missing class errors
|
||||||
|
|
||||||
|
## `#if SKIP` vs `#if SKIP_BRIDGE` — Definitive Rule
|
||||||
|
|
||||||
|
| Macro | When to use |
|
||||||
|
|-------|-------------|
|
||||||
|
| `#if SKIP` | Any code that runs **only on Android** via Skip (UI layout, Android-only APIs, SAF file access). Works in all Skip-compiled code. |
|
||||||
|
| `#if SKIP_BRIDGE` | **Only** for JNI bridge calls: `AnyDynamicObject`, calling Kotlin statics from Swift, `import SkipBridge`. Available only in bridge modules. |
|
||||||
|
|
||||||
|
**Rule**: UI buttons, conditional layouts, Android-only views → `#if SKIP`.
|
||||||
|
`AnyDynamicObject(forStaticsOfClassName:)` and JNI → `#if SKIP_BRIDGE`.
|
||||||
|
|
||||||
|
Using `#if SKIP_BRIDGE` for UI will silently exclude the code on Android (it's not a bridge module), causing buttons/views to disappear with no error.
|
||||||
|
|||||||
Reference in New Issue
Block a user