Adding a widget target to your app
To add a widget to the JRNL
project, you’ll use the Widget Extension template. This template contains all the code necessary to display a widget on the Home screen, set up the initial view for that widget, and launch the app when the widget is tapped. Follow these steps:
- Choose File | New | Target to open the template selector.
- iOS should already be selected. In the Application Extension section, click Widget Extension and click Next:
Figure 25.2: Template Chooser window
- Name the extension
JRNLWidget
and make sure the Include Configuration App Intent check box is unchecked. This is because this widget is not required to be user configurable. Uncheck the Include Live Activity check box as well, as you won’t be using Live Activities. Click Finish. - Click Activate in the dialog box that appears. This will create a scheme for your widget that you can use to run the widget in Simulator: ...