Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to define valid UserRuntimeAttributes #37

Open
SD10 opened this issue Mar 22, 2018 · 3 comments
Open

Allow users to define valid UserRuntimeAttributes #37

SD10 opened this issue Mar 22, 2018 · 3 comments

Comments

@SD10
Copy link
Member

SD10 commented Mar 22, 2018

At IBAnimatable we have a ton of UIKit subclasses with @IBInspectable properties. Some of these are String's and can be very error prone to work with.

Example:
The border property accepts a String of either: solid or dash

If the user writes something like dotted, we should show an error

I think this is possible but the user has to tell us:
a) All valid keys
b) All classes/subclasses this property is used on

Probably in a .yml file?

That may seem like a lot of work but if IBAnimatable were to publish this .yml file on their docs, it could be reusable.

@kateinoigakukun
Copy link
Collaborator

kateinoigakukun commented Mar 22, 2018

The idea which validates runtime attributes looks good. But all valid keys and classes definitions make .iblinter.yml too complex. So we extract the definitions to another file.
IBAnimatable‘s valid key map .yml file may be published as IBDecodable plugin.

@phimage
Copy link
Member

phimage commented Apr 9, 2018

decoding UserRuntimeAttributes IBDecodable/IBDecodable#5

I am interested with this feature. I am thinking about generating the file using sourcery if @IBInspectable annotation is accessible.
Each framework must provide its own file.

@viktorasl
Copy link

How about having a rule, similar to custom_module_rule which would take as a param list of files where each IBInspectable will provide valid values in a comment.
Since IBLiner already has SourceKitten as a dependency it (probably?) can be done.

...
user_runtime_attributes:
- path_to_file
...
// _blurEffectStyle: ExtraLight, Light, Dark
@IBInspectable var _blurEffectStyle: String? {
  didSet {
    ...

// _borderType: solid, dash
@IBInspectable var _borderType: String? {
  didSet {
    ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants