Explore the various UI frameworks available for building app interfaces. Discuss the use cases for different frameworks, share best practices, and get help with specific framework-related questions.

Post

Replies

Boosts

Views

Activity

MacOS Statusbar App Input from Keyboard goes wrong
I have an StatusBar APP in Swift, under Sonoma the App works fine, after upgrade to Sequoia, i cant get the input from Keyboard inside the NSTextField, because the NSTextField shows the Focusring. The given input from keyboard, get every time to another window, like xcode, Safari or Desktop. depending on what was last active after I selected a menu item in the menu of the statusbar APP with a view or an NSAlert with an NSTextField. I have spent several hours with debug sessions, a KeyDown or KeyUP event from the keyboard does not arrive. As I said in Sonoma this was not a problem and the APP works as expected. To me this looks like a bug in Sequoia. But maybe someone here has an idea on this topic
1
0
257
Oct ’24
Hourly repeating notification.
Somebody help me please. I try to set specific time for notification, it works nice, but if you need a little beat more functional this is where difficulties appear. I'd like to give opportunities for repeat, example every hour. I know that UNCalendarNotificationTriger has a repeat value, but when you set repeat on true it remember date component, exp - .minute, and then just repeating notification every time when that minute comes! I'm looking for solution for set notification at special time(exp: 5:00 pm), and then repeating this notification every hour(6, 7, 8, 9 pm) Maybe it's so easy but looks like I feel stuck 😕
2
0
391
Oct ’24
Quick Look Extension does not load MapKit map properly anymore, after macOS Sequoia
It appears that starting with macOS Sequoia, Quick Look Preview extension no longer loads MapKit maps correctly anymore. Map tiles do not appear, leaving users with a beige background. Users report that polylines do render correctly, but annotations appears black. This was previously working fine in prior macOS versions including Sonoma. STEPS TO REPRODUCE Create a macOS app project, with an associated document. Ensure project has a Quick Look preview extension, with necessary basic setups. Ensure that the extension mentioned in (2) must have a MKMapView. Any other cosmetic changes, etc, does not need to be implemented to observe the base issue. Do note that it has been reported that in addition to the map tiles not loading, annotations don't render correctly as well.
1
1
530
Oct ’24
NSPersistentCloudkitContainer setup - merge behavior - contexts
Is it ok to use automaticallyMergesChangesFromParent to true for a managed object context that pins its query generation to current? I have heard from a few sources that in most cases, it’s not recommended to set automaticallyMergesChangesFromParent to true for a managed object context that pins its query generation to current. A source I have seen says: When you pin a managed object context to a specific query generation, you’re explicitly telling the context to view the data as it existed at the time of that generation token (often referred to as a snapshot). This ensures that the context is isolated from any subsequent changes made by other contexts or background tasks. But this may Conflict with Automatic Merging because: The purpose of setting automaticallyMergesChangesFromParent to true is to have the context automatically merge changes from the parent (e.g., background or main context) into itself whenever the parent context saves changes. This behavior conflicts with the concept of a pinned query generation because: • If the context is pinned to current, it should not be concerned with changes that happen after that pinning. • Automatic merging would introduce updates from the parent context that occur after the pinning, thereby violating the “snapshot” nature of the query generation and potentially creating inconsistencies. However, in your own Apple Sample Code Titled "" does use both together. Inside the definition of lazy var persistentContainer: NSPersistentCloudkitContainer the following code is included: // Pin the viewContext to the current generation token, and set it to keep itself up to date with local changes. container.viewContext.automaticallyMergesChangesFromParent = true do { try container.viewContext.setQueryGenerationFrom(.current) } catch { fatalError("###\(#function): Failed to pin viewContext to the current generation:\(error)") }
0
0
227
Oct ’24
Family Activity Picker crashes (Connection to plugin invalidated while in use)
Even on iOS 18 (16-17 also repo) we are seeing a crash on the FamilyActivityPicker when users tap on "Other" or just at random times. We see the follow debug message but no other way of identifying the issue in code. [u 3C8AF272-DC4E-55C4-B8C6-34826D2BEB5B:m (null)] [com.apple.FamilyControls.ActivityPickerExtension(1150.1)] Connection to plugin invalidated while in use. Even with the most basic implementation of FamilyActivityPicker (example below) we can repro this crash consistently. Big applications (think Opal) see the same issue but it seems like they see it less, and are able to intercept the disconnect in order to show an error to the user. My two questions are How can we intercept this crash/disconnect in order to alert our user and restart the experience? Is this EVER gonna get fixed properly? Usage Example: var body: some View { NavigationView { ZStack { familyPickerErrorView .opacity(isHidden ? 0 : 1) .onAppear { DispatchQueue.main.asyncAfter(deadline: .now() + 2) { withAnimation { isHidden = false } } } VStack { Color.clear .frame(height: 1) .background(Color(UIColor.systemBackground)) FamilyActivityPicker( headerText: "Select Apps To Be Blocked (Maximum of 50)", footerText: "Want to block Safari? Check our FAQs", selection: $familySelection) .ignoresSafeArea(.all) } } } .toolbar { ToolbarItem(placement: .navigationBarLeading) { Button(action: { isPresented = false }) { Text("Cancel") .foregroundColor(.black) } } ToolbarItem(placement: .navigationBarTrailing) { Button(action: { isPresented = false }) { Text("Done") } } } .navigationBarTitleDisplayMode(.inline) .alert(isPresented: $showAlert) { Alert(title: Text("Family Activity Picker Issue"), message: Text(alertMessage), dismissButton: .default(Text("OK"))) } .onAppear { isPresented = true } }
1
0
398
Oct ’24
UITextField doesn't apply `keyboardType` on tvOS because of `isSecureTextEntry`
Hello everyone, Recently, I have encountered an issue in my tvOS app where a specific property of UITextField, isSecureTextEntry, set to true, was preventing another property, keyboardType, from functioning correctly. In my case, keyboardType is set to numberPad option. The problem is that during the first tap on the text field, the default keyboard with numbers, letters, and some special characters opens. However, after the second tap, the correct keyboard type with only numbers appears as I want. Removing isSecureTextEntry or setting to false solves the problem. import UIKit class ViewController: UIViewController { private let textField = UITextField() override func viewDidLoad() { super.viewDidLoad() textField.keyboardType = .numberPad textField.isSecureTextEntry = true view.addSubview(textField) setupConstraints() } }
0
0
375
Oct ’24
Programmatically switch between "mirror" and "additional content" with windowExternalDisplayNonInteractive
I'd like to share an app's screen in two modes. First in a standard mirroring mode and second in an "additional content" mode (very likely with a session role windowExternalDisplayNonInteractive). I found that the Keynote app on iOS does a very nice example of what I want to achieve when sharing an iPhone using AirPlay to an AppleTV. sharing a screen results in mirroring the screen on the TV tapping the play button in Keynote switches to "additional content" where iPhone and TV show different content leaving the additional content mode returns to "mirroring" where TV and iPhone show the same content Is there an example for implementing such a feature? I am able to successfully use the external display (windowExternalDisplayNonInteractive) and show additional content there. How can I programmatically "detach" the additional content from the external display and activate mirroring mode? Searching the Developer Forums for windowExternalDisplayNonInteractive reveals some discussions, which include valuable information, however, returning to mirror mode does not seem to be covered.
1
0
286
Oct ’24
Can I increase the reliability of my app intent updating my widgets?
We have widgets in our app. We're now working on a Live Activitiy with a button calling an app intent. This app intent needs to update our Widgets, and we're seeing semi-great results. When we're updating the widgets from within the app, it works great. Also from geofence triggers it usually works, so we're thinking it might have to do with the "widget update budget"? According to the docs: Cases in which WidgetKit doesn’t count reloads against your widget’s budget include when: The widget performs an app intent, such as when the user taps a button or toggles a switch. But we're not really seeing that. When I run our app from within Xcode, everything runs great all the time and the widget gets updated within milliseconds, but when running the TestFlight version is more spotty. To be clear: This is a button in a live activity, calling an app intent, and in turn, the app intent is calling reloadAllTimelines for our "regular" widgets. The live activity itself always gets updated properly. My question is basically, am I doing something wrong and can I do something to increase the consistency of the widget updating on time? Abbreviated example: final class UserEventIntent: NSObject, LiveActivityIntent { @MainActor func perform() async throws -> some IntentResult { do { let newStatus: (stat: Status, wasSame: Bool) = try await eventHelper.performEvent(status: status) WidgetCenter.shared.reloadAllTimelines() }catch { await WidgetCenterBridge.updateLiveActivityForInProgress(false) } return .result() }
2
0
352
Oct ’24
Please HELP. - UIViewController dealloc bug. I need help!
Dear Senior Developer, I come to you at a time where I am lost. Over the last 2-3 months, I have noticed a series of crashes occuring on my app. This all started randomly and has now been a regular occurence. Usually, I would receive some detail as it relates to some class or view that is causing this error but now the only details I have is it relates to a UiViewController dealloc even though I am using SwiftUI. Below I have attached the stack trace from firebase crash analytics. I have spent months on this and I am asking for the help of someone much more senior and knowledable to assist me in this regard. Thanks again for your help and I await your response. I am also willing to share my screen LIVE to help you help me identify this issue. manny.GoblinTools_issue_bfd18ee65a92b459d4ecef3475a9ec34_crash_session_032166c28b8c4764b13a6fdca636d2d6_DNE_0_v2_stacktrace.txt
2
0
413
Oct ’24
PHPickerResult slow loading, plus no thumbnails
A very common use case in our iOS app is that users take a large number of pictures (about 30) in low-light conditions using the camera app, and immediately after, they try to upload them to our servers. We measured the time to load photos from the PHPickerResult. For most photos, it takes less than 100 milliseconds, but for some of them, it takes several seconds—we even saw minutes in some extreme cases. We believe this started happening with iOS 17, when deferred photo processing was introduced. If users take the pictures using our in-app camera experience, the options to customize the camera are enough to avoid the long waiting times. However, the majority of our users still prefer to take the photos with the camera app, and there is little we can do about that. In the past few weeks, we tried many combinations: Without asking for permissions, we tried loadFileRepresentation, loadData, and loadObject. We explored the PHImageManager route, asking permissions and with different options for deliveryMode, resizeMode, version, isSynchronous, and allowSecondaryDegradedImage. We also tried fetching the photos in parallel, with very bad results. In summary, nothing helped the long waiting times—minutes in some cases. The first question is then, is there anything we can do to ignore the post-processing of the photos and get them fast? We could accept the unprocessed images. At a minimum, we would like to show our users what we are doing and why we are taking so much time. We tried to load thumbnails with loadPreviewImage and put a progress indicator on top. This method consistently gives us an error for all photos: (lldb) p error.localizedDescription (String) "Cannot load preview." We can load thumbnails with the PHImageManager option, but it seems excessive to need to get permissions only for that. Second question would be then, what can we do to load thumbnails without asking for permission? I created a feedback report with a video and sample code to reproduce -> FB15493683
2
0
354
Oct ’24
Simulating Fn (Globe) + Arrow Key Events Ignoring Fn Modifier
I want to simulate the pressing of Fn (Globe) + Control + arrow keys combo, but I’m encountering an issue where the Fn modifier seems to be ignored, and the system behaves as if only Control + arrow keys are pressed. In macOS, the combination of Fn + Right Arrow (key code 124) is treated as End (key code 119), and even that didn’t have expected behavior. Instead of moving the window to the right edge of the screen on Sequoia, it switches to the next space, which is the default behavior for Control + Right Arrow. Demo: (I included Fn + Control + C to show that centering the window works for example.) import SwiftUI @main struct LittleKeypressDemo: App { var body: some Scene { Window("Keypress Demo", id: "keypress-demo") { ContentView() } .windowStyle(.hiddenTitleBar) .windowResizability(.contentSize) .windowBackgroundDragBehavior(.enabled) } } struct ContentView: View { var body: some View { VStack(spacing: 20) { KeyPressButton(icon: "arrowtriangle.right.fill", keyCode: 124) KeyPressButton(icon: "arrow.down.to.line", keyCode: 119) KeyPressButton(label: "C", keyCode: 8) } .padding() } } struct KeyPressButton: View { let icon: String? let label: String? let keyCode: CGKeyCode init(icon: String? = nil, label: String? = nil, keyCode: CGKeyCode) { self.icon = icon self.label = label self.keyCode = keyCode } var body: some View { Button(action: { simulateKeyPress(keyCode) }) { HStack { Image(systemName: "globe") Image(systemName: "control") if let icon = icon { Image(systemName: icon) } else if let label = label { Text(label) } } } .buttonStyle(.bordered) .controlSize(.large) } } func simulateKeyPress(_ keyCode: CGKeyCode) { let fnKey = VirtualKey(keyCode: 63, flags: .maskSecondaryFn) let controlKey = VirtualKey(keyCode: 59, flags: [.maskControl, .maskSecondaryFn]) let targetKey = VirtualKey(keyCode: keyCode, flags: [.maskControl, .maskSecondaryFn]) [fnKey, controlKey, targetKey].forEach { $0.pressAndRelease() } } struct VirtualKey { let keyCode: CGKeyCode let flags: CGEventFlags func pressAndRelease() { postKeyEvent(keyDown: true) postKeyEvent(keyDown: false) } private func postKeyEvent(keyDown: Bool) { guard let event = CGEvent(keyboardEventSource: nil, virtualKey: keyCode, keyDown: keyDown) else { return } event.flags = flags event.post(tap: .cghidEventTap) } } Expected behavior: Simulating the key combo Fn + Control + Right Arrow on macOS Sequoia should move the current window to the right half of the screen, instead of switching to the next desktop space. Questions: Is CGEventFlags.maskSecondaryFn enough to simulate the Fn key in combination with Control and the arrow keys? Are there alternative approaches or workarounds to correctly simulate this behavior? What’s the obvious thing I missing? (Btw., window management is completely irrelevant here. I’m specifically asking about simulating these key presses.) Any insights or suggestions would be greatly appreciated. Thank you.
4
2
553
Oct ’24
Wallpaper Api
Hey, I have an app that user selects wallpaper for iPhone. I want a feature that user can set wallpaper direct from app itself for lock screen and home screen not download the image and manually set the wallpaper. As my research there was a PhotoLibrary api that contains PLWallpaperImageViewController.h which allows you to set wallpaper directly. Thank You!
1
0
618
Oct ’24
Prevent Virtual Keyboard for iOS App run in macOS
I have a (pretty basic) app I have developed which essentially just opens a pre-defined website (via URL) in WebView. It operates nicely in iOS and almost exactly as expected when run on my M1 in macOS with the exception that in macOS it keeps popping up a grey bar which ... after some investigating ... I have determined appears to be the virtual keyboard. Pressing escape clears it however I am trying to find some way of preventing it from coming up in the first place when the app is run in macOS. Is there a (hopefully simple) solution either through code or some app setting for this?
0
0
284
Oct ’24
App crashes at launch on missing symbol AVPlayerView... except on first launch
I don't know what triggered this in a previously-running application I'm developing: When I have the build target set to "My Mac (designed for iPad)," I now must delete all the app's build materials under DerivedData to get the app to build and run exactly once. Cleaning isn't enough; I have to delete everything. On second launch, it will crash without even getting to the instantiation of the application class. None of my code executes. Also: If I then set my iPhone as the build target, the app will build and run repeatedly. If I then return to "My Mac (designed for iPad)," the app will again launch once and then crash on every subsequent launch. The crash is the same every time: dyld[3875]: Symbol not found: _OBJC_CLASS_$_AVPlayerView Referenced from: <D566512D-CAB4-3EA6-9B87-DBD15C6E71B3> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Debugger/libViewDebuggerSupport.dylib Expected in: <4C34313C-03AD-32EB-8722-8A77C64AB959> /System/iOSSupport/System/Library/Frameworks/AVKit.framework/Versions/A/AVKit Interestingly, I haven't found any similar online reports that mention this symbol. Has anyone seen this behavior before, where the crash only happens after the first run... and gets reset when you toggle the target type?
6
0
703
Oct ’24
Apple Maps Not responding to scrolling, zooming, or tap gestures on custom pins
Scrolling and zooming I have two apps that utilize the Apple Maps and since I updated my xcode to use IOS18, some of the functionalities have either been missing or glitching, and when I roll back to IOS17.5, everything seems to work fine. When I use MKMapView and use mapView.isZoomEnabled = true mapView.isScrollEnabled = true Scrolling and zooming is still not working on IOS18 but IOS17.5 works fine. Clicking on custom annotations When I press on a custom annotation I add to the MapView, the gesture is sometimes recognized and most of the times not recognized. If I have 20 annotations, there is a possibility only 2 of them respond to tap gestures. Below is how I define the annotation. Annotation("Pin", coordinate: CLLocationCoordinate2D(latitude: latitude, longitude: longitude), anchor: .bottom) { Button(action: {print ("Pressed annotation"){ CustomPin() } }
0
0
293
Oct ’24
How to skip library check in framework
I have build a framework name is HansTranslation.framework for iOS 18 only, because it is include Translation. My app is okay when I call this framework on iOS 18 device, but it is crash on iOS 17.6. below is error info: Symbol not found: _$s7SwiftUI4ViewP013_Translation_aB0E15translationTask_6actionQr0D00D7SessionC13C onfigurationVSg_yAIYactF Referenced from: <4E09A66F-7D9E-3793-A2D6-1BE167EAD3F5> /private/var/containers/Bundle/Application/90A1EF03-09DA-43B5-8946-8186CF9CC804/B uild SRT.app/Frameworks/HansTranslation.framework/HansTranslation (built for ios 18.0 which is newer than running OS) <8F146BA4-EBE8-32C5-9CD8-E30077AD8088> /System/Library/Frameworks/_Translation_SwiftUI. framework/_Translation_SwiftUI I known that iOS 17.6 is NOT include "Translation_SwiftUI. framework", so there is crash. I have notice that don't call this framework when iOS version less than iOS 18, my code control like API_AVAILABLE(ios(18.0)) or @available(iOS 18.0, *)). I try that set "Build Phases" -> Embed Framework -> Copy only when installing -> ON, it is okay on iOS 17.6, but it is not work on iOS 18. My framework in here: https://github.com/MingJieHan/HansTranslation My question that how to do? first way that change option for HansTranslation.framework, let it not link Translation_SwiftUI automatically, not success. second way that change my app option, let it not check library, I don't know how to do next step. please help me or give me some idea for those. Thanks.
1
0
275
Oct ’24
LinkPresentation startFetchingMetadata errors
I’m trying to use the Link Presentation app in my SwiftUI app. When I try to fetch metadata, I get quite a few errors in the console. Here’s a stripped down version of the code that causes errors: public struct URLMetadataLoader { public static func metadata(for url: URL) async -> LPLinkMetadata? { let metadataProvider = LPMetadataProvider() do { let metadata = try await metadataProvider.startFetchingMetadata(for: url) return metadata } catch { print("Failed to get metadata for URL: \(error.localizedDescription)") return nil } } } The errors I get on every call to fetch metadata are below. Thanks. Failed to resolve host network app id to config: bundleID: com.apple.WebKit.Networking instance ID: Optional([_EXExtensionInstanceIdentifier: 0501F943-B5B6-4F60-95B0-CDECFC2AE908]) Type: Error | Timestamp: 2024-10-07 12:17:36.877477-05:00 | Process: URLMetaDataMinimal | Library: ExtensionFoundation | Subsystem: com.apple.extensionkit | Category: default | TID: 0x1f1c18 Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "((target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.rendering AND target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.networking AND target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.webcontent))" UserInfo={NSLocalizedFailureReason=((target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.rendering AND target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.networking AND target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.webcontent))}> 0x12602cd80 - ProcessAssertion::acquireSync Failed to acquire RBS assertion 'XPCConnectionTerminationWatchdog' for process with PID=80284, error: (null) Failed to terminate process: Error Domain=com.apple.extensionKit.errorDomain Code=18 "(null)" UserInfo={NSUnderlyingError=0x600000c6fbd0 {Error Domain=RBSRequestErrorDomain Code=3 "No such process found" UserInfo={NSLocalizedFailureReason=No such process found}}} Failed to terminate process: Error Domain=com.apple.extensionKit.errorDomain Code=18 "(null)" UserInfo={NSUnderlyingError=0x600000c8cc60 {Error Domain=RBSRequestErrorDomain Code=3 "No such process found" UserInfo={NSLocalizedFailureReason=No such process found}}}
2
1
667
Oct ’24