A very technical error here and Google turned up nothing on this.
I am adding Cordova to a Swift Project.
I added a Bridging Header file and the Cordova build dependencies, and I did get autocomplete working (the Cordva CDV classes were auto-completing).
Everything was working fine until I suddenly got this error:
Attribute 'public' can only be used in a non-local scope
And my project just lit up with errors everywhere. Also tons of my functions stopped working.
Any suggestions as to what happened or what I could do to fix would be much appreciated
For future readers:
I agree with Nate Cook's analysis of the question, however my compiler was throwing this error because I was missing a curly brace (}
) higher up in the file. For example, the curly brace after the default statement in the switch is missing. In this case it would throw the error on the public var URLRequest: NSURLRequest
line:
public enum MyEnum: SomeProtocol {
var someVariable {
switch self {
case .first:
return something
default:
return default
}
// <------- needs brace here
public var URLRequest: NSURLRequest {
// Code here.
}
}
That error shows up when you have public
declared on a type that is nested inside a function or method—types declared in that context have only local scope, and thus can't be marked as public. Example:
func foo() {
public struct Bar {
}
}
// Attribute 'public' can only be used in a non-local scope
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With