Post

Replies

Boosts

Views

Activity

Reply to How to use `.focusedSceneObject()` with @Observable?
I'm just migrating some ObservedObjects to Observable and ran into this problem with a Commands menu with a FocusedObject dependency. I want some entries in the menu to be enabled and to act on state from the Observable object. What finally worked for me (so far) is using a FocusedValues extension. I couldn't get this to work without the key path API, despite what the documentation says, and there doesn't appear to be a single example on the Internet. struct MyFocusedObservableStateValue: FocusedValueKey { typealias Value = MyObservableStateType } extension FocusedValues { var myObservableState: MyFocusedObservableStateValue.Value? { get { self[MyFocusedObservableStateValue.self] } set { self[MyFocusedObservableStateValue.self] = newValue } } } struct ItemActionsCommandMenu: Commands { @FocusedValue(\.myObservableState) var myObservableState var body: some Commands { CommandMenu("Menu Name") { // use myObservableState as needed (Note: It's optional) Button("Action") { } .disabled(...) } } } Elsewhere in App: myContentView .focusedSceneValue(\.myObservableState, myObservableState)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’25
Reply to Why does my universal links not work??
Can you clarify how you are testing the links? I've found that the simulator will not always open the links in my app, especially via Safari opening it in. The most reliable method for me has been to put the link into Reminders or another system app and then tap on it.
Topic: Safari & Web SubTopic: General Tags:
Jun ’24
Reply to AppIntentsPackage protocol with SPM package not working
As far as I can tell, reexporting an AppIntent defined in a framework using AppIntentsPackage and includedPackages has never worked since it was introduced at WWDC23. @gohnjanotis @alexanderwe I believe the only solution is to add your app intents directly to your app target and also any other extension target that uses them, I was able to get my shortcuts showing up in Shortcuts doing this. Unfortunately this workaround wouldn't work for an AppIntent defined in an SPM package like in the original question prompt.
Topic: App & System Services SubTopic: General Tags:
Sep ’23
Reply to AppIntentsPackage protocol with SPM package not working
Agree, I'm seeing the same thing here. It looks like prefixing AppIntents. in the shortcut provider actually just hides the shortcuts entirely from the metadata parser. if you look at the built Metadata.appintents/extract.actionsdata in derived data, it's clear the AppShortcutsProvider is detected correctly but that the intents, entities, and queries are not detected from the underlying package / framework. Assuming a beta bug with the package intent re-exporting at this point, too.
Topic: App & System Services SubTopic: General Tags:
Jun ’23
Reply to AppIntentsPackage protocol with SPM package not working
+1. I have roughly the same setup except I'm using a dynamic framework instead of a SPM package. I got the same error when I reference my AppIntent in a AppShortcutsProvider. Weirdly enough I just discovered that prefixing all the AppShortcut types with AppIntents fixed the issue for me. import AppIntents import MyIntentsFramework struct MyShortcutsProvider: AppShortcutsProvider { static var appShortcuts: [AppIntents.AppShortcut] { AppIntents.AppShortcut( intent: MyAppIntent(), phrases: ["Open \(.applicationName)"], shortTitle: "Title", systemImageName: "plus" ) } }
Topic: App & System Services SubTopic: General Tags:
Jun ’23