Skip to main content

Core API overview

MatrixSwiftBaseCore ships Foundation-only utilities. Import once and reach for the relevant module.

import MatrixSwiftBaseCore

Full type signatures will live in the DocC reference once that lands (#10). This page is the narrative overview with code samples.

Helpers

Stateless public final class FooHelper containers with static methods.

HelperPurpose
AsyncHelpersCommon async / await patterns
BundleHelperApp / framework bundle introspection
CoreDataHelperLightweight Core Data setup helpers
CryptoHelperHashing, key derivation (CryptoKit)
CurrencyHelperCurrency formatting via NumberFormatter
DateHelperDate construction, formatting, arithmetic
DoubleHelperRounding, formatting, conversions
EmojiHelperEmoji utilities
EnvHelperRead environment variables / process info
FaceIdHelperBiometric availability checks
FunctionHelperDebounce / throttle / memoize-style wrappers
GeometryHelperGeometric calculations (no UIKit)
JsonHelperJSON encode/decode convenience
MathHelperclamp, lerp, common math
MimeTypeHelperFilename ↔ MIME type via UniformTypeIdentifiers
RandomHelperRandom numbers, strings, picks
RegexHelperRegex compile-and-test helpers
SleepHelperSleep in ms / seconds (async-safe)
SoundHelperAudio file utilities
StringHelperCommon string transforms
ThreadHelperThread / queue introspection
UnitHelperUnit conversions

Example

let clamped = MathHelper.clamp(150, min: 0, max: 100) // 100
try await SleepHelper.milliseconds(250)
let token = RandomHelper.string(length: 32)
let mime = MimeTypeHelper.mimeType(forFilename: "doc.pdf") // "application/pdf"

Extensions

Drop-in additions to Foundation types.

FileWhat it adds
ArrayExtchunked(into:), subscript(safe:), etc.
BoolExtDisplay / negation helpers
DateExtComponent access, formatting shortcuts
DictionaryExtMerge, transform helpers
SetExttoggle(_:), set algebra sugar
URLExtQuery-item helpers, common transforms

Example

let chunks = [1, 2, 3, 4, 5].chunked(into: 2) // [[1,2],[3,4],[5]]
let safe = ["a", "b"][safe: 5] // nil

var set: Set = [1, 2]
set.toggle(3) // [1, 2, 3]
set.toggle(1) // [2, 3]

Networking

Modern async/await HTTP client built on URLSession.

TypePurpose
APIClientSend Endpoint requests, decode responses
EndpointType-safe request description (path, method, headers, body)
HttpMethodGET / POST / PUT / PATCH / DELETE
RequestBodyJSON / form / multipart payloads
NetworkErrorTyped errors (no Error casts at call site)

Example

struct User: Decodable { let id: Int; let name: String }

let endpoint = Endpoint<User>(
path: "/users/me",
method: .get
)

let client = APIClient(baseURL: URL(string: "https://api.example.com")!)
let user = try await client.send(endpoint)

Retry policy is on the roadmap (TODOS.md).

Concurrency

TypePurpose
IntervalHelperRepeating timer wrappers compatible with structured concurrency

Errors / Logging

TypePurpose
AppErrorTyped application-level error enum
AppLoggeros.Logger wrapper with category + level helpers

Managers

Stateful objects that aren't UI but still hold long-lived state.

ManagerPurpose
KeychainManagerSave / load / delete to the system keychain
LocationManagerCLLocationManager wrapper

Models

Value-typed enums / structs used across the library.

ModelPurpose
ImageFileTypes.jpg / .png / .heic / etc.
LocalNotificationNotification payload struct
SoundFileTypes.mp3 / .wav / .caf / etc.
SystemThemes.light / .dark / .system

Validations

TypePurpose
ValidationsEmail / phone / URL / general string validators. Will be expanded into a Validator<T> protocol layer per TODOS.md.