1. Create New Project

2. Add App Extension Target

3. Setup UI for Widget

For the widget it’s a UILabel that named as lbl_main.

4. Enable App Groups for both targets

Go to capabilities on each targets: Main App target and Extensions Target. Turn on ‘App Groups’, then hit ‘+’ button, add text like ‘group.com.yourcompany.app’ or for this project we use ‘group.com.irekasoft.P-Today-Widget’ for both targets.

5. Create a Shared File

Create a new file called SharedFile.swift to share the common string that shared between targets so that we can avoid making mistake on using different key value.