Voir is a tiny Swift framework designed to offer a fully functional and easy-to-use MVVM architecture for iOS app development, tailored for the braves who are still relying on UIKit.
The name “Voir” originates from the French word meaning “to see”, reflecting its objective of enhancing the visibility and clarity of your app's architecture.
This project was initiated to support a presentation at a conference that centers around delivering insightful topics to the tech community. The central theme of my talk is:
Elegant Development: poetry and beauty in Swift code.
-
MVVM Architecture: Voir provides a solid foundation for implementing the MVVM architecture in your iOS apps. It separates concerns by dividing the application logic into three main components: Model, View, and ViewModel.
-
Reusable Components: The package introduces reusable components such as
VoirComponent
andVoirModel
, making it easier to structure your app's UI and business logic. -
Lifecycle Observations: Voir provides built-in lifecycle observation mechanism that automatically notify its components. This feature aids in efficiently managing resource allocation and deallocation. This aspect of Voir almost eliminates the need for touching a UIViewController again, as the
VoirController
efficiently relays all of its lifecycle events to bothVoirComponent
andVoirModel
. -
Builder Patterns: The framework includes builder patterns (
VoirBuilder
andConstraintsBuilder
) that simplify the process of constructing complex UI hierarchies and defining layout constraints. Together, these patterns provide a beautiful domain-specific language (DSL) that not only enhances your code's aesthetics but also makes it completely understandable and easy to maintain when designing, positioning, and configuring UI elements.Voir Builer
is also a separated target inside the package and can be used without outside the MVVM architecture. -
View Controller Helper: With the
viewController
property extension onUIView
, you can easily find the parent UIViewController of any view, aiding in navigation and communication within your app.
- To integrate Voir into your project, simply include the framework as a Swift package.
- There is also a
.xctemplate
to easily create a Voir MVVM Scene. Check the recording below 👇
Voir.xctemplate.mp4
TemplateInstaller is a small Swift command-line interface tool whose sole purpose is to copy the Support/Voir Scene.xctemplate
to the necessary destination, enabling the template to appear in Xcode's File > New
selection window.
1) On your terminal, inside the cloned project folder, just run:
swift run
or 2) Prefer the manual labor?
XCPATH="~/Library/Developer/Xcode/Templates/Project Templates/iOS/Application/"
mkdir -p "$XCPATH"
cp "Support/Voir Scene.xctemplate" "$XCPATH"
For more detailed usage instructions and examples, refer to the DemoApp
inside Support/
folder in the repository.
Checkout DemoApp.xcproject at Support/VoirDemo
folder. It has a small demonstration on how you can take advantage of every feature Voir can offer.
Are you on dark mode? Tap 👆 to see full white background.
Contributions to Voir are welcome! If you find a bug, want to request a feature, or would like to improve the code, please submit an issue or pull request.
Voir is unlicensed. You are free to use and modify. See LICENSE for more details.
Voir is currently developed and maintained by Arthur da Paz.