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.

Posts under General subtopic

Post

Replies

Boosts

Views

Activity

chartXAxis AxisMark consisting of Month:Year
I have a Chart displaying Counts per Date over 2-3 years. I'd like to have the XAxis mark consist of MM-yy or even MM/nyy. Is this possible? OK, just saw AxisValueLabel(format: .dateTime.month().year()) which gives e.g. Mar 2024. This is good. Better might be Mar 24 (maybe a Y3K problem ;-) or even better Mar. OR Mar 24. 2024 Or best increment the year when it changes. Are any of these alternate formats possible? Thanks, David PS, my current .chartXAxis code .chartXAxis { AxisMarks(values: .stride(by: .month, count: 3)) { value in if value.as(Date.self) != nil { AxisValueLabel(format: .dateTime.month().year()) AxisGridLine() AxisTick() } } }
1
0
82
Jun ’25
openURL:options:completionHandler: Not Opening tel:// Link on iPad with Cellular Data
We are using openURL:options:completionHandler: to open a tel:// number in the dialer to place a call. This works on iPhones and WiFi-only iPads (tested with a iPad Mini 6th Gen), but it is failing to open on an iPad 8th Gen (WiFi + Cellular) running iPadOS 18.5 being used by a customer. Prior to updating the iPad to iPadOS 18, the call worked on iPadOS 15.2 and opened the call in FaceTime as expected. Despite not opening the dialer in iPadOS 18, the completionHandler returns the success parameter as true. canOpenUrl also returns true. We created a small test application that reproduces the issue using the code snippet below in a new application, with the tel schema added to the info.plist Queried URL Schemes. We are currently using Xcode 16.3. Test Steps: Create a new blank application and replace ContentView.swift with the code snippet below Run the test app on a physical iPad 8th Gen (WiFi + Cellular) Tap the "place a test call" button Expected Results: The user is prompted to call the number and is taken to FaceTime to attempt the call. The user may then receive an alert telling them an iPhone must be paired if not already. Alternatively: return success = false in the completionHandler. Actual Results: No action occurs that is visible to the user, and the completionHandler returns success = true. Separately, we should be able to have some method of checking if the device can actually complete a call, i.e. if an iPhone is paired, so that we can correctly show or hide a phone icon in the app based on if the user can place a call. canOpenUrl returns true even if there is not a device paired and the call cannot actually be placed, and there doesn't seem to be a proper method for making that check. Code Snippet: import SwiftUI struct ContentView: View { @State private var showAlert = false var body: some View { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundStyle(.tint) Text("Hello, world!") Button("Place a test call") { if let url = URL(string: "tel://5555554567") { UIApplication.shared.open(url) { success in if success { print("Call initiated successfully.") } else { showAlert = true } } } } } .padding() .alert("Call Failed", isPresented: $showAlert) { Button("OK") { showAlert = false } } message: { Text("The call could not be initiated.") } } } #Preview { ContentView() }
0
1
120
Jun ’25
CATiledLayer flashes and re-draws entirely when re-drawing a single tile
I have filed a bug report for this (FB17734946), but I'm posting it here verbatim in case others have the same issue and in hopes of getting attention from an Apple engineer sooner. When calling setNeedsDisplayInRect on a CATiledLayer - or a UIView whose backing layer is CATiledLayer - one would expect to re-draw only a region identified by the rect passed to the method. This is even written in the documentation for the class: "Regions of the layer may be invalidated using the setNeedsDisplayInRect: method however the update will be asynchronous. While the next display update will most likely not contain the updated content, a future update will." However, upon calling this method, CATiledLayer redraws whole contents instead of just the tile at the specified rect, and it flashes when doing so. It behaves exactly the same as if one had called setNeedsDisplay without passing any rect; all contents are cleared and re-drawn again. I'm 100% sure I've passed in the correct rect of the exact tile that I need to redraw. I have even tried passing much smaller rects, but still the same. (And yes, the rect I've passed accounts for the current level of detail.) I have found this GitHub repo https://github.com/frankus/NetPhotoScroller, which based on discussion from here https://forums.macrumors.com/threads/catiledlayer-blanks-out-tiles-when-redrawing.1333948/ aims at solving these issues by using two private methods on CATiledLayer class: (void)setNeedsDisplayInRect:(CGRect)r levelOfDetail:(int)level; (BOOL)canDrawRect:(CGRect)rect levelOfDetail:(int)level; I have explored the repo in detail, however I wasn't able to test exactly this code from the GitHub repo. I have tried using those two private methods myself (through an Objective-C class that defines the methods in the header file and then a swift class which inherits it), but I couldn't solve the issue; the flashing and the full re-draw is still there. After doing a lot of research, the conclusion seems to be that one cannot use CATiledLayer with contents that are downloaded remotely, on demand, as tiles are being requested. I have, however, found one interesting thing which seems to work so far: before calling setNeedsDisplayInRect (or just setNeedsDisplay, as they behave the same for CATiledLayer in my testing), cache the current layer's contents, and after calling setNeedsDisplay (or setNeedsDisplayInRect), restore the contents back to the layer. This prevents flashing and preserves any tiles that were drawn at the time of the re-draw. let c = tiledLayer.contents tiledLayer.setNeedsDisplay(tileRect) tiledLayer.contents = c However! Docs clearly state the warning: Do not attempt to directly modify the contents property of a CATiledLayer object. Doing so disables the ability of a tiled layer to asynchronously provide tiled content, effectively turning the layer into a regular CALayer object. I believe this message implies modifying the contents property with some raw content, like image data, and that it may be safe to re-apply the existing contents (which are in my testing of type CAImageProvider) -- but I can't rely on an implementation detail in my production app. I have tested this and confirmed that the bug appears on: iPhone 14 Pro, iOS 18.5 iPhone 13 Pro, iOS 17.5.1 iPhone 5s, iOS 15.8.3 iPad Pro 1st gen, iPadOS 18.4.1 a couple simulator versions I can also confirm that the fix (to re-apply contents property) is also working properly on all these versions. Is this expected behavior, that tiled layer redraws itself entirely instead of redrawing specific tiles? Is it safe to modify contents of a CATiledLayer by re-applying the existing contents? If not, is there an alternative to avoid flashing?
3
0
103
May ’25
AVAudioSession dropping wired USBAudio source
My app inputs electrical waveforms from an IV485B39 2 channel USB device using an AVAudioSession. Before attempting to acquire data I make sure the input device is available as follows: AVAudiosSession *audioSession = [AVAudioSession sharedInstance]; [audioSession setCategory :AVAudioSessionCategoryRecord error:&err]; NSArray *inputs = [audioSession availableInputs]; I have been using this code for about 10 years. My app is scriptable so a user can acquire data from the IV485B29 multiple times with various parameter settings (sampling rates and sample duration). Recently the scripts have been failing to complete and what I have notice that when it fails the list of available inputs is missing the USBAudio input. While debugging I have noticed that when working properly the list of inputs includes both the internal microphone as well as the USBAudio device as shown below. VIB_TimeSeriesViewController:***Available inputs = ( "<AVAudioSessionPortDescription: 0x11584c7d0, type = MicrophoneBuiltIn; name = iPad Microphone; UID = Built-In Microphone; selectedDataSource = Front>", "<AVAudioSessionPortDescription: 0x11584cae0, type = USBAudio; name = 485B39 200095708064650803073200616; UID = AppleUSBAudioEngine:Digiducer.com :485B39 200095708064650803073200616:000957 200095708064650803073200616:1; selectedDataSource = (null)>" ) But when it fails I only see the built in microphone. VIB_TimeSeriesViewController:***Available inputs = ( "<AVAudioSessionPortDescription: 0x11584cef0, type = MicrophoneBuiltIn; name = iPad Microphone; UID = Built-In Microphone; selectedDataSource = Front>" ) If I only see the built in microphone I immediately repeat the three lines of code and most of the "inputs" contains both the internal microphone and the USBAudioDevice AVAudiosSession *audioSession = [AVAudioSession sharedInstance]; [audioSession setCategory :AVAudioSessionCategoryRecord error:&err]; NSArray *inputs = [audioSession availableInputs]; This fix always works on my M2 iPadPro and my iPhone 14 but some of my customers have older devices and even with 3 tries they still get faults about 1 in 10 tries. I rolled back my code to a released version from about 12 months ago where I know we never had this problem and compiled it against the current libraries and the problem still exists. I assume this is a problem caused by a change in the AVAudioSession framework libraries. I need to find a way to work around the issue or get the library fixed.
0
0
51
May ’25
The URL authorization read and write obtained by UIDocumentPickerViewController
The URL directory obtained by UIDocumentPickerVieweController can be read and written in the directory after calling startAccessingDecurityScopeResource. However, after restarting the app, if the URL saved in the package is called startAccessingDecurityScopeResource again and returns NO, UIDocumentPickerVieweController must be called again to retrieve the URL, and then startAccessingDecurityScopeResource must be called again before continuing the operation. This is too troublesome. Is there a way to continue reading and writing operations in the URL directory after restarting the app?
1
0
41
May ’25
Crash when minimizing on external display and unplugging it (iOS App on Mac)
Our iOS app, when running as an iOS App on Mac, crashes consistently under the following scenario: 1. Launch the app on an external display. 2. Minimize the app window. 3. Disconnect the external display. The app crashes every time under these conditions. The crash log shows the following call stack: *** Assertion failure in -[UINSWorkspace _maximumContentSizeForWindowOnScreen:], UINSWorkspace.m:401 -[UINSWorkspace _maximumContentSizeForWindowOnScreen:]: screen parameter should not be nil ( 0 CoreFoundation 0x000000018e841df0 __exceptionPreprocess + 176 1 libobjc.A.dylib 0x000000018e306b60 objc_exception_throw + 88 2 Foundation 0x000000018fb6aa78 -[NSCalendarDate initWithCoder:] + 0 3 UIKitMacHelper 0x00000001a9a59110 -[UINSWorkspace _maximumContentSizeForWindowOnScreen:] + 184 4 UIKitMacHelper 0x00000001a9a3e748 -[UINSSceneViewController _usableScreenSizeWithSceneSize:shouldOverride:] + 412 5 UIKitMacHelper 0x00000001a9a3d55c -[UINSSceneViewController _effectiveScaleFactorForLayoutWithOverride:] + 88 6 UIKitMacHelper 0x00000001a9a3f3a8 -[UINSSceneViewController _updateZoomFactors] + 28 7 UIKitMacHelper 0x00000001a9a3f248 -[UINSSceneViewController _updateZoomFactorsAndDoLayout] + 24 8 UIKitMacHelper 0x00000001a9a3df80 -[UINSSceneViewController _doUpdates:] + 104 9 UIKitMacHelper 0x00000001a99ad460 -[UINSSceneViewController observeValueForKeyPath:ofObject:change:context:] + 176 10 Foundation 0x000000018facb0d8 -[NSKeyValueObservance observeValueForKeyPath:ofObject:change:context:] + 388 11 Foundation 0x000000018facb0d8 -[NSKeyValueObservance observeValueForKeyPath:ofObject:change:context:] + 388 12 Foundation 0x000000018fa8f7b4 NSKeyValueNotifyObserver + 252 13 Foundation 0x000000018fb3c560 NSKeyValueDidChange + 388 14 Foundation 0x00000001903149a0 NSKeyValueDidChangeWithPerThreadPendingNotifications + 160 15 AppKit 0x00000001924673d4 -[NSThemeFrame _didChangeContentLayoutRect] + 76 16 AppKit 0x000000019246521c -[NSWindow _oldPlaceWindow:fromServer:] + 744 ) It seems like the system attempts to access a screen object that is already nil after the external monitor is removed. This leads to an assertion failure in UINSWorkspace. Is there any known workaround or update planned to address this issue? Thank you.
2
0
60
May ’25
ARKit Camera Feed Zoom & Macro Support for Close-Range Objects
I am currently developing an AR experience using ARKit with SceneKit and am looking to implement functionality that enables: Zooming into the AR camera feed, ideally leveraging the ultra-wide or telephoto lenses available on supported devices. Macro-style focus capabilities, allowing users to view and interact with virtual content closely aligned with small or nearby real-world objects (within a few centimeters). My objective is to ensure that ARKit continues to render the scene accurately while enabling a zoomed-in view or macro-level focus for better detail visibility and alignment. Could you please advise on: Whether ARKit currently supports camera zoom or allows access to macro or ultra-wide cameras within an ARSession. Limitations or considerations when using multi-camera setups in conjunction with ARKit. Any guidance or references to documentation or sample code would be greatly appreciated.
0
0
80
May ’25
Regarding ARKit camera feed zoom and macro support for closer object
I am currently developing an AR experience using ARKit with SceneKit and am looking to implement functionality that enables: Zooming into the AR camera feed, ideally leveraging the ultra-wide or telephoto lenses available on supported devices. Macro-style focus capabilities, allowing users to view and interact with virtual content closely aligned with small or nearby real-world objects (within a few centimeters). My objective is to ensure that ARKit continues to render the scene accurately while enabling a zoomed-in view or macro-level focus for better detail visibility and alignment. Could you please advise on: Whether ARKit currently supports camera zoom or allows access to macro or ultra-wide cameras within an ARSession. Limitations or considerations when using multi-camera setups in conjunction with ARKit. Any guidance or references to documentation or sample code would be greatly appreciated. Best regards, Ayush
0
0
59
May ’25
Dock tile plugin and app groups
In one of my apps I use an app group to share data between the app and a command line tool. This works as expected. The app also contains a Dock Tile plugin and I wonder if there's a way to access the group container from this plugin? Thanks in advance for your help. Best regards, Marc
5
0
378
May ’25
ssue with Session Sharing Between Safari and ASWebAuthenticationSession
We are experiencing an issue with session sharing on iOS and would appreciate your guidance. We operate and control our own OpenID Connect (OIDC) server. Our iOS application uses ASWebAuthenticationSession to authenticate users. We're unable to get the authentication session to be shared between the Safari app and the app's ASWebAuthenticationSession. This results in users having to re-authenticate despite being logged in via Safari. We've attempted various configurations related to cookie SameSite settings. These adjustments resolved the session sharing issue on Android using Chrome Custom Tabs. However, no changes we've tried have enabled session sharing to work as expected on iOS. According to documentation from Apple, Microsoft, Okta, and Auth0, session sharing between Safari and ASWebAuthenticationSession should work. Question: Are there any additional settings, configurations, or platform limitations we should be aware of that could impact session sharing on iOS? Where else can we look to resolve this issue?
Topic: UI Frameworks SubTopic: General
0
0
63
May ’25
Opening FileDocument with URL → should only be called in the main thread
Its document says openDocument can open a document at a specific URL. So I've saved a model as a JSON object with its URL and a bookmark as Data. With its security-scoped bookmark data resolved, I am able to open a document except that the app will crash right after opening a document. Console says should only be called in the main thread struct ContentView: View { @EnvironmentObject var bookmarkViewModel: BookmarkViewModel var body: some View { VStack { } .onAppear { loadBookmarks() } } extension ContentView { func loadBookmarks() { print("1 \(Thread.current)") // NSMainThread Task { for bookmarkItem in bookmarkViewModel.bookmarkItems { // resolving a security-scoped bookmark print("2 \(Thread.current)") // NSMainThread if let _ = resolveBookmark(bookmarkData: bookmarkItem.bookmarkData) { print("3 \(Thread.current)") // NSMainThread do { print("4 \(Thread.current)") // NSMainThread try await openDocument(at: bookmarkItem.bookmarkURL) print("5 \(Thread.current)") // NSMainThread } catch { print("\(error.localizedDescription)") } } } } } } Well, the application is on the main thread. I've checked every line before and after opening a document with its URL. Call what on the main thread? This is confusing. Thanks. class BookmarkViewModel: ObservableObject { @Published var bookmarkItems: [BookmarkItem] = [] var defaultFileManager: FileManager { return FileManager.default } var documentURL: URL? { ... } init() { fetchBookmarkItems() } func fetchBookmarkItems() { bookmarkItems.removeAll() if let documentURL { let bookmarkFolderURL = documentURL.appending(path: "MyApp").appending(path: "Bookmarks") do { let contents = try defaultFileManager.contentsOfDirectory(atPath: bookmarkFolderURL.path) for content in contents { ... let fileURL = bookmarkFolderURL.appending(path: content) let data = try Data(contentsOf: fileURL) let bookmarkItem = try JSONDecoder().decode(BookmarkItem.self, from: data) bookmarkItems.append(bookmarkItem) } } catch { print("Error fetching folder content: \(error.localizedDescription)") } } } } struct BookmarkItem: Codable, Hashable { let bookmarkURL: URL let date: Date let bookmarkData: Data let open: Bool }
4
0
84
May ’25
Best Way to Help Users Diagnose iOS App Crashes with No UI Feedback
Hi all, We're working on an iOS application and would like to improve our ability to diagnose failures - especially in scenarios where the app crashes before it can present any UI to the user. A few specific questions: In case of an exception or crash, is there a way to log the issue so the user (or our support team) can understand the cause of the failure? If the app crashes abruptly (e.g., due to a runtime exception or crash during launch), is there a recommended way to persist error information before the process terminates? Are there Apple-supported mechanisms (like crash reporting tools or APIs) we can integrate that would help us capture such issues? What’s the best practice for enabling support teams to assist users based on crash reports - especially for crashes that happen before any user interaction? Our goal is to make sure users aren't left in the dark if the app fails to start, and to allow us to deliver timely updates or support based on the cause of the crash. Thanks in advance for your guidance!
Topic: UI Frameworks SubTopic: General Tags:
0
0
70
May ’25
AppIntent complie issue & manual remove AppIntent dialog
1.When I attempted to open the subsequent AppIntent within the perform method of the AppIntent instance, I always received the following error: How to solve the problems of inconsistency of this type? I couldn't find any sample code. 2.When I used method 'Button(intent: OpenAppIntent())' to open my app through the dialog custom view of AppIntent, but I couldn't find a way to close this AppIntent dialog. How can i remove this dialog?
Topic: UI Frameworks SubTopic: General
2
0
58
May ’25
CPGridTemplate in CPTabBarTemplate: Second Item Not Selecting in CarPlay Simulator
I am experiencing an issue while using CPGridTemplate within CPTabBarTemplate in my CarPlay app running in the simulator. On app launch, when I select the second item in the grid, it does not visually reflect as selected in the UI. This behavior is unexpected, as the grid item selection should update accordingly. Has anyone encountered this issue or found a solution to ensure proper item selection?
1
0
32
May ’25
CPTabBarTemplate in CarPlay Simulator: Tab Becomes Inactive on Re-selection
I am facing an issue in my CarPlay app using CPTabBarTemplate. The app has two tabs, and on launch, the first tab is correctly selected. However, when I tap on the first tab again, instead of staying active, it becomes inactive. This behavior is unexpected, as re-selecting the active tab should typically maintain its selected state. Has anyone else encountered this issue or found a workaround to prevent the tab from becoming inactive?
0
0
33
May ’25