|
Hello, the new XCode 15 comes with macros, and a prominent one is the However, in the past, I could do this
where selectedTab is But the same with the new syntax, will not work.
I've looked through the WWDC video on it but couldn't find the answer. For now, I've reverted to using the old syntax pre-macros. Is there a way? |
|
Not sure if this will work for your use case ?
|
|
No, no that's not it. That won't compile.
|
|
The
So something like this:
|
|
The solution to this is you need to return your VStack from the trailing closure.
The body of the #Preview is a closure that returns a View. So given how closures work by adding the State variables you can no longer us the shorthand implicit return. You must explicitly return the view.
https://developer.apple.com/documentation/swiftui/preview(_:body:)/ |
|
Using the
Source: https://developer.apple.com/documentation/SwiftUI/Previewable() |
|
I am using |
SPONSORED Alex is the iOS & Mac developer’s ultimate AI assistant. It integrates with Xcode, offering a best-in-class Swift coding agent. Generate modern SwiftUI from images. Fast-apply suggestions from Claude 3.5 Sonnet, o3-mini, and DeepSeek R1. Autofix Swift 6 errors and warnings. And so much more. Start your 7-day free trial today!
Sponsor Hacking with Swift and reach the world's largest Swift community!
You need to create an account or log in to reply.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.