Skip to content

Repository files navigation

Wing Logo

Wing

Swift 6+iOS 15.0+macOS 10.15+MIT

A powerful Swift library providing comprehensive extensions for standard Swift types and Foundation/UIKit classes, designed to enhance developer productivity and simplify common programming tasks.

📖 Table of Contents

✨ Features

🔤 String Extensions
CategoryFeatures
Encoding/Decoding• Base64 encoding/decoding
• URL encoding/decoding
• UTF-8 encoding/decoding
Text Manipulation• Case transformations (camelCase, snake_case, kebab-case)
• Trimming whitespace
• Padding
• Truncating
• Removing HTML tags
• String reversal
Validation• URL validation
• Hexadecimal validation
• Custom character set validation
Formatting• Currency formatting
• Percentage formatting
• Number formatting
Generation• Random string generation (alphanumeric, alphabetic, numeric)
Hashing• SHA1
• SHA256
🔢 Number Extensions
CategoryFeatures
Mathematical Operations• Power calculation
• Square root
• Rounding and formatting
Utilities• Range clamping
• Random number generation
• Type conversions
Formatting• Currency formatting
• Time interval conversions
📅 Date Extensions
FeatureDescription
Calculations• Time difference calculations
• Date manipulation (adding/subtracting days)
ComparisonisToday
isInPast
isInFuture
Formatting• String conversion with custom formats
📚 Collection Extensions
FeatureDescription
Safety• Safe subscript access
Manipulation• Array chunking
• Duplicate removal
• Element swapping
• Element moving
⚡ Optional Extensions
FeatureDescription
Unwrapping• Convenience unwrapping methods
• Nil coalescing with default values
Utilities• Optional chaining helpers
• Nil-or-empty checking for collections
🎁 Property Wrappers
WrapperDescription
@ClampedValue range restriction
@KeyValueStorageUserDefaults persistence
@LimitedCollection/String length limiting
@MaskedString pattern masking
@TrimmingAutomatic whitespace trimming
@ValidatedValue validation

📦 Installation

Swift Package Manager

Add Wing to your Package.swift file:

dependencies:[.package(url:"https://github.com/annurdien/Wing.git", from:"1.0.0")]

🚀 Usage Examples

String Extensions

import Wing
// Base64 encoding/decoding
letencoded="Hello".base64Encoded // "SGVsbG8="
letdecoded= encoded?.base64Decoded // "Hello"
// Case transformations
"helloWorld".snakeCased // "hello_world"
"hello-world".camelCased // "helloWorld"
"hello world".kebabCased // "hello-world"
// String validation
"https://example.com".isValidURL // true
"FF00FF".isHexadecimal // true
// String manipulation
" Hello World ".trimmed // "Hello World"
"Hello".padding(toLength:10, withPad:"*") // "Hello*****"
"Hello World".truncate(length:8) // "Hello..."

Number Extensions

import Wing
// Mathematical operations
5.squared // 25
16.squareRoot() // 4.0
2.power(3) // 8
// Formatting
123.456.formatted(withFractionDigits:2) // "123.46"
1234.currencyFormatted(locale:Locale(identifier:"en_US")) // "$1,234.00"
// Time intervals
5.minutes // TimeInterval(300)
2.hours // TimeInterval(7200)

Date Extensions

import Wing
letdate=Date()
date.isToday // true
date.isInPast // false
date.isInFuture // false
// Date formatting
date.toString("yyyy-MM-dd") // "2025-04-21"
date.toString(dateStyle:.full, timeStyle:.short) // "Sunday, April 21, 2025 at 10:30 AM"
// Date manipulation
date.addingDays(7) // Date one week from now
date.days(from:Date()) // 0

Collection Extensions

import Wing
// Safe subscript access
letarray=["a","b","c"]array[safe:1] // Optional("b")
array[safe:5] // nil
// Array manipulation
letnumbers=[1,2,2,3,3,3]
numbers.removingDuplicates() // [1, 2, 3]
numbers.chunked(into:2) // [[1, 2], [2, 3], [3, 3]]
varmutableArray=["a","b","c"]
mutableArray.move(from:0, to:2) // ["b", "c", "a"]

Optional Extensions

import Wing
letoptionalValue:String?="Hello"letnilValue:String?=nil
// Convenient unwrapping
optionalValue.ifPresent{ value inprint(value) // "Hello"
}
// Default values
nilValue.or("Default") // "Default"
// Optional mapping
optionalValue.mapIfPresent{ $0.uppercased()} // Optional("HELLO")

Property Wrappers

import Wing
classConfiguration{@Clamped(min:0, max:100)varvolume:Int=50 // Will always be between 0 and 100
@KeyValueStorage("username")varusername:String="default" // Persisted in UserDefaults
@Limited(maxLength:10)varshortText:String="" // Will be truncated if longer than 10 characters
@TrimmingvaruserInput:String="" // Whitespace will be automatically trimmed
}

⚙️ Requirements

  • iOS 15.0+
  • Swift 6.0+
  • Xcode 15.0+

📚 Documentation

Building Documentation

# Generate documentation using DocC
xcodebuild docbuild -scheme Wing -destination generic/platform=iOS
# View in Xcode
Product > Build Documentation (⌘ + ⇧ + D)

Online Documentation

Visit our online documentation for detailed API references and guides.

👥 Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Write tests for your changes
  4. Commit your changes (git commit -m 'Add amazing feature')
  5. Push to the branch (git push origin feature/amazing-feature)
  6. Open a Pull Request

For major changes, please open an issue first to discuss what you would like to change.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

👨‍💻 Author

Annurdien Rasyid


Made with ❤️ by Annurdien Rasyid

About

Collection of native Swift extensions and property wrappers

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages