ios-viper-xcode-templates
ios-viper-xcode-templates copied to clipboard
Add SwiftUI templates and LazyLoadingVC
This PR is made as a base for release 4.1 and it adds SwiftUI templates and the LazyLoadingVC needed to make things work. I'll update the README with a proper description later, but right now I want you to take a look at this and see if we should improve it in any way or if is this fine for the initial SwiftUI support when it comes to VIPER.
The main problem with integrating SwiftUI views is that we need to add them to the UIHostingController and we also need to pass them to the presenter. This conflicts with the current setup where the presenter also holds the reference to the VC, and to be fair, with the way SwiftUI handles things, this is not needed. We also have a circular creation dependency between the SwiftUI view, presenter, and wireframe.
The reason to still use VIPER and not switch completely to MVVM is that in mixed UIKit/SwiftUI projects we would still like to have the option to keep navigation in UIKit (VIPER) and we also want to keep the general project structure as familiar as possible for easier onboarding.
I've created 3 generator templates:
- Simple -> Interfaces, SwiftUI View, Presenter, Wireframe -> for basic screens that just display some static info
- Interactor -> Interfaces, SwiftUI View, Presenter, Interactor, Wireframe -> for screens that have some communication with other app layers
- InteractorAndFormatter - Interfaces, SwiftUI View, Presenter, Formatter, Interactor, Wireframe -> for screens that have some communication with other app layers and has a more complex formatting logic which would otherwise clutter the presenter
Take a look at the PR and add any suggestions you think of, I'm all ears 😄
I would refrain from calling this a "SwiftUI Module" since it's really not :) It's more of a "Hosted SwiftUI Module" or something like that. You could also add a real SwiftIUI module 😄
And my actual issue: Please use erb and templates for templates to do this.
And my actual issue: Please use erb and templates for templates to do this.
Yeah, that's the idea, I'll do it once we agree this is ok as an initial version of something for the hosting controller.
I wanted to first have a check regarding the generated files before dealing with templates for templates to avoid double work, hence why it's still in a draft state 😄
I'm just checking what is the state of this PR, should it still be a draft, and what is the strategy with this approach? @goranbrl
I'm just checking what is the state of this PR, should it still be a draft, and what is the strategy with this approach? @goranbrl
A proper generator will be released in the coming months as a result of our SwiftUI architecture standardization, and it will be covered through a separate PR. Let's keep this in a draft state until that happens just so we have the discussion history readily available, and I'll close it when appropriate.
How does this sound to you?
cc @ilucijabalja @MartinColja @Anteo95
Fine by me 👍
Closing this one, we will use #61 to wrap up the introduction of SwiftUI 🙂