Thread-safe primitives for iOS Swift packages.
ForgeCore is the shared foundation for the Forge family of iOS packages. It provides a small, focused set of thread-safe primitives built on Swift 6's Synchronization framework.
Most consumers use ForgeCore indirectly through other Forge packages. You only import it directly when you need its primitives in your own code.
LockedState<State>— thread-safe mutable state container wrappingMutex<State>from the standard librarySynchronizationframework. Typed-throws,sendingparameter semantics, no@unchecked Sendableescape hatches.SendableFileManager— aSendable-conforming wrapper aroundFileManagerfor safe use in concurrent contexts.- Zero dependencies — ForgeCore has no external dependencies beyond the Swift standard library and Foundation.
- iOS 18+
- macOS 15+
- Swift 6.3+ (Xcode 26 or later)
- File → Add Package Dependencies…
- Paste
https://github.com/stefanprojchev/ForgeCore.git - Set rule to Up to Next Major from
1.0.0
dependencies: [
.package(url: "https://github.com/stefanprojchev/ForgeCore.git", from: "1.0.0")
],
targets: [
.target(
name: "YourApp",
dependencies: ["ForgeCore"]
)
]import ForgeCore
// Thread-safe mutable state — no locks, no @unchecked, no races.
let cache = LockedState<[String: User]>([:])
cache.withLock { dict in
dict["alice"] = User(name: "Alice")
}
let alice = cache.withLock { $0["alice"] }Typed-throws propagate concrete error types:
enum CacheError: Error { case full }
do {
try cache.withLock { (dict: inout [String: User]) throws(CacheError) in
guard dict.count < 100 else { throw CacheError.full }
dict["bob"] = User(name: "Bob")
}
} catch {
// error is statically typed as CacheError
}import ForgeCore
let fm = SendableFileManager()
// Pass freely across isolation domains — it's Sendable.
actor FileService {
let fm: FileManaging
init(fm: FileManaging = SendableFileManager()) {
self.fm = fm
}
func exists(_ path: String) -> Bool {
fm.fileExists(atPath: path)
}
}ForgeCore is part of the Forge family of Swift packages for iOS.
| Package | Description |
|---|---|
| ForgeCore | Thread-safe primitives for iOS Swift packages. |
| ForgeInject | Dependency injection with constructor and property wrapper support. |
| ForgeObservers | Reactive system observers — connectivity, lifecycle, keyboard, and more. |
| ForgeStorage | Type-safe key-value, file, and Keychain storage. |
| ForgeOrchestrator | Orchestrate app flows — startup gates, data pipelines, and continuous monitors. |
| ForgePush | Push notification management — permissions, tokens, and routing. |
| ForgeLocation | Location triggers — geofencing, significant changes, and visits. |
| ForgeBackgroundTasks | Background task scheduling and dispatch. |
ForgeCore is released under the MIT License. See LICENSE.