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

Inquiry: Checking User’s Large App Icon Mode Setting on iOS 18
I am writing to inquire if there is any way to programmatically check whether a user has enabled the “Large App Icon” mode in iOS 18. Our development team is working on optimizing our app’s user interface, and it would be beneficial to adapt the design based on this setting. Any guidance on how to access this information, or if it’s even possible within the current iOS APIs, would be greatly appreciated. Thank you for your time and assistance.
1
0
214
Aug ’24
Crash in -[NSLayoutConstraint setConstant:] + 96 (NSLayoutConstraint.m:750)
Hello, I've noticed a few rare crashes with the following stacktrace reported on AppStore connect: Hardware Model: iPhone16,2 AppStoreTools: 15F31e AppVariant: 1:iPhone16,2:17.4 OS Version: iPhone OS 17.5.1 (21F90) Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Termination Reason: SIGNAL 6 Abort trap: 6 Terminating Process: <App> [15575] Triggered by Thread: 0 Last Exception Backtrace: 0 CoreFoundation 0x1a3d38f20 __exceptionPreprocess + 164 (NSException.m:249) 1 libobjc.A.dylib 0x19bbbe018 objc_exception_throw + 60 (objc-exception.mm:356) 2 Foundation 0x1a323f868 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 188 (NSException.m:252) 3 CoreAutoLayout 0x1c4eabcc8 -[NSLayoutConstraint _setSymbolicConstant:constant:symbolicConstantMultiplier:] + 552 (NSLayoutConstraint.m:669) 4 CoreAutoLayout 0x1c4eab674 -[NSLayoutConstraint setConstant:] + 96 (NSLayoutConstraint.m:750) 5 <App> 0x10486d578 closure #1 in BaseChatTableViewCell.requestPreview(for:with:) + 540 (BaseChatTableViewCell+File.swift:162) 6 <App> 0x10486d73c thunk for @escaping @callee_guaranteed (@in_guaranteed URLRequest, @guaranteed NSHTTPURLResponse?, @guaranteed UIImage) -> () + 164 (<compiler-generated>:0) 7 <App> 0x104c4f814 __85-[UIImageView(AFNetworking) setImageWithURLRequest:placeholderImage:success:failure:]_block_invoke + 176 (UIImageView+AFNetworking.m:118) 8 <App> 0x104c3cc74 __78-[AFImageDownloader downloadImageForURLRequest:withReceiptID:success:failure:]_block_invoke.88 + 52 (AFImageDownloader.m:276) 9 libdispatch.dylib 0x1abbdc13c _dispatch_call_block_and_release + 32 (init.c:1530) 10 libdispatch.dylib 0x1abbdddd4 _dispatch_client_callout + 20 (object.m:576) 11 libdispatch.dylib 0x1abbec5a4 _dispatch_main_queue_drain + 988 (queue.c:7898) 12 libdispatch.dylib 0x1abbec1b8 _dispatch_main_queue_callback_4CF + 44 (queue.c:8058) 13 CoreFoundation 0x1a3d0b710 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16 (CFRunLoop.c:1780) 14 CoreFoundation 0x1a3d08914 __CFRunLoopRun + 1996 (CFRunLoop.c:3149) 15 CoreFoundation 0x1a3d07cd8 CFRunLoopRunSpecific + 608 (CFRunLoop.c:3420) 16 GraphicsServices 0x1e8bb81a8 GSEventRunModal + 164 (GSEvent.c:2196) 17 UIKitCore 0x1a634090c -[UIApplication _run] + 888 (UIApplication.m:3713) 18 UIKitCore 0x1a63f49d0 UIApplicationMain + 340 (UIApplication.m:5303) 19 <App> 0x1047c6c20 main + 80 (main.m:11) 20 dyld 0x1c73b9e4c start + 2240 (dyldMain.cpp:1298) It crashes on the last line of let previewSize = BaseChatTableViewCell.getPreviewSize(from: imageSize, isMediaFile) self.filePreviewImageViewHeightConstraint?.constant = previewSize.height self.filePreviewImageViewWidthConstraint?.constant = previewSize.width where previewSize is a CGSize. I am unable to reproduce the crash, nor am I able to understand why it crashes there. Anyone got an idea what could cause a crash on setting a constant?
1
0
217
Aug ’24
PDFKit deletes certificates on document load
Why does PDFKit delete signature widgets that have already been digitally signed? This should not happen. Is there an undocumented flag that needs to be set so that PDFKit doesn't remove them when loading or saving the PDF? It's difficult to tell if it is happening at PDFDocument(url: fileURL) or document.write(to: outputURL) If a document is signed and still allows annotations, form filling, comments, etc. we should be able to load the PDF into a PDFDocument and save it without losing the certs. Instead the certs are gone and only the signature annotation widgets are present. Here is a simple example of loading and then saving the PDF with out any changes and it shows that the data is actually being changed... ... import UIKit import PDFKit class ViewController: UIViewController { var pdfView: PDFView! @IBOutlet weak var myButton: UIButton! override func viewDidLoad() { super.viewDidLoad() pdfView = PDFView(frame: self.view.bounds) pdfView.autoresizingMask = [.flexibleWidth, .flexibleHeight] self.view.addSubview(pdfView) self.view.bringSubviewToFront(myButton) // Load and compare the PDF data if let originalData = loadPDF() { if let loadedData = getRawDataFromLoadedPDF() { let isDataEqual = comparePDFData(originalData, loadedData) print("Is original data equal to loaded data? \(isDataEqual)") } } } @IBAction func onSave(_ sender: Any) { if let savedData = savePDF() { if let originalData = loadPDF() { let isDataEqual = comparePDFData(originalData, savedData) print("Is original data equal to saved data? \(isDataEqual)") } } } func loadPDF() -&gt; Data? { guard let fileURL = Bundle.main.url(forResource: "document", withExtension: "pdf") else { print("Error: document.pdf not found in bundle.") return nil } do { let originalData = try Data(contentsOf: fileURL) if let document = PDFDocument(url: fileURL) { pdfView.document = document print("PDF loaded successfully.") return originalData } else { print("Error: Unable to load PDF document.") return nil } } catch { print("Error reading PDF data: \(error)") return nil } } func getRawDataFromLoadedPDF() -&gt; Data? { guard let document = pdfView.document else { print("Error: No document is currently loaded in pdfView.") return nil } if let data = document.dataRepresentation() { return data } else { print("Error: Unable to get raw data from loaded PDF document.") return nil } } func comparePDFData(_ data1: Data, _ data2: Data) -&gt; Bool { return data1 == data2 } func savePDF() -&gt; Data? { guard let document = pdfView.document else { print("Error: No document is currently loaded in pdfView.") return nil } let fileManager = FileManager.default let urls = fileManager.urls(for: .documentDirectory, in: .userDomainMask) guard let documentsURL = urls.first else { print("Error: Could not find the documents directory.") return nil } let outputURL = documentsURL.appendingPathComponent("document_out.pdf") if document.write(to: outputURL) { print("PDF saved successfully to \(outputURL.path)") do { let savedData = try Data(contentsOf: outputURL) return savedData } catch { print("Error reading saved PDF data: \(error)") return nil } } else { print("Error: Unable to save PDF document.") return nil } } }
1
1
299
Jul ’24
Sequoia Beta 15.1
I went to update to Apple Intelligence Beta 15.1 on Sequoia yesterday when it dropped, and I’m still waitlisted. The weird thing is, I had it on my Mac within a few minutes after downloading the beta, but then restarted the Mac and it now says “joined waitlist” and still does today.
1
0
564
Jul ’24
WidgetKit widgets crashing on iOS 18 beta 5
My app’s WidgetKit widgets are all crashing on iOS 18 beta 5. They were working just fine on earlier betas. This is happening across both Home and Lock Screen widgets. It's an EXC_BAD_ACCESS crash that seems to be happening deep within WidgetKit. I've seen other developers posting about this on social media, so it's not just me. Wanted to get this flagged ASAP as it's very late in the beta cycle now... Filed as FB14684253.
2
3
394
Aug ’24
If you select a character in the content of PFDView using PDfkit with a long press, the Editmenu is displayed too late.
It's the same as the title, and when I checked the log, there were hundreds to thousands of lines with the following content. The larger the page index of the Pdf from which you select letters, the more logs will be recorded. .notdef: no mapping. .notdef: no mapping. .notdef: no mapping. .notdef: no mapping. .notdef: no mapping. .notdef: no mapping. . . . can't create CMap Adobe-KR1-UCS2'. can't create CMap Adobe-KR1-UCS2'. can't create CMap Adobe-KR1-UCS2'. can't create CMap Adobe-KR1-UCS2'. can't create CMap Adobe-KR1-UCS2'. can't create CMap Adobe-Identity-UCS2'. can't create CMap Adobe-KR1-UCS2'. can't create CMap Adobe-KR1-UCS2'. can't create CMap Adobe-Identity-UCS2'. can't create CMap Adobe-Identity-UCS2'. can't create CMap `Adobe-Identity-UCS2'. I don't know why this is happening. Is there a solution?
0
0
264
Aug ’24
Supporting AdaptiveImageGlyph copying & pasting
I am currently running iOS 18 Beta 3 and am working on enabling users to paste (and copy) custom emojis (AdaptiveImageGlyph, such as Memoji, Stickers, and soon GenMoji) into a text field. I am looking for the UTI for AdaptiveImageGlyph—something similar to "public.adaptive-image-glyph". Does anyone know if such a UTI exists? Here’s my situation: When typing AdaptiveImageGlyph using the System keyboard, everything functions correctly. However, if I copy some text containing AdaptiveImageGlyph from the Notes app and paste it into my playground app, it only pastes the text. The reverse is also true. In fact, if I copy some AdaptiveImageGlyph from the playground app and paste it, it only pasts the text. Interestingly, copying AdaptiveImageGlyph from the Notes app and pasting it into iMessage works flawlessly, and vice versa. I am trying to achieve the same seamless functionality in my app. Given that this feature works in iMessage and Notes, I am inclined to believe the issue might be on my side, though I recognize these are system apps and not third-party. Example Code: import SwiftUI import UIKit struct AdaptiveImageGlyphTextView: UIViewRepresentable { class Coordinator: NSObject, UITextViewDelegate { var parent: AdaptiveImageGlyphTextView init(parent: AdaptiveImageGlyphTextView) { self.parent = parent } func textViewDidChange(_ textView: UITextView) { parent.text = textView.text } func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { // Handle insertion of adaptive image glyphs here if needed return true } } @Binding var text: String func makeCoordinator() -> Coordinator { Coordinator(parent: self) } func makeUIView(context: Context) -> UITextView { let textView = UITextView() textView.delegate = context.coordinator textView.supportsAdaptiveImageGlyph = true textView.isEditable = true textView.isSelectable = true textView.font = UIFont.systemFont(ofSize: 17) // Enable paste with NSAdaptiveImageGlyphs textView.pasteConfiguration = UIPasteConfiguration(acceptableTypeIdentifiers: [ "public.text", "public.image", "public.adaptive-image-glyph" // Replace with the correct UTI if different ]) return textView } func updateUIView(_ uiView: UITextView, context: Context) { if uiView.text != text { uiView.text = text } } } struct ContentView: View { @State private var text: String = "" var body: some View { AdaptiveImageGlyphTextView(text: $text) .frame(height: 200) .padding() } } #Preview { ContentView() }
2
0
446
Jul ’24
Issue with getting pushToStartTokenUpdates without creating a Live Activity
I'm trying to develop a Live Activity Extension. The problem is, I can't get pushToStartToken. I'm able to get it when I start a Live Activity, but I can't when I don't start a Live Activity. This function successfully generates the token: private func startNewLiveActivity() async { guard #available(iOS 16.2, *) else { return } let attributes = MyWidgetAttributes( homeTeam: "Badger", awayTeam: "Lion", date: "12/09/2023" ) let initialContentState = ActivityContent( state: MyWidgetAttributes.ContentState( homeTeamScore: 0, awayTeamScore: 0, lastEvent: "Match Start" ), staleDate: nil ) guard let activity = try? Activity.request( attributes: attributes, content: initialContentState, pushType: .token ) else { return } if #available(iOS 17.2, *) { Task { for await data in Activity< MyWidgetAttributes>.pushToStartTokenUpdates { let token = data.map { String(format: "%02x", $0) }.joined() // THE DESIRED pushToStartToken TOKEN IS GENERATED HERE } } } for await data in activity.pushTokenUpdates { let token = data.map { String(format: "%02x", $0) }.joined() // I send token to server here. } } But when I try to get pushToStartToken separately, without creating a live activity, it doesn't return any value: private func getPushToStartToken() async { guard #available(iOS 17.2, *) else { return } Task { for await data in Activity<MyWidgetAttributes>.pushToStartTokenUpdates { let token = data.map { String(format: "%02x", $0) }.joined() // THIS DOESN'T GENERATE ANY TOKENS SINCE THE ACTIVITY IS NOT CREATED } } }
0
0
322
Aug ’24
How to get pushTokenUpdates when starting a Live Activity via Push Notification
I'm trying to build a Live Activity extension. I can successfully start my live activity via push notification. The problem is, when I start live activity from my app, I can get pushTokenUpdates since I control everything and run the for loop that gets pushTokenUpdates. But the code that gets pushTokenUpdates isn't called when I start live activity with push notification since system starts it automatically (maybe it is called, but I don't know when and where). Where am I supposed to get pushTokenUpdates when I start Live Activity using push notification to send them to my server? The relevant code is below: for await data in activity.pushTokenUpdates { let token = data.map { String(format: "%02x", $0) }.joined() Logger().log("Activity token: \(token)") // send token to the server }
1
2
287
Aug ’24
App Clip unavailable
Hello my appclip is showing as unavailable in the app clip card. Until earlier this afternoon my appclip experience was showing correctly with an open action. All of a sudden it started to fail. I did not submit a new version nor updated the association file. To reproduce scan qr.netflix.com/C/123
1
0
356
Jul ’24
App clip default URL working great, but my associated domain url, although valid, is not launching my app clip
Good news bad news. Good news- I have built my first app clip! After getting our app submission accepted, it gave us a working "default app clip url" in which successfully launches our app clip card and app clip. Bad news- All this work was done to associate our app clip link with our website, so we could have a very clean URL, but that url is not launching our app clip card or the clip. Everything points to it looking good: Diagnostics on apple developer settings are all green checkmarks: associated domains, app clip published on app store, smart app banner. My associated domain url is "validated" on app store connect My website has a smart app banner with meta tag with bundle identifier, and a open graph photo configured. My app clip has the domain in it's entitlements file What I'm expecting: Sending a text with the website's url should show me my app clip card, and not open my website, instead the app clip. I shouldn't need to configure an advanced app clip experience because it's just via Messenger.. right? According to the documentation, advanced experiences should be for maps, qr codes, etc, right? From what it seems... everything is set up completely right... so how come when I send myself a text message with the website's URL, it's not popping up with the app clip card?
2
2
375
Jul ’24
Merge results from NSURLSession back on to the main thread UI
I have apps that send requests for route between 2 locations and search, filter then display facilities near the route. The apps first send a request for the route on a background thread, then based on route, search for facilities near certain locations on or near the route. There maybe multiple searches on the same route, each on a different location. Suitable results then are displayed on the map. Apps also do live updates. However, since I have switched to using NSURLSession to search for the route on a background thread, not all suitable results/pin are displayed. Certain pins only show up upon the next didUpdateToLocation call. So my question is, what is the best practice to sync the results on the UI? Why do only some of the results show up on the UI, and others don't.
1
0
233
Jul ’24
How can I set app shortcut platter background colour on visionOS?
This is a follow up to my previous post, this time using the visionOS 1.2 simulator and Xcode 15.4. I am trying to set the background colour of my app shortcut platter for the visionOS version using NSAppIconComplementingColorNames but it doesn’t take effect when I check the shortcuts app. I see the built in Music Recognition app has a background colour but I am unable to set one for my app. Please note that this feature is working correctly on iOS. But on visionOS it has no effect and returns a plain background. I noticed the documentation doesn't mention it works on visionOS. But if that's the case how was the music recognition app able to set a colour?
1
1
422
May ’24
Control Center widget won't show snippet view
Has anyone been able to create a Control Center widget that opens a snippet view? There are stock Control Center widgets that do this, but I haven't been able to get it to work. Here's what I tried: struct SnippetButton: ControlWidget { var body: some ControlWidgetConfiguration { StaticControlConfiguration( kind: "***.***.snippetWidget" ) { ControlWidgetButton(action: SnippetIntent()) { Label("Show Snippet", systemImage: "map.fill") } } .displayName(LocalizedStringResource("Show Snippet")) .description("Show a snippet.") } } struct SnippetIntent: ControlConfigurationIntent { static var title: LocalizedStringResource = "Show a snippet" static var description = IntentDescription("Show a snippet with some text.") @MainActor func perform() async throws -> some IntentResult & ProvidesDialog & ShowsSnippetView { return .result(dialog: IntentDialog("Hello!"), view: SnippetView()) } } struct SnippetView: View { var body: some View { Text("Hello!") } }
3
1
357
Jul ’24
Custom menu for Document based app
In my document-based app for macOS I am using storyboard. I create a custom menu and menu items in storyboard. The menu is there, but the menu item remains inactive (grey). In order to activate the menu, one has to use NSWindowDelegate and walk the menu tree, to enable the menu items. import Foundation import Cocoa class DocumentController: NSViewController, NSTextFieldDelegate { @IBOutlet var myOutlet: NSView! // ... code here ... } extension DocumentController: NSWindowDelegate { func windowDidBecomeMain(_ notification: Notification) { NSLog("windowDidBecomeMain - enable menu") if let customMenu = NSApp.mainMenu?.items[2].submenu { customMenu.item(at: 1)?.isEnabled = true } } func windowDidResignMain(_ notification: Notification) { NSLog("windowDidResignMain - disable menu") } } I added the outlet (myOutlet) in storyboard, but windowDidBecomeMain() does not get called? Thanks for any help.
0
0
164
Jul ’24
Can I omit `ObservableObject` conformance?
Apple's documentation pretty much only says this about ObservableObject: "A type of object with a publisher that emits before the object has changed. By default an ObservableObject synthesizes an objectWillChange publisher that emits the changed value before any of its @Published properties changes.". And this sample seems to behave the same way, with or without conformance to the protocol by Contact: import UIKit import Combine class ViewController: UIViewController { let john = Contact(name: "John Appleseed", age: 24) private var cancellables: Set<AnyCancellable> = [] override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. john.$age.sink { age in print("View controller's john's age is now \(age)") } .store(in: &cancellables) print(john.haveBirthday()) } } class Contact { @Published var name: String @Published var age: Int init(name: String, age: Int) { self.name = name self.age = age } func haveBirthday() -> Int { age += 1 return age } } Can I therefore omit conformance to ObservableObject every time I don't need the objectWillChange publisher?
2
0
242
Jul ’24
[ERROR] failed to get service endpoint creating for for item at URL
I have been using UIDocumentInteractionController and presentOptionsMenuFromRect for sharing PDFs for years. Now I get these errors. Only support loading options for CKShare and SWY types. [ERROR] failed to get service endpoint creating for for item at URL Collaboration: error loading metadata for documentURL:file: The files I create I believe are fine. I have tried sharing them from a temporary folder and also from a subfolder on the iPad but still get these errors. Any help appreciated.
1
0
283
Jul ’24
Is it possible for WKWebView to autofill credit card number for safari?
So in our app, we let the user to type in credit card numbers. We wanna enable the user to autofill credit card numbers saved in the safari. We use the webview to open a link that leads to a PCI-compliant third-party components. We use WKWebView. If we use SFSafariViewController, then the webview will open the link using real safari, and the user will be able to autofill from safari. But we use WKWebView. My question is: Is it possible to enable the user to autofill credit card numbers saved in safari using WKWebView? Thanks!
1
0
233
Jul ’24
How to catch event of Extension UI in macOS
I have an URGENT assignment with detail as below: I have an application and it has an Extension UI for it. When I select an item of popup list on standard UI of application. How can I catch event of this selection in standard UI and do update for Extension UI? Do we have any relationship between Standard UI and Extension UI in MacOS? Please help to share your experience about this technical?
0
0
136
Jul ’24