KeyPath dynamicMemberLookup based syntax sugar for Swift, enabling fluent property setting and method chaining.
DuctTape is a Swift library that provides syntax sugar for configuring objects using KeyPath dynamicMemberLookup. It enables a fluent, chainable builder pattern for setting properties and calling methods, reducing boilerplate code in Swift projects, particularly for UI configuration in Apple platforms.
Swift developers building iOS, macOS, tvOS, or watchOS apps who want cleaner, more readable code for object configuration, especially when working with UIKit/AppKit components.
Developers choose DuctTape for its concise syntax that eliminates repetitive property assignment, seamless integration with existing NSObject-based classes, and flexibility to handle both properties and methods in a single chain.
📦 KeyPath dynamicMemberLookup based syntax sugar for Swift.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses KeyPath dynamicMemberLookup to enable chainable property assignments, eliminating repetitive code as shown in the UILabel configuration example.
Automatically works with UIKit components via the .ductTape property, requiring no extra setup for common Apple frameworks like UIView or UILabel.
The reinforce method allows calling object methods within the chain, enabling complex configurations such as registering collection view cells without breaking flow.
Extendable to any Swift class through DuctTapeCompatible or direct Builder usage, making it versatile beyond Apple's built-in frameworks.
Custom classes not inheriting from NSObject require manual protocol conformance or using the Builder initializer, adding boilerplate that undermines the library's simplicity goal.
Methods must be called inside reinforce closures, interrupting the fluent chain and reducing readability compared to seamless property setters, as seen in the collectionView example.
The library doesn't natively support error propagation in chains; throwing methods must be awkwardly wrapped in reinforce with do-catch blocks, complicating code.