Skip Lite: views re-exported through a non-Skip umbrella target are silently dropped in @ViewBuilder
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 22/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Área
- build-system, tooling
Línea de trabajo
Start with the repro repo and run swift package --allow-writing-to-package-directory skip-transpile on UsesUmbrella versus UsesDirect to compare the generated DemoView.kt. The relevant code is in SkipTranspile.swift (the umbrella-skipping logic around lines 204-221), CodebaseInfo.swift (expandWithExportedImports and rankScore), and KotlinSwiftUITransformer.swift (translateViewBuilder and translateFunctionCall). Done means Badge gets .Compose(composectx) and Card's trailing closure is wrapped in ComposeBuilder when imported through the umbrella, with the output matching the direct import.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Some of our packages use a thin umbrella target (no Skip/skip.yml) whose only content is @_exported import Core, so that consumers can import CoreUmbrella. A Skip module that imports the umbrella gets broken Kotlin for any Core view used inside a @ViewBuilder:
Badge()is emitted without.Compose(composectx), so it never renders.Card { Text("a"); Text("b") }becomes a plain lambda, so only the last child survives andCarditself is not composed.
Swift, the transpile and Kotlin all compile without errors. The only sign is a generic "Skip is unable to match this API call" warning, and it only appears when the file is re-transpiled.
Skip 1.9.19, skip-ui 1.64.0, skip-foundation 1.4.8. The code involved is unchanged on main.
Repro
https://github.com/daniboybye/skip-umbrella-viewbuilder-repro
// Inner (Skip module): public struct Badge: View, public struct Card<Content: View>: View { init(@ViewBuilder content:) }
// InnerUmbrella (no skip.yml):
@_exported import Inner
// UsesUmbrella (Skip module); UsesDirect is identical but uses `import Inner`
import InnerUmbrella
import SwiftUI
public struct DemoView: View {
public var body: some View {
VStack {
Badge()
Card { Text("a"); Text("b") }
}
}
}
swift package --allow-writing-to-package-directory skip-transpile
Generated DemoView.kt, UsesDirect → UsesUmbrella:
- Badge().Compose(composectx)
+ Badge()
Card { ->
- ComposeBuilder { composectx: ComposeContext ->
- Text(LocalizedStringKey(stringLiteral = "a")).Compose(composectx)
- Text(LocalizedStringKey(stringLiteral = "b")).Compose(composectx)
- ComposeResult.ok
- }
- }.Compose(composectx)
+ Text(LocalizedStringKey(stringLiteral = "a"))
+ Text(LocalizedStringKey(stringLiteral = "b"))
+ }
Cause
- The plugin recurses through
InnerUmbrella, skips it because it has noskip.yml, and still linksInner(SkipTranspile.swift#L204-L221). SoInner's symbols are loaded, but skipstone never learns thatInnerUmbrellare-exportsInner. expandWithExportedImportsonly follows re-exports declared by Skip modules (skiptools/skipstone#256).Inneris therefore not visible to the file, andrankScorereturns 0 forBadgeandCard.- With no API match,
translateViewBuilderadds no.Compose, andtranslateFunctionCalldoesn't treat the trailing closure as a@ViewBuilder.
It goes unnoticed when Inner's skip.yml sets package: to the name derived from the umbrella (inner.umbrella), because import inner.umbrella.* then resolves. That is our setup.
Workaround
import InnerUmbrella
#if SKIP
import Inner
#endif
Calling the view through a local function (func badge() -> some View { Badge() }) also works for plain views, but not for @ViewBuilder containers.
Proposed fix
- skip plugin: for a dependency target without
skip.yml, pass--umbrella-module InnerUmbrella:<dir>and add its sources to the plugin inputs. - skipstone: parse those files, collect their
@_exported imports of linked modules, and register a symbol-lessModuleExportfor the umbrella with thoseexportedModuleNames. The #256 code handles the rest. Also skip the umbrella's own Kotlin import unless it matches a real package.
A local skipstone test confirms that adding such a stand-in ModuleExport restores both .Compose calls with no other change.
Separately, it would help if an unmatched bare initializer inside a @ViewBuilder produced a clearer diagnostic, since its result is silently discarded.
If this direction works for you, I'm happy to send PRs for skip and skipstone.
- Lenguaje dominante
- Swift
- Estrellas
- 3.3k
- Forks
- 115
- Merge medio
- 1 d 15 h
- PR fusionados (30 d)
- 5
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de skiptools/skip
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Comments in functionsAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
enhancement project
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
skiptools/skip#673 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
documentation
Dificultad 1/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
documentation
Dificultad 1/5 Menos de una hora Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
Todos los issues de skiptools/skip
Issues similares
-
enhancement help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
heysidhant/appvanish#4 ·
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
timfraedrich/OutRun#121 ·
-
deferred tooling
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
mauwii/pokerchipcase#157 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
Verify the Intel (x86_64) buildAbiertogood first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100