Skip to content

annurdien/Wing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

27 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

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
Category Features
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
Category Features
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
Feature Description
Calculations β€’ Time difference calculations
β€’ Date manipulation (adding/subtracting days)
Comparison β€’ isToday
β€’ isInPast
β€’ isInFuture
Formatting β€’ String conversion with custom formats
πŸ“š Collection Extensions
Feature Description
Safety β€’ Safe subscript access
Manipulation β€’ Array chunking
β€’ Duplicate removal
β€’ Element swapping
β€’ Element moving
⚑ Optional Extensions
Feature Description
Unwrapping β€’ Convenience unwrapping methods
β€’ Nil coalescing with default values
Utilities β€’ Optional chaining helpers
β€’ Nil-or-empty checking for collections
🎁 Property Wrappers
Wrapper Description
@Clamped Value range restriction
@KeyValueStorage UserDefaults persistence
@Limited Collection/String length limiting
@Masked String pattern masking
@Trimming Automatic whitespace trimming
@Validated Value 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
let encoded = "Hello".base64Encoded // "SGVsbG8="
let decoded = 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

let date = 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
let array = ["a", "b", "c"]
array[safe: 1] // Optional("b")
array[safe: 5] // nil

// Array manipulation
let numbers = [1, 2, 2, 3, 3, 3]
numbers.removingDuplicates() // [1, 2, 3]
numbers.chunked(into: 2) // [[1, 2], [2, 3], [3, 3]]

var mutableArray = ["a", "b", "c"]
mutableArray.move(from: 0, to: 2) // ["b", "c", "a"]

Optional Extensions

import Wing

let optionalValue: String? = "Hello"
let nilValue: String? = nil

// Convenient unwrapping
optionalValue.ifPresent { value in
    print(value) // "Hello"
}

// Default values
nilValue.or("Default") // "Default"

// Optional mapping
optionalValue.mapIfPresent { $0.uppercased() } // Optional("HELLO")

Property Wrappers

import Wing

class Configuration {
    @Clamped(min: 0, max: 100)
    var volume: Int = 50 // Will always be between 0 and 100
    
    @KeyValueStorage("username")
    var username: String = "default" // Persisted in UserDefaults
    
    @Limited(maxLength: 10)
    var shortText: String = "" // Will be truncated if longer than 10 characters
    
    @Trimming
    var userInput: 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

License

Stars

Watchers

Forks

Packages

No packages published

Languages