The Swift Helpers package provides miscellaneous helpers, including extensions and custom types. The helpers are organized into modules listed below. See the documentation or browse the source files for more information on usage or implementation details.
- Bindings:
NSKeyValueBindingCreationinformal protocol unbind helper. - Controllers:
NSTreeControllerproperties for getting the topmost selection. - Input:
EventMonitorwrapper forNSEvent’s app monitoring methods. - Menu:
NSMenuItemconvenience initializer, label item constructor. - Touch bar:
NSTouchBaritems property,AlertStyleGroupTouchBarItemclass. - Views:
NSBrowser,NSImage,NSResponder,NSTableView,NSViewextensions,ModalViewclass.
CALayer,CAMediaTimingextensions.
NSManagedObjectContext,NSManagedObjectextensions.
CGFloat,CGSizeextensions.
dumpOutput(_:name:indent:maxDepth:maxItems:)returning a dump as a string.StopwatchandSplitStopwatchfor measuring elapsed and lap times.CallCounterfor counting the number or balance of calls.ThreadCounterfor counting and listing concurrent code threads.Threadnumber getter.
ExitCodeProtocol,ExitCodeProvidingErrorprotocols.exit(_:)overloads for terminating with exit codes.
- Collections:
IndexPathnode inspection methods. - Data: creating and inspecting
Datausing set bit indices. - Operations:
OperationQueueandBlockOperationhelpers. - Processes:
Processshell script initializer,runUntilExit()asynchronous wrapper. - Scheduling:
Timerconvenience constructor. - Preferences:
UserDefault,UserDefaultRawRepresented, andUserDefaultJSONEncodedproperty wrappers. - Resources:
Bundleinformation helpers. - Strings and text:
CharacterSetscalars getter. - URLs and URIs:
URLComponentsandURLhelpers for normalizing URLs according to RFC 3986;URLComponentsandURLhelpers for validating and deriving a base URL according to RFC 3986;URLhelpers for relativizing URLs, stem and filename components getters, and others;URLconformance toComparable;URIReferenceKindenumeration;URLBookmarkstructure;HierarchicalPathstructure for path components comparison, normalization, and manipulation;FilenameComponentsstructure for containing directory, stem, and extension manipulation.
- URL loading system:
HTTPURLResponsestatus helpers.
- Strings and text:
NSRegularExpressionmatch operator, searching and replacing helpers;NSTextCheckingResultrange, capture group, and line number helpers;Stringhelpers for escapingNSRegularExpressionpattern and template characters.
ExtendedLoggerprotocol and implementations for logging a location in source code.LegacyLoggerstructure resemblingLoggerfor earlier versions of deployment targets.StringfilePoint()static method returning a string reference to a location in source code.
print(_:separator:terminator:to:)overloads for writing into a file handle or the output stream of the given kind.BufferedOutputclass for buffering output streams, accompanied by theBufferedOutputProvidingprotocol andBufferedOutputCollectorclass.Processhelpers for getting flattened or buffered output.OutputStreamKindsupporting enumeration.FileHandleconformance toTextOutputStream.
- Strings and text:
Regexmatch operator;StringUnicode scalar initializer, truncation, and quoted path helpers;StringProtocolhelpers for changing case, padding, and trimming;Unicode.Scalarcharacter initializer.
- Collections:
Collectionhelper for transforming an empty collection tonil, and a helper for joining optional strings;KeyValuePairsformatting helper for monospaced output;Sequencecompactedmethod;Setinitializer for strings with a separator.
- Atomic property wrappers.
Add the package dependency using its URL:
https://github.com/processed-bits/swift-helpers
Add the package-level dependency on the Swift Helpers package:
dependencies: [
.package(url: "https://github.com/processed-bits/swift-helpers", from: "3.0.0"),
]Add target-level dependencies on the required libraries:
dependencies: [
.product(name: "AppKitHelpers", package: "SwiftHelpers"),
.product(name: "CoreAnimationHelpers", package: "SwiftHelpers"),
.product(name: "CoreDataHelpers", package: "SwiftHelpers"),
.product(name: "CoreGraphicsHelpers", package: "SwiftHelpers"),
.product(name: "DebuggingHelpers", package: "SwiftHelpers"),
.product(name: "ExitCodeHelpers", package: "SwiftHelpers"),
.product(name: "FoundationHelpers", package: "SwiftHelpers"),
.product(name: "FoundationLegacyHelpers", package: "SwiftHelpers"),
.product(name: "LoggingHelpers", package: "SwiftHelpers"),
.product(name: "OutputHelpers", package: "SwiftHelpers"),
.product(name: "StandardLibraryHelpers", package: "SwiftHelpers"),
.product(name: "SynchronizationHelpers", package: "SwiftHelpers"),
]Documentation is available:
- In Xcode, use
Build Documentation(⌃⇧⌘D) from theProductmenu. - Online at Swift Package Index.
- As documentation archives, see the ‘DocC Plugin Documentation Archive’ section below.
Note
Xcode versions prior to 15 don’t generate documentation for extensions to types from other modules.
Add a package-level dependency on the DocC plugin:
dependencies: [
.package(url: "https://github.com/swiftlang/swift-docc-plugin", from: "1.3.0"),
],Generate documentation archives, then open them with Xcode to import:
swift package generate-documentationThis package follows the evolution of the Swift language, its cross-platform packages, and aims to support the latest versions of Swift on all Apple platforms and Linux. Compatibility with older Swift versions is not guaranteed, but a reasonable effort is made to support them.
See CHANGELOG.md.
Copyright © 2022-2025 Stanislav Lomachinskiy. Licensed under the MIT License.