AutomaticSettings icon indicating copy to clipboard operation
AutomaticSettings copied to clipboard

Question - how to configure stencil + .sourcery.yml

Open avnerbarr opened this issue 3 years ago • 2 comments

Hi @krzysztofzablocki

I just opened a PR which compiles on mac.

I'm having issues though configuring the template + sourcery file.

Here is an example project

https://github.com/avnerbarr/TestSourcery

The workflow isn't completely clear to me.

I'm creating a "settings" struct and adding the conformance.

I see that in the yml there is an include to AutomaticSettingsProtocols.swift. Isn't this part of the imported library?

sources:
  include:
    - AutomaticSettingsProtocols.swift <<<<<<<<<< this part

Also regarding the structure which I need to provide (the container views for Settings ?). Could you point me to an explanation of which views I should provide, and the usage of AutomaticSettingsViewModel etc.

Thanks!

avnerbarr avatar Mar 05 '21 14:03 avnerbarr

@avnerbarr

  1. the reason you need to include AutomaticSettingsProtocols.swift is that otherwise Sourcery doesn't know about those protocols so the template won't know your type implement them (depending on how you integrate you could copy the protocols and put them as private in your project so they don't clash with framework or just point sourcery at the source code file)
  2. as for Views you only need the main view, all the code I'm using for integration is in https://github.com/krzysztofzablocki/AutomaticSettings/tree/main/Example/Example/Settings%20Integration so you can copy the same setup, after that the only thing left is to just create an instance of your View / VM https://github.com/krzysztofzablocki/AutomaticSettings/blob/main/Example/Example/ExampleApp.swift#L35

krzysztofzablocki avatar Mar 06 '21 11:03 krzysztofzablocki

@avnerbarr do you need more help?

krzysztofzablocki avatar Mar 12 '21 12:03 krzysztofzablocki