Adding a widget target to your app
To add a widget to the LetsEat
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.1: Template Chooser window
- Name the extension
LetsEatWidget
and make sure the Include Configuration Intent check box is unticked. This is because this widget will not be user configurable. Click Finish. - Click Activate in the dialog box that appears. This will create a scheme for your widget that you can use to run it in the iOS simulator:
Figure 25.2: Activate Scheme dialog box
- Verify that LetsEatWidgetExtension scheme and...