I created a simply Swift Package
with one UI class
in it.
I managed to upload to a repo and use it in a project.
First time when I tried to import it and use it in a main project there was a problem with access modifiers because my package
was not public
but defined as class MainView: UIView {}
.
After I've changed my package to public class MainView: UIView {}
it worked well.
My question:
Isn't the package like any other of my project classes? Why is supposed to be used with public
?
Is there any way to use my package classes without the public access modifier
?
CodePudding user response:
The default access modifier is "internal" which indicates that it's within the project itself. A Swift package (framework) is a 3rd party "project" that you implement nested inside your project. Which means you are trying to reach code from another project.
TL;DR, No you can not skip using public access modifiers if you want to reach the functionality