• Stars
    star
    717
  • Rank 63,167 (Top 2 %)
  • Language
    Swift
  • License
    MIT License
  • Created about 8 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Xcode Source Code Extension to Generate Swift Initializers

Swift Initializer Generator

This Xcode Source Code Extension will generate a Swift initializer based on the lines you've selected. Handy if you made a struct public and now you have to provide the initializer implementation yourself.

Usage

Select the lines with the attributes that should be included in the initializer. See below; > is the start of the selection and < is the end of the selection.

struct MyStruct {
>    public var a: String
    public var b: Int<
}

Run the extension's "Generate Swift Initializer". Voila! The code above is modified to:

struct MyStruct {
    public var a: String
    public var b: Int
    public init(a: String, b: Int) {
        self.a = a
        self.b = b
    }
}

Demo

Installation

  1. On OS X 10.11 El Capitan, run the following command and restart your Mac:

     sudo /usr/libexec/xpccachectl
    
  2. Open SwiftInitializerGenerator.xcodeproj

  3. Enable target signing for both the Application and the Source Code Extension using your own developer ID

  4. Product > Archive

  5. Right click archive > Show in Finder

  6. Right click archive > Show Package Contents

  7. Drag Swift Initializer Generator.app to your Applications folder

  8. Run Swift Initializer Generator.app and exit again.

  9. Go to System Preferences -> Extensions -> Xcode Source Editor and enable the extension

  10. The menu-item should now be available from Xcode's Editor menu.

Known limitations

It will only parse attributes defined like (open|public|fileprivate|private|internal) [weak] (var|let) NAME: TYPE.

More Repositories

1

HAP

Swift implementation of the Homekit Accessory Protocol
Swift
361
star
2

docx-mailmerge

Mail merge for Office Open XML (docx) files without the need for Microsoft Office Word.
Python
274
star
3

NetService

Swift NetService (Bonjour / Zeroconf / mDNS) implementation for Linux
Swift
117
star
4

DNS

Swift implementation of DNS Records / RR
Swift
63
star
5

SRP

Secure Remote Password (SRP) for Swift
Swift
53
star
6

Lark

Swift SOAP Client
Swift
53
star
7

Glob

Glob for Swift 5
Swift
25
star
8

django-federated-login

Django Federated Login provides an authentication bridge between Django projects and OpenID-enabled identity providers.
Python
19
star
9

django-airbrake

Django Airbrake provides a logging handler to push exceptions and other errors to airbrakeapp or other airbrake-compatible exception handler services (e.g. aTech Media's Codebase).
Python
17
star
10

INI

Swift INI parser based on (NS)Scanner
Swift
16
star
11

Swift-PriorityQueue

Binary heap implementation in Swift
Swift
15
star
12

pathfinding

A* pathfinding algorithm in Python using OSM data
Python
8
star
13

HKDF

HMAC-based Extract-and-Expand Key Derivation Function (HKDF) in Swift
Swift
7
star
14

My-Home

My DIY Homekit setup in Swift
Swift
7
star
15

Swift-Security

Proof of concept for accessing Keychain using Swift
Swift
6
star
16

NetService-Example

Swift
5
star
17

mvvm

Proof of concept Model-View-ViewModel implementation in Python
Python
4
star
18

Bignum

Swift big number library
Swift
4
star
19

CLibSodium

Swift overlay for libsodium
Swift
3
star
20

ncurses-example

Swift
3
star
21

SPA941-Google-Contact-Sync

PHP
2
star
22

Lark-Example

Example of Lark SOAP library written in Swift
Swift
2
star
23

hc-icy

ICE / Essent e-thermostaat client in Go
Go
1
star
24

spa-phone-api

Provides an API for Linksys/Sipura VoIP SPA Phones
Python
1
star
25

Cdns_sd

Swift C modulemap for dns_sd.h
Swift
1
star
26

hc-my-homekit

My DIY HomeKit / HomeControl accessories in Go
Go
1
star