Mohammad Azam demonstrates how to build and use a custom Swift Macro to automatically generate SwiftUI forms from state variables.
In this video, Mohammad Azam will demonstrate how to use Swift Macros to automatically generate SwiftUI forms. Azam will implement FormBuilder macro, which can be attached to any view and create the Form element with all the bindings based on the State variables.
If you are looking for top quality iOS courses to elevate your skills then check out my courses:
azamsharp.teachable.com/
GitHub:
github.com/azamsharp/FormBuilderMacro
#iosdev #swiftui #swiftlang Check out my courses at
azamsharp.school/
Why it's here
2 people recommend this
What people say. Recommended as an example of using Swift Macros to automate boilerplate UI generation.
F
u/Frequent-Revenue6210in r/swift • Recommends
Scaffolding SwiftUI Forms Using Swift Macros
In this video, Mohammad Azam will demonstrate how Swift Macros can be used to automatically generate a SwiftUI Form with all the required views, based on the state variables.
[video
On “Has anyone here written their own property wrappers or macros in Swift?”
…ented FormBuilder. If you put FormBuilder on the SwiftUI view then all the state properties of the view will be automatically converted into different UI elements. Like TextField, Toggle etc. It was inspired from ASPNET model attribute that did similar thing. Maybe it was a different attribute but it was inspired from ASPNET MVC feature.
Video: [video
For property wrapper, I implemented Required property wrapper that allowed to do validation for SwiftUI forms. It was also inspired from things I learned in ASPNET framework.
Here is a simple code snippet that validates the email property for being required and against a regular expression.
**@.Validate**(**.required**("Email is requir…