Bouke / SwiftInitializerGenerator

Xcode Source Code Extension to Generate Swift Initializers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot Initialize `private` properties.

keyhoffman opened this issue · comments

The extension works great! However, when you try to initialize private properties, you get the following error:

"The operation couldn't be completed. (Generate_Swift_Initializer.SourceEditorCommand.Error error 3)"

After looking at the source code, it seems that the error is coming from this line at the beginning of the perform function.

"guard invocation.buffer.contentUTI == "public.swift-source" else {
return completionHandler(Error.notSwiftLanguage)
}"

At the moment, only public or internal properties are supported. See also the last line of the README:

It will only parse attributes defined like (public|internal) (var|let) NAME: TYPE.

However it should be rather easy to add other access modifiers.

Thanks for the quick response! Do you have plans to add this functionality?

I've made some changes in 4c73493. Feel free to send in additional patches if the extension comes in handy.