Malcolm Hall

@malhal
128 Followers
134 Following
295 Posts
iOS developer, traveller, guitarist, home brewer, academic researcher with a Ph.D. in Computer Science from the University of Glasgow. #SwiftUI #SwiftData
Bloghttp://www.malcolmhall.com

#SwiftUI @FocusState seems broken on iOS 18.2 Simulator in Xcode 16.2

https://developer.apple.com/forums/thread/774528

Setting a @FocusState var that has a corresponding `.focused` TextField and .defaultFocus for initial focus both are not working.

SwiftUI FocusState is not working … | Apple Developer Forums

Do you prefer Counter1 or Counter2? Also included is a screen cap of a computed publisher from the WWDC talk that introduced Combine.

#SwiftUI #Combine

Here's a good one from the sample: Making your app’s functionality available to Siri. onAppear, Task.detached, then MainActor.run, crazy!

Album's async fetchAssets is also weird.

https://developer.apple.com/documentation/appintents/making-your-app-s-functionality-available-to-siri

#SwiftUI

Making your app’s functionality available to Siri | Apple Developer Documentation

Add assistant schemas to your app so Siri can complete requests, and integrate your app with Apple Intelligence, Spotlight, and other system experiences.

Apple Developer Documentation

Found the missing #SwiftData context did change notification!

extension ModelContext {
public static let didChange = NSNotification.Name(rawValue: "_SwiftDataModelsChangedInContextNotificationPrivate")
}

For those interested here is the other side of the 2 relationships.

This obvious mistake shouldn't even compile. In Code Data's model editor the UI would not even allow you to do this.

Nice work Apple! #SwiftUI #SwiftData and can't even submit an issue 😭

@Relationship(inverse: \Plant.backyard)
public var leadingPlants: [Plant] = []

@Relationship(inverse: \Plant.backyard)
public var trailingPlants: [Plant] = []

SwiftData/Schema.swift:457: Fatal error: Inverse already set to another relationship - leadingPlants - cannot assign to - trailingPlants

https://github.com/apple/sample-backyard-birds

GitHub - apple/sample-backyard-birds

Contribute to apple/sample-backyard-birds development by creating an account on GitHub.

GitHub

#SwiftUI wonder if this is normal? "Duplicate bar buttons appear when .toolbar is applied to a Group View" https://developer.apple.com/forums/thread/762965

Group {
Text("1")
Text("2")
Text("3")
}
.toolbar {
Button("Hi") {
}
}

Duplicate bar buttons appear when … | Apple Developer Forums

Found an annoying bug in #Shortcuts on Mac. The Get File in Folder Action fails with the Documents folder if iCloud Desktop & Documents folder is turned on.

FB14481167 Permissions error with the "Get File from Folder" action with the Documents folder when iCloud Drive's Desktop & Documents folder feature is enabled despite allowing in Privacy alert

http://openradar.appspot.com/radar?id=5501459122618368

rdar://FB14481167: Shortcuts: Permissions error with the "Get File from Folder" action with the Documents folder when iCloud Drive's Desktop & Documents folder feature is enabled despite allowing in Privacy alert

Btw this results in the "Open Favorite Trails" Shortcuts action switching to the Favourites tab in all windows, e.g. in the below screenshot.

The thing I was wondering, should multi-scene be disabled, or should the Shortcut action work on all scenes, or select one scene based on some heuristic like activate the scene already on favourites, if none then use most recently activated?

In the #AppIntents sample, which is designed to show you how to modify navigation from an external Shortcuts action, if you make another window, the navigation is mirrored in both windows because the navigation object is shared between the whole app.

This is a really frustrating issue because it leaves the question, should AppIntents only be used in apps that are not multi-scene and the Apple developer just forgot to disable it in the plist? Or...

https://developer.apple.com/documentation/appintents/acceleratingappinteractionswithappintents

#SwiftUI

Accelerating app interactions with App Intents | Apple Developer Documentation

Enable people to use your app’s features quickly through Siri, Spotlight, and Shortcuts.

Apple Developer Documentation