Skip to content

Repository files navigation

ForgeCore

Thread-safe primitives for iOS Swift packages.

Swift 6.3+iOS 18+macOS 15+LicenseRelease


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.

Features

  • LockedState<State> — thread-safe mutable state container wrapping Mutex<State> from the standard library Synchronization framework. Typed-throws, sending parameter semantics, no @unchecked Sendable escape hatches.
  • SendableFileManager — a Sendable-conforming wrapper around FileManager for safe use in concurrent contexts.
  • Zero dependencies — ForgeCore has no external dependencies beyond the Swift standard library and Foundation.

Requirements

  • iOS 18+
  • macOS 15+
  • Swift 6.3+ (Xcode 26 or later)

Installation

Xcode

  1. File → Add Package Dependencies…
  2. Paste https://github.com/stefanprojchev/ForgeCore.git
  3. Set rule to Up to Next Major from 1.0.0

Package.swift

dependencies:[.package(url:"https://github.com/stefanprojchev/ForgeCore.git", from:"1.0.0")],targets:[.target(
name:"YourApp",
dependencies:["ForgeCore"])]

Quick Start

LockedState

import ForgeCore
// Thread-safe mutable state — no locks, no @unchecked, no races.
letcache=LockedState<[String:User]>([:])
cache.withLock{ dict indict["alice"]=User(name:"Alice")}letalice= cache.withLock{$0["alice"]}

Typed-throws propagate concrete error types:

enumCacheError:Error{case full }do{try cache.withLock{(dict:inout[String:User])throws(CacheError)inguard dict.count <100else{throwCacheError.full }dict["bob"]=User(name:"Bob")}}catch{
// error is statically typed as CacheError
}

SendableFileManager

import ForgeCore
letfm=SendableFileManager()
// Pass freely across isolation domains — it's Sendable.
actorFileService{letfm:FileManaginginit(fm:FileManaging=SendableFileManager()){self.fm = fm
}func exists(_ path:String)->Bool{
fm.fileExists(atPath: path)}}

The Forge Family

ForgeCore is part of the Forge family of Swift packages for iOS.

PackageDescription
ForgeCoreThread-safe primitives for iOS Swift packages.
ForgeInjectDependency injection with constructor and property wrapper support.
ForgeObserversReactive system observers — connectivity, lifecycle, keyboard, and more.
ForgeStorageType-safe key-value, file, and Keychain storage.
ForgeDBType-safe repository pattern and GRDB-backed SQLite persistence.
ForgeOrchestratorOrchestrate app flows — startup gates, data pipelines, and continuous monitors.
ForgePushPush notification management — permissions, tokens, and routing.
ForgeLocationLocation triggers — geofencing, significant changes, and visits.
ForgeBackgroundTasksBackground task scheduling and dispatch.
ForgeNetworkingTyped, async/await-first HTTP networking with auth, retry, and background transfers.
ForgeLogStructured logging with pluggable providers and a built-in inspector UI.
ForgeAccessSubscription-aware feature gating with override channels and debug UI.

License

ForgeCore is released under the MIT License. See LICENSE.

About

Thread-safe primitives for iOS Swift packages.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages