Proof of concept for Xcode 8 source extensions; generate a Swift init from current selection
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Generates an init based on properties of a type.

Given a simple class Employee:

class Employee {
  let name: String
  let id: Int

Employee needs an init method, which is largely boilerplate. This project includes an Xcode editor extension to generate the initializer. It matches declarations of the form:

var {name}: {Type}
let {name}: {Type}

Highlight the properties of Employee and invoke the command by selecting Editor > Generate Swift Init > Generate Swift Init From Selection. The following code will be generated:

init(name: String, id: Int) { = name = id



Clone the repository. Run the GenerateSwiftInit target on your machine. You'll likely need to update code signing information.


A developer-signed mac app is included in the GenerateSwiftInit directory. It is compatible with macOS 10.12 and Xcode 8.

  1. Download and move it to your /Applications directory.
  2. Open System Preferences > Extensions
  3. Ensure the checkbox for GenerateSwiftInit is checked
  4. Restart Xcode