Swift libraries
Some potentially useful Swift libraries:
Area | Library | Comments |
---|---|---|
GCD | Async | appears to be a simple useful framework |
Future, Promises | BrightFutures | Swift futures and promises. See also Searching for a Swift Future library |
Mocking HTTP | Nocilla | |
NSDate | TimePiece | Various NSDate helpers |
Keychain | KeychainAccess | Keychain API needs wrapping |
JSON | SwiftyJSON, Argo, Gloss, Freddy, … | Argo is modelled after Haskell’s Aeson which might put of some developers; SwiftyJSON looks possibly simpler and Gloss appears to be inspired by Argo. “Freddy is type safe and idiomatic” and finally a comparison of JSONJoy, SwiftyJSON & OCMapper |
Testing | Assertions, Quick, FBSnapShotTestCase | Assertions: This is a Swift µframework providing simple, flexible assertions for XCTest in Swift; Quick: Quick is a behavior-driven development framework for Swift and Objective-C. Inspired by RSpec, Specta, and Ginkgo. FBSnapShotTestCase: Compares a snapshot to a “reference image” stored in your source code repository and fails the test if the two images don’t match. |
QuickCheck style testing | Fox, SwiftCheck | Similar to QuickCheck on Haskell, see presentation on Fox and the Erlang Elevator QuickCheck example mentioned in the talk. From SwiftCheck: “With the power of SwiftCheck and a sufficiently expressive testing suite, we can begin to check our programs not for individual passing cases in a few scattershot unit tests, but declare and enforce immutable properties that better describe the intent and invariants of our programs.” |
Managing complexity of interactions | ReactiveCocoa | Cocoa framework inspired by Functional Reactive Programming. It provides APIs for composing and transforming streams of values over time |
Result<Value, Error> | Result | Result<Value, Error> values are either successful (wrapping Value) or failed (wrapping Error). This is similar to Swift’s native Optional type, with the addition of an error value to pass some error code, message, or object along to be logged or displayed to the user. |
“Libraries to simplify development of Swift programs by utilising the type system” | TypeLift | SwiftCheck (QuickCheck for Swift), Swiftx (Functional data types and functions for any project), Focus (Optics for Swift), Aquifer (Functional streaming abstractions in Swift), Swiftz (Swiftz is a Swift library for functional programming), Concurrent (Functional Concurrency Primitives), Operadic (Standard Operators for the working Swift Librarian), Basis (Pure Declarative Programming in Swift, Among Other Things), Algebra (Abstract Algebraic Structures in Swift) |
code composition | Stream | Lazy streams in Swift |
Logging | CleanroomLogger | The API provided by CleanroomLogger is designed to be readily understood by anyone familiar with packages such as CocoaLumberjack and log4j |
HTTP networking library | Alamofire | Swift version of AFNetworking |
Nothing but net(working) | Swish | Protocol based http library |
Functional programming in Swift | Swiftz | Swiftz implements higher-level data types like Arrows, Lists, HLists, and a number of typeclasses integral to programming with the maximum amount of support from the type system |
Dependency Injection | Dip | “Dip is inspired by .NET’s Unity Container”. See also: “Function programming in Swift” 2015 conference - DI in Swift video. I’m sure there are other DI frameworks out there… |
Autolayout | PureLayout | PureLayout extends UIView/NSView, NSArray, and NSLayoutConstraint with a comprehensive Auto Layout API that is modeled after Apple’s own frameworks. PureLayout is a cross-platform Objective-C library that works (and looks!) great in Swift |
AttributedStrings | BonMot | BonMot is a Swift attributed string library |
Threading | Async | Syntactic sugar in Swift for asynchronous dispatches in Grand Central Dispatch |
I still haven’t found Swift equivalents of:
Area | Library | Comments |
---|---|---|
Mocking | OCMock | Extensive use of Swift protocols minimises the need for mocks. Using locally defined classes for mocking see Mocking in Swift. Quote: “In Swift, classes can be declared within the definition of a function, allowing for mock objects to be extremely self-contained. Just declare a mock inner-class, override and necessary methods” |
See also:
- A collaborative list of awesome swift resources
- Awesome Swift - A curated list of awesome Swift frameworks, libraries and software.