Post

Replies

Boosts

Views

Activity

CloudKit: shared records creatorUserRecordID and lastModifiedUserRecordID
Hi, I am testing a situation with shared CKRecords where the data in the CKRecord syncs fine, but the creatorUserRecordID.recordName and lastModifiedUserRecordID.recordName shows "defaultOwner" (which maps to the CKCurrentUserDefaultName constant) even though I made sure I edit the CKRecord value from a different iCloud account. In fact, on the CloudKit dashboard, it shows the correct user recordIDs in the metadata for the 'Created' and 'Modified' fields, but not in the CKRecord. I am mostly testing this on the iPhone simulator with the debugger attached. Is that a possible reason for this, or is there some other reason the lastModifiedUserRecordID is showing the value for 'CKCurrentUserDefaultName'? It would be pretty difficult to build in functionality to look up changes by a different userID if this is the case.
1
0
121
2w
Exceptions thrown with NSTextView and spell checker
I use NSTextView in my app, and I am getting a LOT of crashes when I’m running the app with the debugger attached, and it all points to this spell checker in NSTextView. The crash happens as soon as the textview shows the ‘word completion’ option. If I turn off the “Continuous Spell Checking” option, it works fine, and it doesn’t crash. The exception reason given is: __NSCFString * "NSMutableRLEArray objectAtIndex:effectiveRange:: Out of bounds" This is what the stack trace looks like in Xcode: Thread 1 Queue : com.apple.main-thread (serial) #0 0x000000018335eb38 in objc_exception_throw () #1 0x0000000184e01910 in -[NSRLEArray objectAtIndex:effectiveRange:] () #2 0x0000000184e519a8 in -[NSMutableAttributedString addAttribute:value:range:] () #3 0x000000018818086c in -[NSText(NSTextAccessibilityPrivate) accessibilityAXAttributedStringForCharacterRange:parent:] () #4 0x0000000187f576b0 in -[NSAccessibilityAttributeAccessorInfo getParameterizedAttributeValue:forObject:withParameter:] () #5 0x0000000187f591a8 in ___NSAccessibilityEntryPointValueForAttributeWithParameter_block_invoke.799 () #6 0x0000000187f5458c in NSAccessibilityPerformEntryPointObject () #7 0x0000000187f56190 in NSAccessibilityEntryPointValueForAttributeWithParameter () #8 0x0000000187cb6a3c in CopyParameterizedAttributeValue () #9 0x00000002327057ac in ___lldb_unnamed_symbol4511 () #10 0x0000000232705854 in ___lldb_unnamed_symbol4512 () #11 0x000000018a5b3670 in _AXXMIGCopyParameterizedAttributeValue () #12 0x000000018a5d4894 in _XCopyParameterizedAttributeValue () #13 0x000000018a592ff8 in mshMIGPerform () #14 0x000000018382a250 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ () #15 0x000000018382a178 in __CFRunLoopDoSource1 () #16 0x0000000183828b78 in __CFRunLoopRun () #17 0x0000000183827c58 in CFRunLoopRunSpecific () #18 0x000000018f2bc27c in RunCurrentEventLoopInMode () #19 0x000000018f2bf4e8 in ReceiveNextEventCommon () #20 0x000000018f44a484 in _BlockUntilNextEventMatchingListInModeWithFilter () #21 0x000000018774fab4 in _DPSNextEvent () #22 0x00000001880ee5b0 in -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] () #23 0x00000001884b836c in -[NSCorrectionPanel _interceptEvents] () #24 0x00000001884b8f30 in -[NSCorrectionPanel showPanelAtRect:inView:primaryString:alternativeStrings:forType:completionHandler:] () #25 0x00000001880c91ec in -[NSSpellChecker showCorrectionIndicatorOfType:range:primaryString:alternativeStrings:forStringInRect:view:completionHandler:] () #26 0x00000001880ca0c0 in -[NSSpellChecker _showInlinePredictionForReplacingRange:markedRange:string:withString:view:client:lastReplacementRange:completeWordIndexes:resultDictionary:completionHandler:] () #27 0x00000001880cb26c in -[NSSpellChecker showCompletionForCandidate:selectedRange:offset:inString:rect:view:client:completionHandler:] () #28 0x0000000188303a94 in -[NSTextCheckingController handleCompletionFromCandidates:forSelectedRange:offset:inAnnotatedString:rect:view:] () #29 0x00000001882f9054 in -[NSTextCheckingController viewForRange:completionHandler:] () #30 0x00000001883041c8 in __60-[NSTextCheckingController handleCandidates:sequenceNumber:]_block_invoke () #31 0x000000018789105c in -[NSTextCheckingController annotatedSubstringForProposedRange:wrap:completionHandler:failureHandler:] () #32 0x0000000187890da4 in -[NSTextCheckingController annotatedSubstringForProposedRange:completionHandler:] () #33 0x00000001878927d4 in -[NSTextCheckingController annotatedSubstringForSelectedRangeWithCompletionHandler:] () #34 0x0000000188304134 in -[NSTextCheckingController handleCandidates:sequenceNumber:] () #35 0x00000001883067e0 in ___NSRunLoopTimerCreateWithHandler_block_invoke () #36 0x0000000183842e14 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ () #37 0x0000000183842ad4 in __CFRunLoopDoTimer () #38 0x0000000183842610 in __CFRunLoopDoTimers () #39 0x0000000183828a18 in __CFRunLoopRun () #40 0x0000000183827c58 in CFRunLoopRunSpecific () #41 0x000000018f2bc27c in RunCurrentEventLoopInMode () #42 0x000000018f2bf4e8 in ReceiveNextEventCommon () #43 0x000000018f44a484 in _BlockUntilNextEventMatchingListInModeWithFilter () #44 0x000000018774fab4 in _DPSNextEvent () #45 0x00000001880ee5b0 in -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] () #46 0x0000000187742c64 in -[NSApplication run] () #47 0x000000018771935c in NSApplicationMain () If I run the debug version of the app without the debugger, it works fine as well. In fact, if I run the app without "All Objective-C Exceptions" breakpoint, it also works fine. So it seems like some framework issue, which is making it hard to run and test my app. What’s the reason for this, and is this an issue I should be worried about for when the app is available to my users?
Topic: UI Frameworks SubTopic: AppKit Tags:
3
0
41
Jun ’25
Crash with NSAttributedString in Core Data
I am trying out the new AttributedString binding with SwiftUI’s TextEditor in iOS26. I need to save this to a Core Data database. Core Data has no AttributedString type, so I set the type of the field to “Transformable”, give it a custom class of NSAttributedString, and set the transformer to NSSecureUnarchiveFromData When I try to save, I first convert the Swift AttributedString to NSAttributedString, and then save the context. Unfortunately I get this error when saving the context, and the save isn't persisted: CoreData: error: SQLCore dispatchRequest: exception handling request: <NSSQLSaveChangesRequestContext: 0x600003721140> , <shared NSSecureUnarchiveFromData transformer> threw while encoding a value. with userInfo of (null) Here's the code that tries to save the attributed string: struct AttributedDetailView: View { @ObservedObject var item: Item @State private var notesText = AttributedString() var body: some View { VStack { TextEditor(text: $notesText) .padding() .onChange(of: notesText) { item.attributedString = NSAttributedString(notesText) } } .onAppear { if let nsattributed = item.attributedString { notesText = AttributedString(nsattributed) } else { notesText = "" } } .task { item.attributedString = NSAttributedString(notesText) do { try item.managedObjectContext?.save() } catch { print("core data save error = \(error)") } } } }
2
0
65
Jun ’25
Core Spotlight searching only for title
I just adding a way to donate my app's data to Core Spotlight using CSSearchableIndex, but I'm finding that spotlight is only searching for the title of the CSSearchableItem I create. I know the index is working, because it always finds the item through the title property, but nothing else. This is how I'm creating the CSSearchableItem: - (CSSearchableItem *) createSearchableItem { CSSearchableItemAttributeSet* attributeSet = [[CSSearchableItemAttributeSet alloc] initWithContentType: UTTypeText]; attributeSet.title = [self titleForIndex]; attributeSet.displayName = [self titleForIndex]; attributeSet.contentDescription = [self contentDescriptionForIndex]; attributeSet.thumbnailData = [self thumbnailDataForIndex]; attributeSet.textContent = [self contentDescriptionForIndex]; CSSearchableItem *item = [[CSSearchableItem alloc] initWithUniqueIdentifier: [self referenceURLString] domainIdentifier:@"com.cjournal.cjournal-Logs" attributeSet:attributeSet]; item.expirationDate = [NSDate distantFuture]; return item; } There's a lot of confusing tips around which say specifying the 'textContent' should work, and/or setting the displayName is essential, but none of these are working. Is there something I'm missing with my setup? Thanks.
0
0
60
Jun ’25
Crash with NSAttributedString in Core Data
I am trying out the new AttributedString binding with SwiftUI’s TextEditor in iOS26. I need to save this to a Core Data database. Core Data has no AttributedString type, so I set the type of the field to “Transformable”, give it a custom class of NSAttributedString, and set the transformer to NSSecureUnarchiveFromData When I try to save, I first convert the Swift AttributedString to NSAttributedString, and then save the context. Unfortunately I get this error when saving the context, and the save isn't persisted: CoreData: error: SQLCore dispatchRequest: exception handling request: <NSSQLSaveChangesRequestContext: 0x600003721140> , <shared NSSecureUnarchiveFromData transformer> threw while encoding a value. with userInfo of (null) Here's the code that tries to save the attributed string: struct AttributedDetailView: View { @ObservedObject var item: Item @State private var notesText = AttributedString() var body: some View { VStack { TextEditor(text: $notesText) .padding() .onChange(of: notesText) { item.attributedString = NSAttributedString(notesText) } } .onAppear { if let nsattributed = item.attributedString { notesText = AttributedString(nsattributed) } else { notesText = "" } } .task { item.attributedString = NSAttributedString(notesText) do { try item.managedObjectContext?.save() } catch { print("core data save error = \(error)") } } } } This is the attribute setup in the Core Data model editor: Is there a workaround for this? I filed FB17943846 if someone can take a look. Thanks.
2
0
143
Jun ’25
FoundationModels and Core Data
Hi, I have an app that uses Core Data to store user information and display it in various views. I want to know if it's possible to easily integrate this setup with FoundationModels to make it easier for the user to query and manipulate the information, and if so, how would I go about it? Can the model be pointed to the database schema file and the SQLite file sitting in the user's app group container to parse out the information needed? And/or should the NSManagedObjects be made @Generable for better output? Any guidance about this would be useful.
1
0
135
Jun ’25
iPadOS26: UITabBar doesn't switch selected state
With iPadOS26, if I create a UITabBar, and use that to switch between views, the selected state never updates. I created this simple UIViewController to demonstrate the issue: class SimpleTabBarController: UIViewController, UITabBarDelegate { let tabBar = UITabBar() let redItem = UITabBarItem(title: "Red", image: nil, tag: 0) let blueItem = UITabBarItem(title: "Blue", image: nil, tag: 1) override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .white tabBar.items = [redItem, blueItem] tabBar.selectedItem = redItem tabBar.delegate = self tabBar.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tabBar) NSLayoutConstraint.activate([ tabBar.leadingAnchor.constraint(equalTo: view.leadingAnchor), tabBar.trailingAnchor.constraint(equalTo: view.trailingAnchor), tabBar.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor) ]) updateBackground(for: redItem) } func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) { updateBackground(for: item) } private func updateBackground(for item: UITabBarItem) { switch item.tag { case 0: view.backgroundColor = .systemRed case 1: view.backgroundColor = .systemBlue default: view.backgroundColor = .white } } } The tabBar didSelect item method is called, and the background color gets updated as expected, but the selected state of the UITabBar stays the same. I files a feedback for a related issue: FB17841678
1
0
166
Jun ’25
Xcode26: download stuck on 'fetching'
I just downloaded Xcode26, and am trying to download the new simulator to be able to run and test my app. But the downloads folder just shows that it's stuck on "Fetching download information ..." even 15 minutes after it started. I tried restarting Xcode but didn't help. Internet connection is good. Any tips to get it working?
6
3
240
Jun ’25
SwiftUI List - onInsert not called on iOS (works on macOS)
I am working with a simple SwiftUI List and I want to enable functionality that allows files and images to be dropped onto the List from outside the app. There is an onInsert modifier with List that allows for this, but I found that it works on macOS, but not when running the same view on iOS. I have sample code that I can't seem to post on this forum because it keeps giving me a validation error about "This post contains sensitive language". Maybe this will work: Code to reproduce issue Is there anything I can do to make this work on iOS?
1
0
65
May ’25
WidgetKit: add new widget to bundle
Hi, I have an existing Mac app on the App Store with a couple of widgets as part of the app. I want to now add a new widget to the WidgetBundle. When I build the updated app with Xcode, and then run the updated app, the widgets list doesn't seem to get updated in Notification Center or in the WidgetKit Simulator. I do have the App Store version installed in the /Applications folder as well, so there might be some conflict. What's the trick to getting the widgets list to run the debug version?
0
0
48
Mar ’25
SwiftUI: TextField not getting focus changes inside Button
I have a SwiftUI List (on macOS) where I want to display a few TextFields in each row, and observe how the focus changes as an individual text field is selected or unselected. This seems to work fine if I just have the List display a pure TextField in each row, but if I embed the TextField inside a Button view, the focus change notifications stop working. I want the 'button' functionality so that the user can tap anywhere on the row and have the text field activated, instead of tapping exactly on the text field boundary. Here is some code to demonstrate the problem. In the List if you have RowView uncommented out (1), then the focus change notifications work. If you comment that out and uncomment the RowViewWithButton (2), then the button functionality works, but I can't get focus change notifications anymore. Here is the code to reproduce the issue. Interestingly, when I test this on iOS, it works fine in both cases. But I need the solution for macOS. import SwiftUI // test on macOS target struct ContentView: View { @State private var textFields = Array(repeating: "", count: 4) @FocusState private var focusedField: Int? var body: some View { List(0..<4, id: \.self) { index in // 1. works with focus notification changes RowView(index: index, text: $textFields[index], focusedField: $focusedField) // 2. button works, but no focus notifications on text field //RowViewWithButton(index: index, text: $textFields[index], focusedField: $focusedField) } } } struct RowView: View { let index: Int @Binding var text: String @FocusState.Binding var focusedField: Int? var body: some View { HStack { Text("Row \(index + 1):") TextField("", text: $text) .multilineTextAlignment(.leading) .focused($focusedField, equals: index) } .onChange(of: focusedField) { newFocus in if newFocus == index { print("TextField \(index) is in focus") } else { print("TextField \(index) lost focus") } } .padding(.vertical, 4) } } struct RowViewWithButton: View { let index: Int @Binding var text: String @FocusState.Binding var focusedField: Int? var body: some View { Button (action: { print("RowView - button selected at index \(index)") focusedField = index }) { HStack { Text("Row \(index + 1):") TextField("", text: $text) .multilineTextAlignment(.leading) .focused($focusedField, equals: index) } .onChange(of: focusedField) { newFocus in if newFocus == index { print("TextField \(index) is in focus") } else { print("TextField \(index) lost focus") } } .foregroundColor(.primary) } .buttonStyle(BorderlessButtonStyle()) .padding(.vertical, 4) } } #Preview { ContentView() .frame(width: 320, height: 250) }
2
0
264
Mar ’25
SwiftUI: Major unannounced change in iOS18.4 beta1
Hi, I have noticed a major change to a SwiftUI API behavior in iOS18.4beta1 which breaks my app's functionality, and I've started hearing from users running the new beta that the app doesn't correctly work for them anymore. The problem is with views that contain a List with multiple-selection, and the contextMenu API applied with the ‘primaryAction’ callback that is triggered when the user taps on a row. Previously, if the user tapped on a row, this callback was triggered with the 'selectedItems' showing the tapped item. With iOS18.4beta, the same callback is triggered with ‘selectedItems’ being empty. I have the code to demonstrate the problem: struct ListSelectionTestView: View { @State private var items: [TimedItem] = [ TimedItem(number: 1, timestamp: "2024-11-20 10:00"), TimedItem(number: 2, timestamp: "2024-11-20 11:00"), TimedItem(number: 3, timestamp: "2024-11-20 12:00") ] @State var selectedItems = Set<TimedItem.ID>() var body: some View { NavigationStack { List(selection: $selectedItems) { ForEach(items) { item in Text("Item \(item.number) - \(item.timestamp)") } } .contextMenu(forSelectionType: TimedItem.ID.self, menu: {_ in Button(action: { print("button called - count = \(selectedItems.count)") }) { Label("Add Item", systemImage: "square.and.pencil") } }, primaryAction: {_ in print("primaryAction called - count = \(selectedItems.count)") }) } } } struct TimedItem: Identifiable { let id = UUID() let number: Int let timestamp: String } #Preview { ListSelectionTestView() } Running the same code on iOS18.2, and tapping on a row will print this to the console: primaryAction called - count = 1 Running the same code on iOS18.4 beta1, and tapping on a row will print this to the console: primaryAction called - count = 0 So users who were previously selecting an item from the row, and then seeing expected behavior with the selected item, will now suddenly tap on a row and see nothing. My app's functionality relies on the user selecting an item from a list to see another detailed view with the selected item's contents, and it doesn't work anymore. This is a major regression issue. Please confirm and let me know. I have filed a feedback: FB16593120
3
0
380
Feb ’25
SwiftUI Transformable: support drag to Finder on macOS
I am trying to support dragging out a 'file' object from my app into Finder, on macOS. I have my object conform to Transferable and the files are saved on disk locally, so I just want to pass it the URL. This works fine when dragging out to other apps, like Notes or Mail, but not in Finder. I setup a ProxyRepresentation as well, as suggested by another thread, but it doesn't seem to help. Is there any other setup I need to do in the Xcode project file for it to work, or is there something else that I'm missing? @available(iOSApplicationExtension 17.0, macOSApplicationExtension 14.0, *) extension FileAttachments: Transferable { public static var transferRepresentation: some TransferRepresentation { FileRepresentation(exportedContentType: UTType.content) { content in SentTransferredFile(content.fullFileURL(), allowAccessingOriginalFile: false) } .exportingCondition { file in if let fileUTI = UTType(filenameExtension: file.fullFileURL().pathExtension), let fileURL = file.fullFileURL() { print("FileAttachments: FileRepresentation exportingCondition fileUTI: \(fileUTI) for file: \(fileURL)") return fileUTI.conforms(to: UTType.content) } return false } .suggestedFileName{$0.fileRenamedName} ProxyRepresentation { file in if let fileURL = file.fullFileURL() { print("FileAttachments: ProxyRepresentation returning file") return fileURL } return file.fullFileURL()! } } }
1
0
327
Feb ’25
NSOutlineView with Diffable Data Source
Hi, On macOS, there seems to be a NSTableViewDiffableDataSource and an NSCollectionViewDiffableDataSource, but there seems to be nothing for NSOutlineView. Is it possible to somehow use NSTableViewDiffableDataSource with NSOutlineView that I'm missing? If not, is it possible to use NSTableView with NSTableViewDiffableDataSource to show a 'table' with section headers?
Topic: UI Frameworks SubTopic: AppKit Tags:
5
0
624
Dec ’24