Post

Replies

Boosts

Views

Activity

Reply to Spotlight App Extension does not persist custom Attributes
It exceptions on let text = try String(contentsOf: url) I tested by exporting the new type (instead of importing( and changing all the type identifiers everywhere, appended 2 to the file extension (I already use that one) then used: mdimport -m -y net.projectwizards.spotlight.document -u /Users/mh/Downloads/Test/Untitled.exampletext2 Note this just seems to test the plugin it doesn't actually import it to Spotlight (seems like that isn't implemented yet).
Topic: App & System Services SubTopic: General Tags:
Sep ’25
Reply to The Spotlight Import Extension does not allow to inspect document bundles to get the metadata for the spotlight
I think this might be the reason CSImportExtension was never fully implemented on macOS, e.g. if you try the built-in pdf extension at /System/Library/Frameworks/PDFKit.framework/Versions/A/Plugins/PDFImporter.appex (from mdimport -L) Using: mdimport -m -y com.adobe.pdf -u AnyPDF.pdf You'll see it doesn't get any attributes like page count or anything, if you have a nosey in Hopper you see it has code for these attributes but is likely failing to read the pdf file in the same way your code does. So they probably gave up and thats why /System/Library/Spotlight/PDF.mdimporter still exists (from mdimport -e ) and why no one can get CSImportExtension to populate spotlight with anything on macOS.
Topic: App & System Services SubTopic: General Tags:
Sep ’25
Reply to NSLocationRequireExplicitServiceSession
In Xcode select the project in the sidebar, select the target in the first column, select Info in the top tab bar. Under custom iOS Target Properties hover over the table and click plus to add a new row. Enter NSLocationRequireExplicitServiceSession for the key, choose Bool for the type, and choose YES for the value. This is shown the below screenshot:
Jun ’25
Reply to UITextView's pressesBegan isn't triggered by the software keyboard
I found a bug in SwiftUI caused by this issue. When you use TextField with axis: .vertical it renders a SwiftUI.VerticalTextView that uses presses to submit the field. So it only works with hardware keyboard, e.g. Mac keyboard and iPhone simulator. On software keyboard on simulator or device the return adds a new line instead of sending the expected submit! FB17642828 https://github.com/feedback-assistant/reports/issues/661
Topic: UI Frameworks SubTopic: UIKit Tags:
May ’25
Reply to SwiftData updates in the background are not merged in the main UI context
This is probably for the best. If you think about it, why bother to make a whole new context and a new item object just to save if you want the outcome to be another instance of the object loaded back into the main context? Why not just save the memory and use the main context in the first place so there is only one object instance. The main context save happens semi-asynchronously after 10 seconds or at app suspend anyway. If many objects were saved in the background ModelActor and automatically loaded into main context regardless if they are shown on the UI or not then it would be just as slow and memory intensive as if they were saved to the main context in the first place, perhaps even slower or twice as memory intensive because they have been loaded into 2 contexts.
Apr ’25
Reply to Actors with Combine publishers as properties.
The Transcribing speech to text tutorial for the Scrumdinger sample app does it like this: actor SpeechRecognizer: ObservableObject { @MainActor @Published var transcript: String = "" nonisolated private func transcribe(_ message: String) { Task { @MainActor in transcript = message } } struct MeetingView: View { @StateObject var speechRecognizer = SpeechRecognizer() https://developer.apple.com/tutorials/app-dev-training/transcribing-speech-to-text
Topic: Programming Languages SubTopic: Swift Tags:
Apr ’25
Reply to Unable to use transitions for SwiftData in List
I'm not bothered that it isn't possible to have List use SwiftUI defined animations but I would at least like the animation completion to work so I can do something after the default row insert animation completes, e.g. private func addItem() { var transaction = Transaction(animation: .default) transaction.addAnimationCompletion { // need this after the row insert animation finishes. print("Complete") } withTransaction(transaction) { let newItem = Item(timestamp: Date()) items.append(newItem) } } After a row has been inserted and animated I plan to programatically select it and navigate. I don't want both of these animations to happen simultaneously. Right now completion just fires instantly. Submitted FB17267533 referencing FB15436970
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’25
Reply to Accessing an actor's isolated state from within a SwiftUI view
@MainActor @Published var num: Int = 0 And to set it inside an async actor func you can do: await MainActor.run { num = x } An example of this is in Scrumdinger in the Transcribing Speech tutorial: https://developer.apple.com/tutorials/app-dev-training/transcribing-speech-to-text actor SpeechRecognizer: ObservableObject { ... @MainActor @Published var transcript: String = "" ... nonisolated private func transcribe(_ message: String) { Task { @MainActor in transcript = message } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’25
Reply to SwiftData JSONDataStore with relationships
I had the same problem and fixed it by changing the fetch to filter by the entity name, e.g. let objs = try read() let snapshots = objs.values.filter { v in v.persistentIdentifier.entityName == String(describing: T.self) } return DataStoreFetchResult(descriptor: request.descriptor, fetchedSnapshots: snapshots, relatedSnapshots: objs)
Apr ’25
Reply to SwiftData serious bug with relationships and CloudKit in iOS 18.0 (Xcode 16 Beta)
If it updates automatically for the new remotely added Record which is the type used in your @Query then maybe you just need another dummy @Query for Band so it will also update when a Band is remotely added, e.g. struct ContentView: View { @Environment(\.modelContext) private var modelContext @Query private var records: [Record] @Query private var bands: [Band]
Apr ’25
Reply to SwiftUI Sheet race condition
It's expected. body needs to call the myVar getter if you want body to be called when the myVar setter is used. And you need this to happen so that the .sheet computes a new version of the closure. You can fix it by putting the bool and the myVar in the same State, e.g. struct Content { var myVar: Int? = nil var presentSheet: Bool = false } @State var content = Content() .sheet(isPresented: $content.presentSheet)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’25
Reply to Disabled button in SwiftUI .alert not working
I noticed if the Button's title is dynamic it breaks .disabled() from working, e.g. Button("Save \(text)") { // dynamic title items.append(ListItem(text: text)) } .disabled(text.isEmpty) // no worky anymore Xcode 16.2, iOS simulator 18.2 Submitted FB16539507 to request the .alert() docs be updated to state if using .disabled is supported because currently it is not mentioned. Also included this bug I noticed which is probably a waste of time since I reported the bug to the documentation team.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’25
Reply to Why can't SwiftUI state be changed in the middle of view updates?
The main misatke is in: func textField( forColorWithID colorID: UUID ) -> some View { ensureThatThereIsEditableText( The ensureThatThereIsEditableText func is changing the model which is not allowed from inside body. A few other mistakes in the SwiftUI code are: id: \.self is not a valid id keypath it needs to be a path to a unique identifeir property or the data should implement Identifiable. @ViewBuilder func colorTextField is not valid SwiftUI you need to make a struct ColorTextField: View { Don't have if inside body with no else clause. Try and avoid the if completely by defining the view and doing the if inside the param, e.g. MyView(text: a ? "a" : "b") If I was you I would redesign the data to use Identifiable and an array instead of trying to use a dictionary.
Topic: UI Frameworks SubTopic: SwiftUI
Dec ’24