Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bouke/swiftinitializergenerator
Xcode Source Code Extension to Generate Swift Initializers
https://github.com/bouke/swiftinitializergenerator
code-generator swift swift-initializer xcode-extension
Last synced: 11 days ago
JSON representation
Xcode Source Code Extension to Generate Swift Initializers
- Host: GitHub
- URL: https://github.com/bouke/swiftinitializergenerator
- Owner: Bouke
- License: mit
- Created: 2016-09-11T09:31:33.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-08-13T05:41:04.000Z (over 5 years ago)
- Last Synced: 2024-10-12T07:28:40.333Z (about 1 month ago)
- Topics: code-generator, swift, swift-initializer, xcode-extension
- Language: Swift
- Homepage:
- Size: 1.36 MB
- Stars: 718
- Watchers: 11
- Forks: 31
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
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.
```swift
struct MyStruct {
> public var a: String
public var b: Int<
}
```
Run the extension's "Generate Swift Initializer". Voila! The code above is modified to:
```swift
struct MyStruct {
public var a: String
public var b: Int
public init(a: String, b: Int) {
self.a = a
self.b = b
}
}
```
![Demo](docs/demo.gif)Installation
------------1. On OS X 10.11 El Capitan, run the following command and restart your Mac:
sudo /usr/libexec/xpccachectl
1. Open ``SwiftInitializerGenerator.xcodeproj``
1. Enable target signing for both the Application and the Source Code Extension using your own developer ID
1. Product > Archive
1. Right click archive > Show in Finder
1. Right click archive > Show Package Contents
1. Drag ``Swift Initializer Generator.app`` to your Applications folder
1. Run ``Swift Initializer Generator.app`` and exit again.
1. Go to System Preferences -> Extensions -> Xcode Source Editor and enable the extension
1. 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``.