ForgeInject
Macro-based dependency injection for iOS.
Constructor injection. Lazy resolution. Zero boilerplate.
.package(url: "...ForgeInject", from: "1.0.0") Quick Example
import ForgeInject
// 1. Register dependencies
struct AppDependencies: ForgeRegisterProtocol {
func registerDependencies(in container: ForgeContainerProtocol) {
container.register(with: .singleton) { _ in
NetworkService() as NetworkServiceProtocol
}
}
}
// 2. Set up at app launch
let container = ForgeContainer()
AppDependencies().registerDependencies(in: container)
ForgeContainer.shared = container
// 3. Use @Injectable for constructor injection — testable by default
@Injectable
@Observable
final class ProfileViewModel {
let network: NetworkServiceProtocol
func load() async {
let data = try? await network.fetch(from: profileURL)
}
}
// Production: zero-arg init resolves from the container
let vm = ProfileViewModel()
// Tests: pass a mock directly — no container touching
let vm = ProfileViewModel(network: MockNetworkService()) Forge Ecosystem
ForgeInject
currentLightweight dependency injection for iOS. Property wrapper. Thread-safe.
ForgeObservers
Reactive system observers. Connectivity, lifecycle, keyboard, and more.
ForgeStorage
Type-safe persistence. Key-value, file storage, and Keychain.
ForgeBackgroundTasks
BGTaskScheduler registration, scheduling, and dispatch for iOS.
ForgeLocation
Location-based triggers. Geofencing, significant changes, and visits.
ForgePush
Push notification management. Permissions, tokens, and routing.
ForgeOrchestrator
Sequence, pipeline, and monitor orchestrators for iOS app flows.
Why ForgeInject
Constructor Injection
@Injectable generates a testable init with defaults resolved from the container.
Retain Policies
Choose the right lifetime per dependency.
Fine-grained control over memory.
Swift 6 Ready
Built on OSAllocatedUnfairLock. Resolve safely from any actor or isolation context.