Skip to content

example of ViewBuilder issue #1250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

russellwheatley
Copy link
Member

@russellwheatley russellwheatley commented May 2, 2025

Hacked together for purpose of demonstration only.

@russellwheatley russellwheatley changed the title question: how to make Views concrete? (i.e not use Any View) example of ViewBuilder May 2, 2025
public var googleButton: some View {
if googleProvider != nil {
// For purpose of demonstration
// This produces "Type 'any View' cannot conform to 'View'"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peterfriese - the problem is when we try to render from core package, Xcode produces this compiler error. I don't know how to get around it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you take a look at https://gist.github.com/peterfriese/d9745f366fb4f857daf077e93b1eb01f and see if this approach helps?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peterfriese - here is the commit attempting to follow your example: 8c38462 (#1250)

@russellwheatley russellwheatley changed the title example of ViewBuilder example of ViewBuilder issue May 2, 2025
@russellwheatley russellwheatley changed the base branch from main to facebook-google-phone-buttons May 2, 2025 08:38
@@ -28,7 +28,8 @@ extension AuthPickerView: View {
Text(authService.authenticationFlow == .login ? "Login" : "Sign up")
VStack { Divider() }
EmailAuthView()

// Xcode compiler exception: Type 'any ExternalAuthProvider' cannot conform to 'ExternalAuthProvider'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peterfriese - Following your gist example, we get this Xcode compiler error now.

I tried to remove any ExternalAuthProvider from the types in auth service for each provider but it isn't allowed because ExternalAuthProvider uses an associated type (ButtonType), Swift requires you to explicitly acknowledge it as an existential by using any ExternalAuthProvider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants