Reputation: 9140
I'm trying to build a iOS framework but at the moment I'm trying to import the framework I'm getting this error:
This is implementation of my framework:
public protocol myframeWorkDelegate{
func doSomething(value:Int)
}
public class myframeWork{
public var delegate:myframeWorkDelegate? = nil
public func doingSomething(do:String){
}
}
Any of you knows why I'm getting this error?
I'll really appreciate your help.
Upvotes: 1
Views: 87
Reputation: 726987
This happens because you named your variable the name of your class. Swift compiler starts using the name of your variable right away, and decides that you are trying to read the value inside its own initializer, as in
var someVariable : String = someVariable
Of course, you are not doing this, so Swift compiler could distinguish between the two uses of myframeWork
identifier in the declaration, at least theoretically. However, they decided it is not worth the trouble.
Renaming the variable or the class will fix this problem. You may also need to provide a public initializer for your class in order for the modified code to compile.
Upvotes: 1
Reputation: 7361
Change the name of your var
. The error is because the name of the class is the same as the name of the variable. Additionally, this is why you should always capitalize class names ie class MyFramework
versus var myFramework
.
Upvotes: 1