Post

Replies

Boosts

Views

Activity

WeatherKit does not work on Simulators
WeatherKit seems to work fine when I deploy a debug build on a real device, but whenever I try to deploy on a simulator, I get the following errors: 2022-09-13 17:51:56.118325-0400 Widget Wizard[63356:284415] [AuthService] Failed to generate jwt token for: com.apple.weatherkit.authservice with error: Error Domain=AMSErrorDomain Code=12 "Mescal Failed" UserInfo={NSLocalizedDescription=Mescal Failed, NSLocalizedFailureReason=SAPInit failed: -42049} 2022-09-13 17:51:56.119297-0400 Widget Wizard[63356:284415] [WeatherService] Encountered an error when fetching weather data subset; location=<+43.65320000,-79.38320000> +/- 5.00m (speed -1.00 mps / course -1.00) @ 9/13/22, 5:51:55 PM Eastern Daylight Time, error=Error Domain=AMSErrorDomain Code=12 "Mescal Failed" UserInfo={NSLocalizedDescription=Mescal Failed, NSLocalizedFailureReason=SAPInit failed: -42049} WeatherKitProvider.getWeather error Optional(<+43.65320000,-79.38320000> +/- 5.00m (speed -1.00 mps / course -1.00) @ 9/13/22, 5:51:55 PM Eastern Daylight Time) Mescal Failed I have confirmed that everything is configured correctly in terms of certificates and profiles. It just doesn't work on any simulator. It seems a number of people on Twitter are having the same issues.
4
5
1.4k
Sep ’22
Calendar List is empty after authorization
I'm having issues with EventKit. Before requesting any data from EventKit, I request auth access to reminders and calendar. In the App Sandbox configuration, I've checked off Reminders. After requesting access, I call reset() on the EKEventStore I created. The first time after access is approved, a call to "store.calendars(for: .event)" returns zero results (calls to "store.predicateForEvents" WILL return results). If I force quit the app and launch it again, I get results for "store.calendars(for: .event)" What am I missing here? What's weird is, before all this started happening, everything was working correctly without the store.reset() call - even the calendars were getting returned. However, I accidentally deleted my App's Target and had to recreate it. Since recreating the build target, I was NOT getting results for "store.predicateForEvents" until I called "store.reset()" after authorization was granted. But I still can't get the calendar list after first launch.
1
0
1.2k
Sep ’20
My widgets appear with a Placeholder view in the Widget Gallery
I have multiple widgets in my application, and they all appear as the "placeholder" view. In my snapshot code (shown below), the information is returned in less than a second. I even tried using sample data rather than retrieving the data from HealthKit (the commented out code). In fact, you can briefly see the data show up in Widget Gallery in a video I took, before it switches to the placeholder view. (For some reason the forums aren't allowing me to link to the video) Any idea what's going on? public func snapshot(for configuration: HealthStatTypeSelectionIntent, in context: Context, completion: @escaping (HealthEntry) -> ()) { print("HealthWidget.snapshot ") let entry = HealthEntry(date: Date(), stat: HealthStat(type: .steps) ) completion(entry) // HealthKitHelper.shared.getStats(for: .steps) { stat in // let entry = HealthEntry(date: Date(), stat: stat ) // completion(entry) // // } }
4
0
3.5k
Aug ’20
onAppear is called when the view hasn't appeared
I'm using a 100% SwiftUI app, currently on Xcode 12 Beta 4 In my ContentView, I have a simple TabView struct ContentView: View { &#9;&#9;var body: some View { TabView { AgendaView() .tabItem { Image(systemName: "list.bullet") Text("Agenda") } HealthView() .tabItem { Image(systemName: "heart") Text("Health") } } &#9;&#9;} } The AgendaView and HealthView have onAppear methods. On App launch, the AgendaView is the one visible, but onAppear is called for both AgendaView and HealthView. Why is that? Shouldn't onAppear be called only when the view actually appears on screen? Code for HealthView and AgendaView struct AgendaView: View { &#9;&#9;var body: some View { VStack { Text("Hello, AgendaView!") }.onAppear{ print("AgendaView.onAppear") }.onDisappear(){ print("AgendaView.onDisappear") } &#9;&#9;} } struct HealthView: View { &#9;&#9;var body: some View { VStack { Text("Hello, HealthView!") }.onAppear{ print("HealthView.onAppear") }.onDisappear(){ print("HealthView.onDisappear") } &#9;&#9;} }
26
3
15k
Aug ’20
Handling a user tapping on a Siri IntentsUI to go to the correct view in app when the app is terminated / NOT in the background
I have a Siri Intent that displays a simple UI. When the user taps on it, the app is launched. When the app is in the background, I use the following code in the Scene Delegate to capture what the user did and take the user to the right view. It works as expected. &#9;&#9;&#9;&#9;func scene(_ scene: UIScene, continue userActivity: NSUserActivity) { &#9;&#9;&#9;&#9;&#9;&#9;print("CONTINUE USER ACTIVITY") &#9;&#9;&#9;&#9;&#9;&#9;guard let intent = userActivity.interaction?.intent as? WasteWizardIntent else { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;print("AppDelegate: WasteWizardIntent - FALSE") &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;//return false &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;return &#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;print("AppDelegate: WasteWizardIntent - TRUE") &#9;&#9;&#9;&#9;&#9;&#9;print(intent) &#9;&#9;&#9;&#9;&#9;&#9;appState.selectedTab = .wastewizard &#9;&#9;&#9;&#9;&#9;&#9;appState.deepLinkActionSheet = true &#9;&#9;&#9;&#9;&#9;&#9;appState.deepLinkString = intent.garbage! &#9;&#9;&#9;&#9;&#9;&#9;//contentView.wasteWizard.viewModel.goToWasteItem(for: intent.garbage!) &#9;&#9;&#9;&#9;} However, I can't figure out what to do when the app is launched when it is NOT in the background. My understanding is that UIScene.ConnectionOptions should be populated, but it's empty. In the SceneDelegate scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) method. When I put a breakpoint, the userActvity, intent and handoffUserActivityType are all nil. &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;let window = UIWindow(windowScene: windowScene) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;window.rootViewController = UIHostingController(rootView: contentView) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;RootAlerter.shared.rootViewController = window.rootViewController &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;self.window = window &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;window.makeKeyAndVisible() &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;let userActivity = connectionOptions.userActivities &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;let string = connectionOptions.handoffUserActivityType &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;let intent = userActivity?.interaction?.intent as? WasteWizardIntent &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;print("handoff type \(connectionOptions.handoffUserActivityType)") &#9;&#9;&#9;&#9;} I also tried the following methods but they never get called: &#9;&#9;&#9;&#9;func scene(_ scene: UIScene, didUpdate userActivity: NSUserActivity) &#9;&#9;&#9;&#9;func scene(_ scene: UIScene, willContinueUserActivityWithType userActivityType: String) Also tried this in the AppDelegate:
2
0
1.1k
Jun ’20