You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
structMyStruct{>publicvara:Stringpublicvarb:Int<}
Run the extension's "Generate Swift Initializer". Voila! The code above is modified to:
structMyStruct{publicvara:Stringpublicvarb:Intpublicinit(a:String, b:Int){self.a = a
self.b = b
}}
Installation
On OS X 10.11 El Capitan, run the following command and restart your Mac:
sudo /usr/libexec/xpccachectl
Open SwiftInitializerGenerator.xcodeproj
Enable target signing for both the Application and the Source Code Extension using your own developer ID
Product > Archive
Right click archive > Show in Finder
Right click archive > Show Package Contents
Drag Swift Initializer Generator.app to your Applications folder
Run Swift Initializer Generator.app and exit again.
Go to System Preferences -> Extensions -> Xcode Source Editor and enable the extension
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.
About
Xcode Source Code Extension to Generate Swift Initializers