Can't use extensions from another module #277
-
I created a multi-module app following the documentation, with one of the module being the app, and the other a design system containing extensions of components like so: public struct PrimaryButtonStyle: ButtonStyle {
public init() {}
public func makeBody(configuration: Configuration) -> some View {
configuration.label
.fontWeight(Font.Weight.bold)
.font(Font.title3)
.fontDesign(Font.Design.rounded)
.padding()
.foregroundStyle(Color.white)
.background(configuration.isPressed ? Color.gray.opacity(0.2) : Color.accentColor)
.clipShape(RoundedRectangle(cornerRadius: 12))
}
}
public extension ButtonStyle where Self == PrimaryButtonStyle {
static var primary: PrimaryButtonStyle {
PrimaryButtonStyle()
}
} But when I try to use it like so in the Skip app, I get a bunch of the following errors: import MyModule
Button("Hey there!") {
// noop
}
.buttonStyle(.primary)
And inside the design system module itself I get those 2 errors:
I am not sure where this issue comes from, as I didn't really find any similar issues online. Any help is appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
I think you just need to |
Beta Was this translation helpful? Give feedback.
-
Unfortunately it would require modifications to our transpiler as well in order to properly recognize the makeBody function as a @ViewBuilder. We haven't had many requests for ButtonStyle support - I assume most users are just creating their own View type whose body displays a Button whose label is styled, and then using that instead |
Beta Was this translation helpful? Give feedback.
Sorry, Skip doesn't support button styles. You can view the list of supported SwiftUI here: https://skip.tools/docs/modules/skip-ui/#supported-swiftui