+ WIP dependency injection

Doesn't work
This commit is contained in:
David Bureš 2025-09-12 21:34:51 +02:00
parent 6d0334ce7f
commit 573daf9930
No known key found for this signature in database
5 changed files with 31 additions and 1 deletions

View File

@ -11,6 +11,21 @@ import CorkShared
import Foundation
import Observation
@preconcurrency import UserNotifications
import FactoryKit
extension Container
{
@MainActor
var appState: Factory<AppState>
{
self {
MainActor.assumeIsolated
{
AppState()
}
}
}
}
/// Class that holds the global state of the app, excluding services
@Observable @MainActor

View File

@ -15,6 +15,7 @@ import Defaults
import SwiftData
import SwiftUI
import UserNotifications
import FactoryKit
// swiftlint:disable type_body_length
@main
@ -22,6 +23,8 @@ struct CorkApp: App
{
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate: AppDelegate
@Injected(\.appConstants) private var appConstants: AppConstants
@State var brewPackagesTracker: BrewPackagesTracker = .init()
@State var tapTracker: TapTracker = .init()

View File

@ -35,6 +35,7 @@ func corkTarget(configureWithSelfCompiled: Bool) -> ProjectDescription.Target {
.external(name: "LaunchAtLogin"),
.external(name: "DavidFoundation"),
.external(name: "ButtonKit"),
.external(name: "FactoryKit"),
.package(product: "SwiftLintBuildToolPlugin", type: .plugin),
.external(name: "Defaults"),
.external(name: "DefaultsMacros")
@ -63,7 +64,8 @@ let corkSharedTarget: ProjectDescription.Target = .target(
"Modules/Shared/**/*.swift"
],
dependencies: [
.external(name: "Defaults")
.external(name: "Defaults"),
.external(name: "FactoryKit")
],
settings: .settings(configurations: [
.debug(

View File

@ -27,6 +27,15 @@
"version" : "9.0.2"
}
},
{
"identity" : "factory",
"kind" : "remoteSourceControl",
"location" : "https://github.com/hmlongco/Factory",
"state" : {
"revision" : "ccc898f21992ebc130bc04cc197460a5ae230bcf",
"version" : "2.5.3"
}
},
{
"identity" : "launchatlogin-modern",
"kind" : "remoteSourceControl",

View File

@ -24,6 +24,7 @@ let package = Package(
// You can read more about dependencies here: https://docs.tuist.io/documentation/tuist/dependencies
.package(url: "https://github.com/sindresorhus/LaunchAtLogin-Modern", .upToNextMajor(from: "1.0.0")),
.package(url: "https://github.com/sindresorhus/Defaults", .upToNextMajor(from: "9.0.2")),
.package(url: "https://github.com/hmlongco/Factory", .upToNextMajor(from: .init(2, 5, 3))),
.package(url: "https://github.com/buresdv/DavidFoundation", .upToNextMajor(from: "2.0.1")),
.package(url: "https://github.com/Dean151/ButtonKit", .upToNextMajor(from: "0.6.1")),
.package(url: "https://github.com/SimplyDanny/SwiftLintPlugins", .upToNextMajor(from: "0.56.1")),