Adding a widget
Widgets operate and live outside of our app, therefor they are considered to be an extension of our app.
To add a new widget – we need to a new Widget Extension target by selecting File -> New -> Target….
Then, in the Choose a template for your new target window, we search for a widget and add the widget extension (see Figure 5.1):
Figure 5.1: The Choose a template for your new target window
After clicking on Next, we should provide a name for our widget, just like any target we add. In addition, uncheck the Include Configuration App Intent checkbox.
Once the widget is added, we can see a new target with the name we provided. Xcode creates a few files for us as part of the widget template (assuming that the target name is MyWidget
):
MyWidgetBundle
– The widget bundle is a container for the different widgets our extension holds. Currently, we have only one widget, but it is possible to add more...