Skip to content

A macro that generates a protocol including non private members of any class or struct.

License

Notifications You must be signed in to change notification settings

Pimine/ProtocolMacro

 
 

Repository files navigation

ProtocolMacro

A macro that produces a protocol based on a class/struct non private interface

Usage

1 - add ProtocolMacro as a dependency
2 - import ProtocolMacro
3 - mark your class or struct with the macro @Protocol
4 - Add conformance to generated protocol (its name is your Type suffixed by 'Protocol'): {YourTypeHere}Protocol

example

import ProtocolMacro
@Protocol
struct ViewModel: ViewModelProtocol {
    var someProperty: String = ""
    func function() { }
    private func privateFunctionsNotIncluded() { }
}

extension ViewModel {
    func extensionFunctionsNotIncluded() { }
}

auto-generated code:

protocol ViewModelProtocol {
    var someProperty: String {
        get
        set
    }
    func function()
}

About

A macro that generates a protocol including non private members of any class or struct.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 100.0%