widgetkit

Perform a deeplink from SwiftUI widget on tap

心已入冬 提交于 2020-12-26 07:23:24
问题 I have a simple widget (medium-sized) with two texts, and what I want is to be able to perform a deep link to lead the user to a specific section of my app, but I can't seem to find a way to do so. The view I have written (which is very simple): HStack { Text("FIRST ITEM") Spacer() Text("SECOND ITEM") } I have already tried to replace Text("SECOND ITEM") with Link("SECOND ITEM destination: URL(string: myDeeplinkUrl)!) but it doesn't work either. 回答1: In the Widget view you need to create a

Fetching current location in iOS 14 Widget

喜夏-厌秋 提交于 2020-12-25 04:02:48
问题 Has anyone tried to update user's location in iOS 14 Widget? After reading Apple Developer forums I've come up with the writing wrapper around CLLocationManager and using it this way: class WidgetLocationManager: NSObject, CLLocationManagerDelegate { var locationManager: CLLocationManager? { didSet { self.locationManager!.delegate = self } } private var handler: ((CLLocation) -> Void)? func fetchLocation(handler: @escaping (CLLocation) -> Void) { self.handler = handler self.locationManager!

Fetch data from CoreData for iOS 14 widget

浪尽此生 提交于 2020-12-22 06:26:20
问题 I want to display data fetched from Core Data in a widget. But @FetchRequest doesn’t work on widgets. As I understand, we have to create an app group and make a shared persistent container. What I want to know is how to read (fetch) data on widgets from that shared persistent container or simply, how to display data fetched from Core Data in widgets . 回答1: First you need to create an AppGroup which will be used to create a Core Data Persistent Container (here is a good explanation how to do

Fetch data from CoreData for iOS 14 widget

若如初见. 提交于 2020-12-22 06:26:13
问题 I want to display data fetched from Core Data in a widget. But @FetchRequest doesn’t work on widgets. As I understand, we have to create an app group and make a shared persistent container. What I want to know is how to read (fetch) data on widgets from that shared persistent container or simply, how to display data fetched from Core Data in widgets . 回答1: First you need to create an AppGroup which will be used to create a Core Data Persistent Container (here is a good explanation how to do

WidgetCenter not found in scope

青春壹個敷衍的年華 提交于 2020-12-08 15:34:52
问题 I'm building an iOS app for iOS 10+. The app builds fine in Debug configuration, but in Release fails to compile swift source code that references WidgetCenter . It outputs the error Cannot find WidgetCenter in scope even though I'm importing WidgetKit and optionally embedding the framework. import Foundation import WidgetKit class MyWidgetCenter: NSObject { @available(iOS 14, *) func reloadTimelines(_ kind: String) { // this line causes error: cannot find 'WidgetCenter' in scope WidgetCenter

WidgetCenter not found in scope

左心房为你撑大大i 提交于 2020-12-08 15:33:28
问题 I'm building an iOS app for iOS 10+. The app builds fine in Debug configuration, but in Release fails to compile swift source code that references WidgetCenter . It outputs the error Cannot find WidgetCenter in scope even though I'm importing WidgetKit and optionally embedding the framework. import Foundation import WidgetKit class MyWidgetCenter: NSObject { @available(iOS 14, *) func reloadTimelines(_ kind: String) { // this line causes error: cannot find 'WidgetCenter' in scope WidgetCenter

WidgetCenter not found in scope

主宰稳场 提交于 2020-12-08 15:33:06
问题 I'm building an iOS app for iOS 10+. The app builds fine in Debug configuration, but in Release fails to compile swift source code that references WidgetCenter . It outputs the error Cannot find WidgetCenter in scope even though I'm importing WidgetKit and optionally embedding the framework. import Foundation import WidgetKit class MyWidgetCenter: NSObject { @available(iOS 14, *) func reloadTimelines(_ kind: String) { // this line causes error: cannot find 'WidgetCenter' in scope WidgetCenter

Why do some views appear as a red no entry sign in widgets?

你说的曾经没有我的故事 提交于 2020-12-04 15:58:04
问题 I've created a project in xcode 12 and added a Widget Extension target. The target is created and I'm left with a simple widget that shows the time. The preview of the widget works as expected and the widget is shown as expected in the simulator. But if I change the view to use List instead of Text , like this: struct SimpleWidgetEntryView : View { var entry: Provider.Entry var body: some View { List { Text("Something") } } } The preview and the simulator both show a red No Entry sign on a

iOS 14 Widgets + SwiftUI + Firebase?

空扰寡人 提交于 2020-12-01 10:42:10
问题 I'm still pretty new to SwiftUI and Firebase. Recently, as a hobby, I have been developing an app for my school. After the launch of Xcode 12, I decided to experiment with the new features such as Widgets. However, since my app gets its data from Firebase, I've been having some problems. My most recent problem is this "Thread 1: "Failed to get FirebaseApp instance. Please call FirebaseApp.configure() before using Firestore". I'm not entirely sure where to put "FirebaseApp.configure()" as

iOS 14 Widgets + SwiftUI + Firebase?

一笑奈何 提交于 2020-12-01 10:42:08
问题 I'm still pretty new to SwiftUI and Firebase. Recently, as a hobby, I have been developing an app for my school. After the launch of Xcode 12, I decided to experiment with the new features such as Widgets. However, since my app gets its data from Firebase, I've been having some problems. My most recent problem is this "Thread 1: "Failed to get FirebaseApp instance. Please call FirebaseApp.configure() before using Firestore". I'm not entirely sure where to put "FirebaseApp.configure()" as