Well, as seems to be all too often and embarassingly the case - ask a question in public, and suddenly the answer reveals itself...
As it turns out I wasn't actually removing all objects in the update: closure and then replacing them - I was adding rebuilding them in my graph but not in the RealityView update: closure. Dumb oversight.
TL;DR: I was expecting the @Published values to automagically update the 3D content - much the same way that SwiftUI automatically updates 2D textfields and such. That isn't what happens in the RealityView update: closure.
So, the solution was simple:
} update: { updateContent in
updateContent.entities.removeAll()
graph.renew()
for element in graph.all {
updateContent.add(element)
}
}
where graph is a custom object that contains my RealityKit scene.
Post
Replies
Boosts
Views
Activity
Any luck figuring this out? I've been stumped for a couple of days on the exact same issue...
Instead of Virtualization, I went with the dual-boot option. I need to run production releases of Ventura and Xcode in order to support my apps in the AppStore - but I wanted to begin work on my VisionOS app too. This setup works like a charm for me...
https://support.apple.com/en-us/HT208891
and if you're looking specifically for VisionOS sample code...
https://developer.apple.com/documentation/visionos/world
Be fine for what - development? No way is 8 GB enough. I've got 2 SwiftUI apps in the AppStore, and both were developed on a 2020 M1 MacBook Air with 16GB RAM. Working with Xcode 15 beta 2 and VisionOS simulator, it comes to a crawl. My best guess is that this is a memory issue more than a processor issue. Bottom line: the M2 Mac mini would most likely be fine, but DEFINITELY buy the most RAM you can.
To make it explicit, this works:
@main
struct SwiftDataFlashCardSample: App {
let container: ModelContainer
init() {
let schema = Schema([Card.self])
let config = ModelConfiguration(schema: schema, cloudKitContainerIdentifier: "iCloud.org.your.name")
var contain: ModelContainer? = nil
do {
contain = try ModelContainer(for: schema, config)
} catch {
print("couldn't create ModelContainer()")
}
self.container = contain!
}
var body: some Scene {
WindowGroup {
ContentView()
}
.modelContainer(container)
}
}
and, as normal, add Capabilities iCloud.cloudKit and BackgroundModes.Remote notifications.
This worked:
@main
struct SwiftDataFlashCardSample: App {
let container: ModelContainer
init() {
let schema = Schema([Card.self])
let config = ModelConfiguration(schema: schema, cloudKitContainerIdentifier: "iCloud.org.your.name")
var contain: ModelContainer? = nil
do {
contain = try ModelContainer(for: schema, config)
} catch {
print("couldn't create ModelContainer()")
}
self.container = contain!
}
var body: some Scene {
WindowGroup {
ContentView()
}
.modelContainer(container)
}
}
and, as normal, add Capabilities iCloud.cloudKit and BackgroundModes.Remote notifications.
I transitioned from UIKit based coding to SwiftUI coding 2 years ago. SwiftUI is a completely different mindset, and it can be awkward to get SwiftUI to do UIKit kinds of things. With respect to TextField delegate methods and SwiftUI state variables - one way of thinking about it that worked for me was to gather together all of the data that you need to paint your view, and put that into either State variables or a data object. Example, instead of allowing the name, address, city and state TextFields to hold the data, it's better to define an Address struct that has those same data fields. Then, your SwiftUI app just paints the values that are in the Address struct.
Here's something else that really helped me make the transition: in UIKit programming, we tend to think of a TextField as having its own behaviors - like it holds the data for the name or address, and when the user types in that field, then the Textfield is responsible for updating it's value. In addition, it may be responsible for communicating that change to other objects in your app. In contrast, in SwiftUI, it's easiest to think about how the SwiftUI system throws away and re-creates any views whose data is no longer supporting the way the view is being painted. The data changes, then the View is discarded and re-created.
My suggestion would be to watch WWDC23's "Build an app with SwiftData" and just notice how different it is from UIKit. SwiftUI has evolved tremendously over the past 3 years, and it's now awesome expressive - but in it's own, unique way.
I didn’t realize this, but there’s an (i) button in Apple’s Shortcuts app - and when tapped it shows 2 toggles. One of which enables Spotlight, and the other enables Siri.
The solution to my question was provided via Apple’s Feedback Assistant - I just needed to (a) know about this setting, and (b) ensure the Siri toggle was turned on.
Happens to me too on Xcode Version 14.2 (14C18), Watch OS 9.3.1 (20S664)
Oracle for the win! I quit messing with "brew install java" and instead downloaded the .dmg for openJKD directly from Oracle and that worked.
Here's another piece of the puzzle... I added another invocation to AppShortcut.phrases "show my top (.applicationName) cards" - and instead of doing the right thing or even launching Safari, this phrase launches a Siri disambiguation showing all the credit cards I have defined in my Apple Wallet. Further circumstantial evidence that Siri is pre-disposed to satisfying Apple-defined Intents before mine.
For any who stumble across this question... I've not tried OP's let shortcut = / return [shortcut] implementation - instead I did this and it works for me:
struct NotesShortcutProvider: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut(intent: ShowTodayTasks(), phrases:["Show today tasks, "show my tasks today"]) } }
I've hacked my way into a solution... turns out that:
I only need to call .updateAppShortcutParameters() once
that call to .updateAppShortcutParameters() needs to include an AppShortcut(intent:, phrases:) call for each AppIntent I've written
the AppShortcutsProvider's appShortcuts:[AppShortcut] array is initialized in a way that I was not expecting... ie, you don't need []s around nor commas between array elements
so, this is what it looks like:
static var appShortcuts: [AppShortcut] {
AppShortcut(intent:IntentOne(), phrases:["phrase 1"] // no commas!
AppShortcut(intent:IntentTwo(), phrases:["phrase 2"]
}
Still non-functional in Ventura 13.1 Beta (22C5050e)