Today we’ll quickly explore the difference between the public
and open
keywords in Swift.
In short, we use open
when we’re working on a module that at some point will be imported in a different module and overridden.
For example, when you’re developing your own reusable UI element and want to distribute it using CocoaPods, you may consider using the open
keyword to let others override the behavior of your library. With public
, you may simply import the framework, but you can’t override it.
Without a further ado, let’s get started.
Say we’re creating our own UI element, and we want it to be reusable and independent. So we create a new target in our existing project, like so:
Next, we choose Static Library in the drop-down:
#mobile #xcode #ios #swift #programming