-1

I create a framework using swift, and then I create a test project to check if the framework goes well.

The framework has two classfile named "pubUtils" and "utils".

In my test project, I can only use the public class PubUtils. I cannot use the Utils class, because it cannot find it. And the method in the PubUtils must be public if I want to use them. I donnot know it is that Apple design or something I make mistakes.

  • See related: [Swift, access modifiers and unit testing](http://stackoverflow.com/questions/24994593/swift-access-modifiers-and-unit-testing) – rintaro Nov 27 '14 at 09:54

1 Answers1

1

Yes. Only classes/method with the public access level will be visible to the external world. That is to restrict others from using your internal classes/methods. The default access level is internal which means which will be accessible within the same target/module.private access level has even little visibility. This is how the access control mechanism in swift works.

In your case, if you want some other source files to use your framework classes, make them as public. Each framework is considered as separate module.

Read more about: Access control

Anil Varghese
  • 42,757
  • 9
  • 93
  • 110