Post

Replies

Boosts

Views

Activity

How to index file based documents in Core Spotlight
I read this thread https://developer.apple.com/forums/thread/788979 thoroughly, but I’m still confused regarding indexing files content. I'm building a notes app where the notes are stored in files. A file can contain several notes (think paragraphs). Each note and the file document itself have a unique ID, all embedded in the file. So far so good, when the user opens a file in the app, I index all the notes in it using several CSSearchableItem, one for each note. Each CSSearchableItem gets a unique ID based on the note and file IDs. The notes are then visible in Spotlight search and when the user taps one of them, the app is called with a Spotlight activity and I present the note. I learned that I should create a CSImportExtension to allow the system to index files when app is not running. But the only method is update(_:forFileAt:), which allows to provide back to the system a single attributes set. How can I index the notes in a file as separate items? What happens if an iCloud document file is edited remotely and the app is not running, or is editing another file? Does the system detect it and run CSImportExtension on the file? All the notes and documents IDs are unique, and when the user duplicates the document file from within the app, new unique IDs are set in the duplicate file. But the user can also duplicate files outside the app, in which case the IDs remain the same in the duplicate file. How does Spotlight react to indexing two distinct items, with the same ID, but different 'contentURL'? What if I index a note from a file, and set the current contentURL of the file, and then the user moves the file. Next time when I index a note from this file, Spotlight will get an item with the same uniqueIdentifier but with a different contentURL. Won't this confuse the system? How to handle the case of deleted files: Unless a file is pending editing, the app doesn’t know it has been deleted, so it won’t remove the corresponding items from Spotlight. I should mention that I use a Core Data database, which stores the mapping from file document IDs to file URLs, actually to bookmarks, so I can track the files even if the user renames or moves them.
7
0
212
Nov ’25
Chaotic keyboard frame notification in windowed app in iOS 26
I have a simple task, to measure the height of the overlapping area occupied by the keyboard in the current view. In the attached images, I use it to position a UITextView (red) above the keyboard, as a test. The keyboard displays an inputAccessoryView (yellow) when editing a text view, but it’s also summoned by a UIFindInteraction, which shows a search bar above the keyboard. When measuring the keyboard, I need to account for either the accessory view or the search bar, basically, the total keyboard height including any extra views above it. I use the usual algorithm: the keyboard frame from UIResponder.keyboardWillShowNotification (documented as being in screen coordinates) is converted to my view’s coordinates and intersected with the view’s bounds to get the overlapping height. The first issue: in windowed mode, the keyboard frame reports a negative origin.x (e.g. -247), even though in screen coordinates it should start at 0. I display the raw frame in the navbar, as shown in the first screenshot. I then suspected the frame might be in window coordinates on iOS 26, but repositioning the window a few times, and switching between find interaction keyboard and text editing keyboard, sometimes yields a positive origin.x instead, as if the keyboard starts from the middle of the screen!? (see the second screenshot). And in some cases, the raw keyboard height is even 0, despite the keyboard clearly being visible and taking space (third screenshot). Interestingly, the reported frame for the search keyboard is always consistent and in screen coordinates, but the default keyboard frame just doesn’t make sense.
1
0
289
Sep ’25
How to fix iOS 26 Beta / iOS 18 SDK compile conflicts?
A method in my app now requires the override keyword when compiling with Xcode 26 beta / iOS 26 SDK, but if I add it, the current official Xcode 16.4 (iOS 18 SDK) throws a compile error. It's about 'toggleSidebar(_:)' in UIViewController. The problem is: Apple expects our apps to be ready for iOS 26 launch this fall, so I need to be actively developing and testing in the Xcode 26 beta now. At the same time, I still need to submit updates to the App Store using the current official Xcode 16.4 until iOS 26 officially launches. I'm using a single .xcodeproj file and can't keep manually adding/removing -DIOS_SDK_26_OR_LATER in Build Settings multiple times a day. How to fix it and why isn't there a straightforward #if sdk(>=26.0) type of check for compile-time in Swift? It's really frustrating to manage this override conflict.
1
0
168
Jul ’25
Double border in UIBarButtonItem with Custom View on iOS 26, bug or feature?
I have several UIBarButtonItems in a navigation bar, and they get the default glass treatment in iOS26. All look ok excepting one, which is a UIBarButtonItem with a custom view, a plain UIButton. This one does not change the tint of the inner button's image to white/black like all the others, but it stays blue, like the regular tinted bar buttons pre iOS26. I then built the inner UIButton starting from glass configuration, UIButton.Configuration.glass(), and it looks fine, see the 2nd pic. But if I send the app to background and bring it back, the inner button gets a border, such that the bar button now has 2 borders, and look out of place compared to the other bar buttons, see 3rd pic. Is this a bug or a feature? How can I make custom-view bar buttons look like regular ones, without double border.
2
0
228
Jul ’25
LLDB error: type for self cannot be reconstructed: type for typename
All is fine in Xcode15, no LLDB errors whatsoever, but in Xcode16 I can't get any variable displayed in the console because of the following error: error: type for self cannot be reconstructed: type for typename "$......." was not found (cached) error: Couldn't realize Swift AST type of self. Hint: using `v` to directly inspect variables and fields may still work. I've checked the output of swift-healthcheck and there are several messages like this: SwiftASTContextForExpressions(module: "ROA", cu: "ROA+ViewLayer.swift")::LoadOneModule() -- Missing Swift module or Clang module found for "UIKit", "imported" via SwiftDWARFImporterDelegate. Hint: Register Swift modules with the linker using -add_ast_path. I added -add_ast_path to the OTHER_LDFLAGS in the faulty module's build settings but no luck. How can I debug my project in Xcode16?
15
2
2.0k
May ’25
Equal width buttons in VStack
I can't wrap my head around how to make two buttons the same width, without resorting to ugly hacks like GeometryReader. What is otherwise easy to implement using UIStackView or AutoLayout, becomes a nightmare in SwiftUI. I tried the following, plus some other variations, but nothing works. What is the "official way" to make two vertically aligned buttons of the same width? 1) VStack(alignment: .leading) { Button("Short", action: {}) .frame(maxWidth: .infinity) Button("Long title", action: {}) .frame(maxWidth: .infinity) } .frame(maxWidth: .infinity) 2) VStack(alignment: .leading) { Button(action: {}) { Text("Short") .frame(maxWidth: .infinity) } Button(action: {}) { Text("Long title") .frame(maxWidth: .infinity) } } .frame(maxWidth: .infinity) 3) VStack(alignment: .leading) { Button(action: {}) { Text("Short") }.frame(maxWidth: .infinity) Button(action: {}) { Text("Long title") }.frame(maxWidth: .infinity) } .frame(maxWidth: .infinity)
3
0
1k
Oct ’24
Xcode 15.0 crashes when uploading apps to App Store Connect
I'm trying to upload an app to AppStoreConnect but Xcode (15.0 release not beta) crashes while creating the IPA - I think it's at this step, as it happens very fast. The agreements are all accepted, I don't know what else should I do ?? Here's the log: ------------------------------------- Process: Xcode [2147] Path: /Applications/Xcode.app/Contents/MacOS/Xcode Identifier: com.apple.dt.Xcode Version: 15.0 (22265) Build Info: IDEApplication-22265000000000000~3 (15A240d) Code Type: ARM-64 (Native) Parent Process: launchd [1] User ID: 501 Date/Time: 2023-09-24 11:08:28.8476 +0300 OS Version: macOS 13.5.2 (22G91) Report Version: 12 Anonymous UUID: AC134C1E-4270-BC50-46BA-0FC5F300594C Time Awake Since Boot: 590 seconds System Integrity Protection: enabled Crashed Thread: 0 Dispatch queue: archive info plist lock Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Termination Reason: Namespace SIGNAL, Code 6 Abort trap: 6 Terminating Process: Xcode [2147] Application Specific Information: abort() called com.apple.main-thread Application Specific Signatures: NSInvalidArgumentException Application Specific Backtrace 0: 0 CoreFoundation 0x00000001a3543154 __exceptionPreprocess + 176 1 DVTFoundation 0x0000000102713e30 DVTFailureHintExceptionPreprocessor + 388 2 libobjc.A.dylib 0x00000001a30624d4 objc_exception_throw + 60 3 CoreFoundation 0x00000001a362d9b8 -[__NSCFString characterAtIndex:].cold.1 + 0 4 CoreFoundation 0x00000001a363ac10 -[__NSPlaceholderDictionary initWithCapacity:].cold.1 + 0 5 CoreFoundation 0x00000001a3456ae0 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 320 6 CoreFoundation 0x00000001a3456974 +[NSDictionary dictionaryWithObjects:forKeys:count:] + 52 7 IDEFoundation 0x0000000108a55ac8 -[IDEArchiveDistributionRecord dictionaryRepresentation] + 296 8 IDEFoundation 0x0000000108a37180 __31-[IDEArchive setDistributions:]_block_invoke + 16 9 DVTFoundation 0x000000010270bb2c -[NSArray(DVTFoundationClassAdditions) dvt_arrayByApplyingBlock:] + 224 10 IDEFoundation 0x0000000108a37110 -[IDEArchive setDistributions:] + 84 11 Foundation 0x00000001a440ad94 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:maybeNewValuesDict:usingBlock:] + 604 12 Foundation 0x00000001a4434f00 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:] + 64 13 Foundation 0x00000001a444e42c _NSSetObjectValueAndNotify + 284 14 IDEFoundation 0x0000000108a36f08 __36-[IDEArchive addDistribution:error:]_block_invoke + 156 15 libdispatch.dylib 0x00000001a323c400 _dispatch_client_callout + 20 16 libdispatch.dylib 0x00000001a324b97c _dispatch_lane_barrier_sync_invoke_and_complete + 56 17 DVTFoundation 0x0000000102758014 DVTDispatchBarrierSync + 148 18 DVTFoundation 0x00000001027342b4 -[DVTDispatchLock performLockedBlock:] + 60 19 IDEFoundation 0x0000000108a36d30 -[IDEArchive addDistribution:error:] + 200 20 IDEFoundation 0x00000001086dc2f0 __35-[IDEDistributionUploadStep upload]_block_invoke.115 + 116 21 DVTFoundation 0x0000000102757330 __DVT_CALLING_CLIENT_BLOCK__ + 16 22 DVTFoundation 0x0000000102757b08 __DVTSyncPerformBlock_block_invoke + 68 23 CoreFoundation 0x00000001a34ca1d4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 28 24 CoreFoundation 0x00000001a34ca0e8 __CFRunLoopDoBlocks + 364 25 CoreFoundation 0x00000001a34c958c __CFRunLoopRun + 2432 26 CoreFoundation 0x00000001a34c84b8 CFRunLoopRunSpecific + 612 27 HIToolbox 0x00000001acd1adf0 RunCurrentEventLoopInMode + 292 28 HIToolbox 0x00000001acd1ac2c ReceiveNextEventCommon + 648 29 HIToolbox 0x00000001acd1a984 _BlockUntilNextEventMatchingListInModeWithFilter + 76 30 AppKit 0x00000001a66ef97c _DPSNextEvent + 636 31 AppKit 0x00000001a66eeb18 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 716 32 DVTKit 0x0000000102fd8a9c -[DVTApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 300 33 AppKit 0x00000001a66e2f7c -[NSApplication run] + 464 34 DVTKit 0x0000000102fd7cbc -[DVTApplication run] + 60 35 AppKit 0x00000001a66ba3cc NSApplicationMain + 880 36 dyld 0x00000001a3093f28 start + 2236 Application Specific Backtrace 1: 0 CoreFoundation 0x00000001a3543154 __exceptionPreprocess + 176 1 DVTFoundation 0x0000000102713e30 DVTFailureHintExceptionPreprocessor + 388 2 libobjc.A.dylib 0x00000001a30624d4 objc_exception_throw + 60 3 CoreFoundation 0x00000001a362d9b8 -[__NSCFString characterAtIndex:].cold.1 + 0 4 CoreFoundation 0x00000001a363ac10 -[__NSPlaceholderDictionary initWithCapacity:].cold.1 + 0 5 CoreFoundation 0x00000001a3456ae0 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 320 6 CoreFoundation 0x00000001a3456974 +[NSDictionary dictionaryWithObjects:forKeys:count:] + 52 7 IDEFoundation 0x0000000108a55ac8 -[IDEArchiveDistributionRecord dictionaryRepresentation] + 296 8 IDEFoundation 0x0000000108a37180 __31-[IDEArchive setDistributions:]_block_invoke + 16 9 DVTFoundation 0x000000010270bb2c -[NSArray(DVTFoundationClassAdditions) dvt_arrayByApplyingBlock:] + 224 10 IDEFoundation 0x0000000108a37110 -[IDEArchive setDistributions:] + 84 11 Foundation 0x00000001a440ad94 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:maybeNewValuesDict:usingBlock:] + 604 12 Foundation 0x00000001a4434f00 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:] + 64 13 Foundation 0x00000001a444e42c _NSSetObjectValueAndNotify + 284 14 IDEFoundation 0x0000000108a36f08 __36-[IDEArchive
9
2
3.6k
Oct ’23
How to implement a search bar above the keyboard like Safari on iPad
How can I insert a UISearchBar in the middle of the shortcuts bar displayed above the keyboard on iPad? You insert custom shortcuts in the shortcuts bar using 'someTextField.inputAssistantItem' with 'leadingBarButtonGroups' or 'trailingBarButtonGroups' properties, but it has no 'middleBarButtonGroups'. If I add the search bar as 'inputAccessoryView', like 'someTextField.inputAccessoryView = UISearchBar()' it is added above the shortcuts bar.
0
1
618
Aug ’23
How to symbolicate macCatalyst X86-64 crash files on M1/2
Got some crashes in Xcode Organizer from a macCatalyst app and they are not symbolicated. The crashes are from an X86-64 machine, and my work machine is M1. When trying to symbolicate them in Organizer I get an error: "Unable to Symbolicate Crash - An error occurred attempting to symbolicate crash. Unable to locate dSYMs for ...". It makes sense, as I only run the app on M1, and maybe the X86-64 was not built on this machine. I then went to download the dSYM file from AppStoreConnect/TestFlight/Build Metadata, but there is no "Download dSYM" link, even though the app page says "Includes Symbols Yes". I then tried to compile the app for "AnyMac (Mac Catalyst, Apple Silicon, Intel)", and now I get a binary with two images, the arm64 and the x86, but the UUID of x86 image is different than the one from the crash file. How can I get the original dSYM to symbolicate crashes from production?
0
0
669
Aug ’23
TextKit2 vs TextKit1 memory usage
I'm working on an app displaying a few hundred custom labels. The custom label is modelled after UILabel. When I implement the custom label using TextKit, the app is using about 0.5 GB of memory. When I implement it using TextKit2, it takes about 1.2 GB. Did anyone notice such a big difference in memory usage between TextKit and TextKit2? For how long will TextKit be around before being deprecated?
1
0
748
Aug ’23
'Perform' is never called from iOS17 Widget
I have created a widget and added a button in its body like this: Button("Tap me: ", intent: TaskIntent()). If I compile the TaskIntent in both the app and the widget, when tapping the button, it open the app and that's all, 'perform' is not called at all. If I compile the TaskIntent only in the widget, when tapping the button, it does nothing, 'perform' is not called either. Is there any special sauce needed to run the 'perform' of the AppIntent attach to the button?
1
1
921
Aug ’23
Xcode 14 Automatic signing failed
I have added Siri capability for an iOS/MacCatalyst app in Xcode. The app compiles just fine for iOS, but when compiling for MacCatalyst I get the error: “/Volumes/xdrive/M2/M2.xcodeproj Provisioning profile "Mac Catalyst Team Provisioning Profile: com.anotherview.M2.mac" doesn't include the com.apple.developer.siri entitlement. ” On the “Signing & Capabilities” page I get the error: “Automatic signing failed Xcode failed to provision this target. Please file a bug report at https://feedbackassistant.apple.com and include the Update Signing report from the Report navigator.” How can I add Siri capabilities on a Mac Catalyst app?
0
0
1.1k
Aug ’23
Official instruction for installing iOS 17.0 beta 2 and visionOS 1.0 in Xcode 15 beta 2
I downloaded the simulators, opened the DMGs, and copied them to the library. Then I start Xcode and it enters an infinite loop of "Cannot open because unverified...". I keep pressing "Open Anyway" in the Settings app, it keeps telling me "Cannot open because unverified blah blah...". I tried following the hints in this thread (https://developer.apple.com/forums/thread/732324) but no luck, I only wasted hours of work So, Apple, how to install visionOS 1.0 in Xcode 15 beta 2, such a way that it works??
0
0
635
Jul ’23