ryanfrancesconi/spfk-base
The foundational layer for the SPFK package ecosystem. SPFKBase provides core utilities, type extensions, and shared infrastructure used across all SPFK packages.
Overview
SPFKBase is a Swift package containing common extensions, type definitions, logging, and testing utilities that form the base dependency for higher-level SPFK packages. It includes a companion Objective-C/C++ module (SPFKBaseC) for bridging Objective-C exception handling into Swift.
Requirements
- Platforms: macOS 13+, iOS 16+
- Swift: 6.2+
Features
Logging
A lightweight logging layer built on Apple's os_log system with categorized log channels (info, debug, error, points-of-interest) and build-configuration gating. Debug and verbose logging is automatically stripped from release builds.
Exception Handling
Bridges Objective-C @try/@catch exception handling into Swift through the SPFKBaseC module, allowing Swift code to safely catch Objective-C exceptions that would otherwise be fatal.
Type Definitions
MovementDirection-- An enum representing directional movement (up/down) with numeric, boolean, and string conversions.FloatChannelData-- A multi-channel floating-point buffer backed byUnsafeMutablePointer<UnsafeMutablePointer<Float>?>, used for interleaved/deinterleaved audio data.UnitInterval-- A type-safe wrapper constraining floating-point values to the 0...1 range.Benchmark-- A simple start/stop timer for measuring execution duration of code blocks.
Extensions
String
- ASCII filtering, whitespace normalization, abbreviation from camelCase/PascalCase names
- Spaced title-case conversion, case-insensitive comparison, standard locale-aware sorting
- Delimiter-based splitting, boolean parsing, URL encoding
- C-string interop utilities
Collections
- Generalized element movement (bring-to-front, send-to-back, move by offset)
- Quantity descriptions with pluralization ("1 item" vs "3 items")
- Delimited string joining with configurable separators and terminal conjunctions
- Case-insensitive string search, numeric type conversions (
compactMaptoInt,UInt32,Double)
Floating Point
- Rounding to arbitrary divisors with configurable rounding rules
- Array mean/average computation for
FloatandDoublecollections - Unit interval range (
0...1) as a static property
URL
- File existence, readability, and size checks
- Remote URL detection, path containment tests, tilde resolution
- Directory creation, listing, emptiness checks, and deletion
- MIME type lookup via
UTType, resource value accessors (dates, hidden, alias/symlink detection) - Query string construction with percent-encoding
Bool
- Initialization from any
BinaryInteger(zero isfalse, non-zero istrue)
NSError / NSException
- Convenience initializers for
NSErrorwith description, domain, code, and source location NSExceptiontoNSErrorconversion preserving call stack information
Geometry
NSRectconstruction fromNSSize,CGFloatpairs, andIntpairs- Center-point computation for
NSRect
Other
FileManagerextensions for file date retrievalNotificationCenterasync observation helpersTaskcancellation utilitiesAsyncSequencecollection into arraysFourCharCode(UInt32) string conversion for Audio Unit type identifiersTypeDescribableprotocol for runtime type name access
Testing Utilities
TestCaseModel-- A protocol for test fixtures that manages temporary directories and provides access to bundled test resources.BinTestCase-- A specialized test case model for binary/audio file testing with automatic cleanup.
Dependencies
Installation
Add SPFKBase to your Package.swift:
dependencies: [
.package(url: "https://github.com/ryanfrancesconi/spfk-base", from: "0.0.5"),
]Then add it as a dependency to your target:
.target(
name: "YourTarget",
dependencies: [
.product(name: "SPFKBase", package: "spfk-base"),
]
)License
Copyright Ryan Francesconi. All Rights Reserved.
About
Spongefork (SPFK) is the personal software projects of Ryan Francesconi. Dedicated to creative sound manipulation, his first application, Spongefork, was released in 1999 for macOS 8. From 2016 to 2025 he was the lead macOS developer at Audio Design Desk.
Package Metadata
Repository: ryanfrancesconi/spfk-base
Default branch: main
README: README.md