In this chapter, you'll learn about the core fundamentals of the declarative syntax. You'll be able to identify and understand the theory behind it and the part it plays in SwiftUI development. We'll look specifically at how the syntax is written and how easily it can be intercepted and edited in a live debugging environment, all within Xcode. We'll finish off by going deeper into the structure of the syntax and understand how it all binds together. By the end of this chapter, you'll be able to fully understand what advantages are on offer, along with how to comfortably write a basic UI using declarative syntax.
Without declarative syntax, there would be no SwiftUI, or it would simply be another UIKit forcing users to learn a new framework with the same base language. Due to this, it is important to learn the fundamentals of the syntax as this will help you not only understand the core principles of SwiftUI but how to successfully utilize and build on the foundation that has been laid.
Learning SwiftUI without understanding its declarative syntax would be like trying to drive without really knowing what a car is and, although this does sound like a lot to learn before you've even written your first line of code, with this knowledge at hand, you'll be able to jump right into coding the syntax without any worries.
The following topics will be covered in this chapter:
- What is declarative syntax?
- Visualizing declarative syntax
- Nesting and decoration
- Imperative syntax