I came across @Dependency in the context of AppIntent. Is this a Swift feature or something specific to AppIntents?
Are there any official documents about it (I couldn't find ones)? I assume it’s related to dependency injection, but I’m not entirely sure how or when it should be used in this context.
struct ResumeTrailActivity: ResumeWorkoutIntent {
static let openAppWhenRun: Bool = true
static let title: LocalizedStringResource = "Resume Trail Activity"
static let description = IntentDescription("Resumes tracking a trail activity.",
categoryName: "Activity Tracking",
searchKeywords: ["workout"])
@Dependency
private var activityTracker: ActivityTracker
func perform() async throws -> some IntentResult {
await activityTracker.resumeActivity()
// Set the Action button functionality back to `NextTrailManeuver`.
return .result(actionButtonIntent: NextTrailManeuver())
}
}