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 then click Next:
- Name the extension
LetsEatWidget
and make sure the Include Configuration Intent checkbox is unticked. 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:
- Verify that the LetsEatWidgetExtension scheme and iPhone SE (2nd generation) are selected in the Scheme menu: