Post

Replies

Boosts

Views

Activity

Can a Widget post a Local Notification?
My guess is no... but, I have to ask. I made a widget that checks our GitHub repository for new pull requests - in an attempt to make sure PRs are addressed quicker. It works great - using GitHub's API. It's on my iPhone's Lock Screen. It definitely keeps me more on top of our pull requests! Our product manager asked if we could also send a local notification when there's a new PR. I was thinking maybe from the widget - it's updating around every 15 minutes - and if there's a new PR - then maybe it could fire a local notification. However, there's the permissions. The user has to say "OK" to them. Widget can't do that. Can it inherit the notification permissions from the parent app? Anyway - I think it is way overkill - I mean we have a widget! Why a notification as well!?!?!? I thought I'd ask... Thanks, Scott iOS 17.
2
0
656
Jan ’24
Swift Package Manager "platforms" and Watch OS
I'm working on an app and want to include a Watch target. My app uses Swift Package Manager and 1 package (that I created) for doing repetitive utilities such as showing a "Loading..." view (in iOS only) The Swift Package Package has supported platforms set to: platforms: [ .iOS(.v14) ] However, when I try to start editing my Watch OS SwiftUI ContentView, the preview errors out stating: iOS storyboards do not support target device type "watch". (This is from the Swift Package's Loading.storyboard.) The Swift Package is UIKit only - no Swift UI. The "Loading..." view I am using for iOS is a View Controller - obviously not meant for Watch OS. I cannot run the target to the Watch app - it shows a lot of UIKit errors from the Swift Package, like Cannot find type 'UIView' in scope and on and on. The Watch app does not need this package at all. I thought that if the platforms does not specify .watchOS* then it wouldn't try to apply it to my Watch target. How do I tell this target not to link/load this package?
1
0
1k
Jun ’23
Custom presentation container for UIDatePicker.inline triggered by UIDatePicker.compact
I prototyped using the UIDatePicker (in UIKit) for a designer. Out of the box, it works well without a lot of code: The UI/UX designer was wondering if we could mimic how Apple's Calendar app displays the calendars: Where the Inline calendar appears to expand into a cell filling the bounds. I don't see how to control the frame or how the Calendar can be "told" where it is displayed? Can this be done? (iOS 15+) Thanks, Scott
2
0
665
May ’23
Accessibility Trait or Hint for "Radio Buttons"
I know "radio buttons" are not a standard iOS UI element, but this is what we have from our UX team. They are technically UIButtons, but I don't feel it is correct to have the trait == .button. Because if a user using VoiceOver taps it, and hears "Pickup, Button, Selected" - they might assume if they double tap on it, then, as a button, it should do something. But it won't do anything, because it is already selected. And since it is a Radio Button, it doesn't unselect when an action is applied. There is no trait for "Radio Button". Is trait .button the right way to go? Thanks, Scott
2
0
2.0k
Oct ’22
SwiftUI Preview not working in a large project
In a large project that I am working on, SwiftUI Previews do not work. (Xcode 13.4, iOS 15) You can make the simplest of SwiftUI files - like: import SwiftUI struct TestView: View {     var body: some View {         Text("Hello, World!")     } } struct TestView_Previews: PreviewProvider {     static var previews: some View {         TestView()     } } And the Canvas will only show: "Automatic preview updating pauses when the previewed file is edited in a way that causes the containing module to be rebuilt." I've tried Resume, Refresh Canvas, Deleting Derived Data - but we just can't seem to get it to work. Any ideas? Thanks in advance, Scott
4
0
1.6k
Aug ’22
Overuse of DispatchQueue.main.async?
I have code that I inherited - and there is very liberal use of DispatchQueue.main.async because they were concerned the UI code there wasn't on the main thread - but it already was on the main queue. The bug I saw, was that if the calling code was already on the main thread, and the function they called also called the DispatchQueue.main.async, it seems like that call was delayed/not-called, and being requeued on the run loop for the next call. Here's kind of a general - very stripped down - version of what I was experiencing:     var result = 1     override func viewDidLoad() {         super.viewDidLoad()         DispatchQueue.main.async {             print("Before : result = \(self.result)")             self.doStuff()             print("After  : result = \(self.result)")         }     }     func doStuff() {         self.result += 1         self.doStuff2()     }     func doStuff2() {         DispatchQueue.main.async {             self.result += 1             self.doStuff3()         }     }     func doStuff3() {         result += 1     } } The output is: Before : result = 1 After  : result = 2 So it enters doStuff2() but that function also calls DispatchQueue.main.async - and therefore, that code never gets executed. I cleaned it up by removing these extraneous calls - but it took A LONG TIME tracking all of them down. Is there any better way to debug this? Also - they said this code worked in iOS 12. Thanks, Scott
3
0
2.4k
Jul ’22