Skip to content

mikeyclarke/NoCoderInitMacro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NoCoderInitMacro

A Swift Macro that adds an unimplemented init(coder:) to your classes so that you don’t have to.

Installation

NoCoderInitMacro is installable using Swift Package Manager.

Add to your package.swift

.package(url: "https://github.com/mikeyclarke/NoCoderInitMacro.git", from: "1.0.0"),

Or through the Xcode UI:

  • “Add Package Dependency…” (currently available from the File menu or in the right-click menu in the File Navigator)
  • Enter the URL of this repository: https://github.com/mikeyclarke/NoCoderInitMacro.git
  • Choose "Up To Next Major Version": 1.0.0

Usage

Import the macro and then simply annotate any class that needs an init(coder:) with @NoCoderInit.

import NoCoderInitMacro

@NoCoderInit
class ViewController: PlatformViewController {
    init() {
        // …
    }
}

// Expands to:

class ViewController: PlatformViewController {
    init() {
        // …
    }

    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

Alternatives

There are various alternatives to adding the unimplemented initializer.

License

NoCoderInitMacro is available under the MIT license. See LICENSE for details.

About

A Swift Macro that adds an unimplemented init(coder:)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages