Resources – Building iOS 14 Widgets

Hi there! 👋🏼 I just created a widget for my Bhagavad Gita Interpretation App.

This widget shows the latest Bookmark helping the user to continue reading the book. I am currently testing the widget and would release it soon.🤞🏽

In my quest of learning about the Widgets, I collected a list of links that were helpful to me along the way. I always do this for every topic that I learn and this time decided to publish the list so that it would help anyone building a widget.

  • Apple documentation for Widgets:
    • A complete working example of how to add a Widget, adding configuration details, timeline entries, placeholder widget, adding content, adding dynamic content, responding to user interactions & having a widget bundle.
  • Getting Started With Widgets: A Complete Working Example!
    • Shows how to define a Widget
    • Creates an App Group for sharing data using a file in sharedContainerURL. 
    • Shows how to create App Group Entitlements
    • Shows how to access the Container
    • How to write to a contents file & read from it. And then how to use that data to show on the UI
    • Enabling User Customization. Using Intents.
  • Sharing data with a Widget:
    • Talks bout App Groups: To share data between different targets on the same device you add them to an App Group.
    • Shows how to create App Group Entitlements
    • Shows how to access the Container
    • Talks about “What about sharing Core Data?”
      • If you need to move a Core Data store to the container use the migratePersistentStore method of NSPersistentStoreCoordinator.
      • Do you need to use Core Data with a widget? You might be better off keeping it simple. A widget is not interactive and shows a small amount of information. My preference would be to extract the data you need in the main App and share it as a simple plist or JSON file to the widget.
  • Receive sub link from widget in App Delegate:
    • Answer mention – “inside my custom class I had added the property “.widgetURL”, as soon as I removed it the “Link” works correctly, and the App delegate method application:openURL:options:  start to work”
  • Link widget to specific UITableViewCell :
    • One of the answers says – “I ended up using Universal URL, to open my app when the widget is clicked and go to the tableviewcell that correlates to the URL.”
    • Developer Tools Engineer ’s below answer : 
func tableView(_: UITableView, didSelectRowAt indexPath: IndexPath) { 
                let selectedRowData = rowData[indexPath.row] // rowData is the array of objects you’re displaying
  • WidgetKit deep link:
    • An answer from Frameworks Engineer  saying how to open the main app part when for the main app UIApplicationDelegate is used
    • The answer is “When your widget gets tapped your app should be passed the URL, if you support scenes your scene delegate should get a scene(_:openURLContexts:) call, otherwise your application delegate should get an application(_:open: options:) call.”
  • WidgetCenter APIs to reload your timeline:
    • WidgetCenter.shared.reloadAllTimelines()
    • WidgetCenter.shared.reloadTimelines(ofKind: “WidgetKind”) : preferred since it will only reload the timelines of a specific widget.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create your website with
Get started
%d bloggers like this: