Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add public init to style struct #59

Merged
merged 1 commit into from
Aug 26, 2020
Merged

Add public init to style struct #59

merged 1 commit into from
Aug 26, 2020

Conversation

voltec
Copy link
Contributor

@voltec voltec commented Aug 18, 2020

added public init method

added public init method
@styrken
Copy link
Collaborator

styrken commented Aug 18, 2020

What issue does this PR solve ?

@voltec
Copy link
Contributor Author

voltec commented Aug 19, 2020

What issue does this PR solve ?
I can't use the init method in swift package dependencies because it's not public.

@styrken
Copy link
Collaborator

styrken commented Aug 19, 2020

Okay, I though structs created the inits automatically but that might not be case when imported as a package?

@voltec
Copy link
Contributor Author

voltec commented Aug 19, 2020

Okay, I though structs created the inits automatically but that might not be case when imported as a package?

I only see public methods and variables:

public struct PartialSheetStyle {
    public enum PartialSheetBackground {
        case solid(Color)
        case blur(UIBlurEffect.Style)
    }
}

extension PartialSheetStyle {
    public static func defaultStyle() -> PartialSheet.PartialSheetStyle
}

@styrken
Copy link
Collaborator

styrken commented Aug 19, 2020

Yes but the compiler creates the init for you?

https://docs.swift.org/swift-book/LanguageGuide/Initialization.html#ID213

(See Memberwise Initializers for Structure Types)

@jtrespalacios
Copy link

I'm also running into this issue when using this package, not able to init PartialSheetStyle from application code

@styrken
Copy link
Collaborator

styrken commented Aug 25, 2020

Okay, i will have a look

@styrken styrken changed the title Update PartialSheetStyle.swift Add public init to style struct Aug 26, 2020
@1337domz
Copy link
Contributor

Unfortuantly the default for a Struct memberwise initializer is 'internal':

https://docs.swift.org/swift-book/LanguageGuide/AccessControl.html

The default memberwise initializer for a structure type is considered private if any of the structure’s stored properties are private. Likewise, if any of the structure’s stored properties are file private, the initializer is file private. Otherwise, the initializer has an access level of internal.

As with the default initializer above, if you want a public structure type to be initializable with a memberwise initializer when used in another module, you must provide a public memberwise initializer yourself as part of the type’s definition.

@styrken
Copy link
Collaborator

styrken commented Aug 26, 2020

Thanks for the clarification. I will be merging the PR shortly.

@styrken styrken merged commit 1e89905 into AndreaMiotto:master Aug 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'PartialSheetStyle' initializer is inaccessible due to 'internal' protection level
4 participants