-
Notifications
You must be signed in to change notification settings - Fork 74
Cannot declare a public var in an extension with internal requirements #124
Comments
I already see this issue. We put public for some case your controller come from a framework? the code which produce the code if isCurrentModule {
// Accessors for view controllers defined in the current module should be "internal".
output += " var storyboardIdentifier: \(os.storyboardSceneIdentifierType)? { return \(initIdentifierString) }\n"
} else {
// Accessors for view controllers in external modules (whether system or custom frameworks), should be marked public.
output += " public var storyboardIdentifier: \(os.storyboardSceneIdentifierType)? { return \(initIdentifierString) }\n"
} with var isCurrentModule = false
if let customModule = viewController.customModule {
isCurrentModule = !storyboardCustomModules.contains(customModule)
} |
Interesting, no idea why some of my controllers had the "Inherit Module From Target" checkbox unchecked, but checking it has fixed the issue. Thanks! Regardless though, it would be good if Natalie could somehow handle this a bit more gracefully if possible, rather than causing compile errors? I don't really understand the details though, so of course this might not be possible. |
I came across this error few days ago too. I may be totally wrong on this but...
It masked the issue by turning off public modifier but the real problem is that Natalie generates type constrained extension for the internal type: public protocol IdentifiableProtocol: Equatable {
var storyboardIdentifier: String? { get }
}
...
protocol ViewControllerIdentifiableProtocol: IdentifiableProtocol { }
extension ViewController: ViewControllerIdentifiableProtocol { }
extension IdentifiableProtocol where Self: ViewController {
public var storyboardIdentifier: String? { return "ViewController" }
static var storyboardIdentifier: String? { return "ViewController" }
} IdentifiableProtocol declared as public and by saying "Cannot declare a public var in an extension with internal requirements" Swift probably means that you cannot have default implementation of IdentifiableProtocol with public access modifiers unless the type (ViewController) in the type constraint for the extension (where Self: ViewController) is also made public. I'm not sure how to fix this and whether this situation avoidable at the Natalie level. Obviously declaring all view controllers and their methods public because of this error isn't a best fix. |
I am getting a build issue in my generated output file. The issue is with this code:
Specifically the public var. The exact error is: Cannot declare a
public var
in an extension with internal requirementsThis is the relevant class:
Strangely I don't have this issue in another project, the public keyword is not present. Am I doing something wrong or is this an issue with Natalie?
The text was updated successfully, but these errors were encountered: