A handy collection of more than 500 native Swift extensions to boost your productivity.

Overview

Build Status Platforms Cocoapods Carthage compatible SPM compatible Accio supported codecov docs Swift Xcode MIT Slack Channel

SwifterSwift is a collection of over 500 native Swift extensions, with handy methods, syntactic sugar, and performance improvements for wide range of primitive data types, UIKit and Cocoa classes –over 500 in 1– for iOS, macOS, tvOS, watchOS and Linux.

Whats New in v5.3?

Requirements

  • iOS 10.0+ / tvOS 9.0+ / watchOS 2.0+ / macOS 10.10+ / Ubuntu 14.04+
  • Swift 5.0+

Looking to use SwifterSwift for older versions of Swift

SwifterSwift is Swift v5.0+ compatible starting from v5

  • To use with Swift 3 / Xcode 8.x please ensure you are using v3.1.1.
  • To use with Swift 3.2 / Xcode 9.x please ensure you are using v3.2.0.

Installation

CocoaPods

To integrate SwifterSwift into your Xcode project using CocoaPods, specify it in your Podfile:

- Integrate All extensions (recommended):

pod 'SwifterSwift'

- Integrate SwiftStdlib extensions only:

pod 'SwifterSwift/SwiftStdlib'

- Integrate Foundation extensions only:

pod 'SwifterSwift/Foundation'

- Integrate UIKit extensions only:

pod 'SwifterSwift/UIKit'

- Integrate AppKit extensions only:

pod 'SwifterSwift/AppKit'

- Integrate MapKit extensions only:

pod 'SwifterSwift/MapKit'

- Integrate CoreGraphics extensions only:

pod 'SwifterSwift/CoreGraphics'

- Integrate CoreLocation extensions only:

pod 'SwifterSwift/CoreLocation'

- Integrate SpriteKit extensions only:

pod 'SwifterSwift/SpriteKit'

- Integrate SceneKit extensions only:

pod 'SwifterSwift/SceneKit'

- Integrate StoreKit extensions only:

pod 'SwifterSwift/StoreKit'

- Integrate Dispatch extensions only:

pod 'SwifterSwift/Dispatch'

- Integrate WebKit extensions only:

pod 'SwifterSwift/WebKit'

- Integrate HealthKit extensions only:

pod 'SwifterSwift/HealthKit'
Carthage

To integrate SwifterSwift into your Xcode project using Carthage, specify it in your Cartfile:

github "SwifterSwift/SwifterSwift" ~> 5.3
Swift Package Manager

You can use The Swift Package Manager to install SwifterSwift by adding the proper description to your Package.swift file:

import PackageDescription

let package = Package(
    name: "YOUR_PROJECT_NAME",
    targets: [],
    dependencies: [
        .package(url: "https://github.com/SwifterSwift/SwifterSwift.git", from: "5.3.0")
    ]
)

Next, add SwifterSwift to your targets dependencies like so:

.target(
    name: "YOUR_TARGET_NAME",
    dependencies: [
        "SwifterSwift",
    ]
),

Then run swift package update.

Note that the Swift Package Manager doesn't support building for iOS/tvOS/macOS/watchOS apps – see Accio in the next section for that.

Accio

Accio is a dependency manager based on SwiftPM which can build frameworks for iOS/macOS/tvOS/watchOS. Therefore the integration steps are exactly the same as described above. Once your Package.swift file is configured, you need to run accio update instead of swift package update though.

Manually

Add the SwifterSwift folder to your Xcode project to use all extensions, or a specific extension.

For your test targets you can also add the XCTest folder.

List of All Extensions

SwiftStdlib Extensions
Foundation Extensions
UIKit Extensions
AppKit Extensions
CoreGraphics Extensions
CoreLocation Extensions
CoreAnimation Extensions
MapKit Extensions
SpriteKit Extensions
SceneKit Extensions
StoreKit Extensions
Dispatch Extensions
WebKit Extensions
HealthKit Extensions
XCTest Extensions

How cool is this?

SwifterSwift is a library of over 500 properties and methods, designed to extend Swift's functionality and productivity, staying faithful to the original Swift API design guidelines.

Check Examples.playground from the project for some cool examples!

Documentation

Documentation for all extensions, with examples, is available at swifterswift.com/docs

Get involved

We want your feedback. Please refer to contributing guidelines before participating.

Slack Channel: Slack

It is always nice to talk with other people using SwifterSwift and exchange experiences, so come join our Slack channel.

Thanks

Special thanks to:

License

SwifterSwift is released under the MIT license. See LICENSE for more information.

Comments
  • Added zoom extension to MapView

    Added zoom extension to MapView

    I wanted to contribute, but I'm very inexperienced in contributing to open source projects. I'd appreciate it if you could tell me what's missing :)

    Checklist

    • [x] I checked the Contributing Guidelines before creating this request.
    • [x] New extensions are written in Swift 5.0.
    • [x] New extensions support iOS 8.0+ / tvOS 9.0+ / macOS 10.10+ / watchOS 2.0+, or use @available if not.
    • [x] I have added tests for new extensions, and they passed.
    • [x] All extensions have a clear comments explaining their functionality, all parameters and return type in English.
    • [x] All extensions are declared as public.
    • [x] I have added a changelog entry describing my changes.
    opened by mustafagunes 39
  • shadowOffset for UILabel is conflict with UILabel's property.

    shadowOffset for UILabel is conflict with UILabel's property.

    [v] I've read, understood, and done my best to follow the Contributing guidelines before opening this issue.

    What did you do?

    Set shadowOffset, shadowColor, shadowRadius inspectable value on UILabel.

    What did you expect to happen?

    UILabel with proper shadow

    What happened instead?

    shadowOffset is not applied, because UILabel has shadowOffset property. So shadow is always above text, because layer.shadowOffset default value is (0, -3) (Also UILabel has shadowColor property.)

    SwifterSwift Environment

    • SwifterSwift version: 4.6.0
    • Xcode version: 10
    • macOS version running Xcode: 10.14.2
    • Swift version: 4.2
    • Platform(s) running SwifterSwift: iOS

    Demo Project

    Please link to or upload a project we can download that reproduces the issue.

    confirmed bug: source help wanted good first issue 
    opened by mlight3 23
  • Added new protocol for UIViewController to instantiate it from storyboard

    Added new protocol for UIViewController to instantiate it from storyboard

    Checklist

    • [x] I checked the Contributing Guidelines before creating this request.
    • [x] New extensions are written in Swift 5.0.
    • [x] New extensions support iOS 10.0+ / tvOS 9.0+ / macOS 10.10+ / watchOS 2.0+, or use @available if not.
    • [x] I have added tests for new extensions, and they passed.
    • [x] All extensions have a clear comments explaining their functionality, all parameters and return type in English.
    • [x] All extensions are declared as public.
    • [x] I have added a changelog entry describing my changes.
    opened by VatoKo 19
  • Add init(light:dark:) to NSColor and UIColor

    Add init(light:dark:) to NSColor and UIColor

    This extension allows to create an NSColor or UIColor with different colors for light mode and dark mode. I created separate NSColorExtensions.swift and UIColorExtensions.swift files, because NSColor and UIColor use different APIs for this problem and can't be unified.

    I couldn't figure out how to create a test for macOS, because it uses NSAppearance instead of UITraitCollection. Any suggestions?

    Checklist

    • [x] I checked the Contributing Guidelines before creating this request.
    • [x] New extensions are written in Swift 5.0.
    • [x] New extensions support iOS 8.0+ / tvOS 9.0+ / macOS 10.10+ / watchOS 2.0+, or use @available if not.
    • [x] I have added tests for new extensions, and they passed.
    • [x] All extensions have a clear comments explaining their functionality, all parameters and return type in English.
    • [x] All extensions are declared as public.
    • [x] I have added a changelog entry describing my changes.
    opened by MaxHaertwig 18
  • Array.withoutDuplicates(keyPath:)

    Array.withoutDuplicates(keyPath:)

    🚀 Fixed #653. Added withoutDuplicates(keyPath:) to Array.

    Checklist

    • [x] I checked the Contributing Guidelines before creating this request.
    • [x] New extensions are written in Swift 5.0.
    • [x] New extensions support iOS 8.0+ / tvOS 9.0+ / macOS 10.10+ / watchOS 2.0+, or use @available if not.
    • [x] I have added tests for new extensions, and they passed.
    • [x] All extensions have a clear comments explaining their functionality, all parameters and return type in English.
    • [x] All extensions are declared as public.
    • [x] I have added a changelog entry describing my changes.
    opened by RomanPodymov 18
  • Getting `ambiguous use of 'makeIterator()'` error when building package with Xcode 14

    Getting `ambiguous use of 'makeIterator()'` error when building package with Xcode 14

    Describe the bug The package will fail to build and install when used inside a project being compiled on Xcode 14 beta, with an ambiguous use of 'makeIterator()' error.

    To Reproduce

    1. Add SwifterSwift as a package inside an iOS project.
    2. Open project in Xcode 14 beta.
    3. Attempt to build app.

    Expected behavior The SwifterSwift package will not fail to build when using Xcode 14 beta.

    Additional context

    Here's a screenshot of the error: Screen Shot 2022-08-31 at 10 07 12 AM

    I'm about to open a PR which addresses this issue!

    possible bug 
    opened by ianclawson 17
  • Update UIButton extensions

    Update UIButton extensions

    Sometimes I need the image to be on the right or below the text. So add imageRightText on UIButton

    | type | imageAboveText: false | imageAboveText: true  | | --- | --- | --- | | imageRightText: false| Image/Text |

    Image
    ---- 
    Text
    | | imageRightText: true | Text/Image |
    Text
    ---- 
    Image
    |

    Checklist

    • [x] I checked the Contributing Guidelines before creating this request.
    • [x] New extensions are written in Swift 5.0.
    • [x] New extensions support iOS 10.0+ / tvOS 9.0+ / macOS 10.10+ / watchOS 2.0+, or use @available if not.
    • [x] I have added tests for new extensions, and they passed.
    • [x] All extensions have a clear comments explaining their functionality, all parameters and return type in English.
    • [x] All extensions are declared as public.
    • [x] I have added a changelog entry describing my changes.
    stale 
    opened by Jayxiang 17
  • Added 'applyGradient' method to UIViewExtensions

    Added 'applyGradient' method to UIViewExtensions

    🚀

    Checklist

    • [x] I checked the Contributing Guidelines before creating this request.
    • [x] New extensions are written in Swift 5.0.
    • [x] New extensions support iOS 8.0+ / tvOS 9.0+ / macOS 10.10+ / watchOS 2.0+, or use @available if not.
    • [x] I have added tests for new extensions, and they passed.
    • [x] All extensions have a clear comments explaining their functionality, all parameters and return type in English.
    • [x] All extensions are declared as public.
    • [x] I have added a changelog entry describing my changes.
    opened by JayMehta97 17
  • Use 'swift_version' instead of 'pod_target_xcconfig{SWIFT_VERSION}' t…

    Use 'swift_version' instead of 'pod_target_xcconfig{SWIFT_VERSION}' t…

    …o specify Swift version of pod target itself.

    Checklist

    • [x] I checked the Contributing Guidelines before creating this request.
    • [ ] New extensions are written in Swift 4.
    • [ ] New extensions support iOS 8.0+ / tvOS 9.0+ / macOS 10.10+ / watchOS 2.0+.
    • [ ] I have added tests for new extensions, and they passed.
    • [ ] All extensions have a clear comments explaining their functionality, all parameters and return type in English.
    • [ ] All extensions are declared as public.
    • [ ] I have added a changelog entry describing my changes.
    opened by dklinzh 17
  • Add stack function to array with element UIView

    Add stack function to array with element UIView

    Adding the function to create a UIStackView from an Array of UIViews. Taking the defaults and parameter docs from Apples Defaults.

    Solves #399

    Checklist

    • [x] I checked the Contributing Guidelines before creating this request.
    • [x] New extensions are written in Swift 4.
    • [x] New extensions support iOS 8.0+ / tvOS 9.0+ / macOS 10.10+ / watchOS 2.0+.
    • [x] I have added tests for new extensions, and they passed.
    • [x] All extensions have a clear comments explaining their functionality, all parameters and return type in English.
    • [x] All extensions are declared as public.
    • [x] I have added a changelog entry describing my changes.
    opened by be-meyer 16
  • Update LICENSE copyright date to 2018

    Update LICENSE copyright date to 2018

    https://github.com/SwifterSwift/SwifterSwift/blob/master/LICENSE

    MIT License
    -- Copyright (c) 2015-2017 SwifterSwift (https://github.com/swifterswift)
    ++ Copyright (c) 2015-2018 SwifterSwift (https://github.com/swifterswift)
    
    help wanted good first issue documentation 
    opened by SD10 16
  • String [safeFrom:] and [safeTo:]

    String [safeFrom:] and [safeTo:]

    🚀

    Hello. Thank you for SwifterSwift. Fix #1066.

    Checklist

    • [x] I checked the Contributing Guidelines before creating this request.
    • [x] New extensions are written in Swift 5.0.
    • [x] New extensions support iOS 10.0+ / tvOS 9.0+ / macOS 10.10+ / watchOS 2.0+, or use @available if not.
    • [x] I have added tests for new extensions, and they passed.
    • [x] All extensions have a clear comments explaining their functionality, all parameters and return type in English.
    • [x] All extensions are declared as public.
    • [x] I have added a changelog entry describing my changes.
    opened by RomanPodymov 2
  • String [safeFrom:] and [safeTo:]

    String [safeFrom:] and [safeTo:]

    🚀 Is your feature request related to a problem? Please describe. Hello. Thank you for SwifterSwift. Found out that you have s[safe: 10] and s[safe: 1..<10]. But what about s[safeFrom: 3] and s[safeTo: 10]?

    Describe the solution you'd like Add subscript(safeFrom lowerBound: Int) -> String? and subscript(safeTo upperBound: Int) -> String? to StringExtensions.swift.

    Describe alternatives you've considered Nothing.

    Additional context Nothing.

    opened by RomanPodymov 0
  • add a more simple conversion between string and double.

    add a more simple conversion between string and double.

    Checklist

    • [x] I checked the Contributing Guidelines before creating this request.
    • [x] New extensions are written in Swift 5.0.
    • [x] New extensions support iOS 10.0+ / tvOS 9.0+ / macOS 10.10+ / watchOS 2.0+, or use @available if not.
    • [x] I have added tests for new extensions, and they passed.
    • [x] All extensions have a clear comments explaining their functionality, all parameters and return type in English.
    • [x] All extensions are declared as public.
    • [x] I have added a changelog entry describing my changes.
    opened by westfort4July 0
  • Fixes building HKActivitySummary for macOS

    Fixes building HKActivitySummary for macOS

    🚀 fixes #1054

    Checklist

    • [x] I checked the Contributing Guidelines before creating this request.
    • [x] New extensions are written in Swift 5.0.
    • [x] New extensions support iOS 10.0+ / tvOS 9.0+ / macOS 10.10+ / watchOS 2.0+, or use @available if not.
    • [x] I have added tests for new extensions, and they passed.
    • [x] All extensions have a clear comments explaining their functionality, all parameters and return type in English.
    • [x] All extensions are declared as public.
    • [x] I have added a changelog entry describing my changes.
    opened by guykogus 2
  • SwifterSwift breaks compilation on macOS projects targeting BigSur and above and using the latest Xcode SDK

    SwifterSwift breaks compilation on macOS projects targeting BigSur and above and using the latest Xcode SDK

    Describe the bug SwifterSwift declares an extension to HealthKit that breaks compilation on macOS because Healthkit is only available on macOS from v13

    To Reproduce Steps to reproduce the behavior:

    1. Create a project on Xcode 14 on Ventura and try to include SwifterSwift with a target deployment < Ventura

    Expected behavior Code should compile

    Desktop (please complete the following information):

    • OS: macOS 13
    • Xcode Version : 14.1
    • Project: deployment = BigSur and uses macOS13 SDK to compile

    Additional context We created a fork and simply modified the @availability predicate in HKActivitySummaryExtensions

    @available(watchOS 2.2, macOS 13.0, *)

    confirmed bug: source help wanted good first issue 
    opened by spicymatt 0
  • Random String duplication

    Random String duplication

    We have 2 basically the same functions for generating a random string which only differ in their signatures.

    https://github.com/SwifterSwift/SwifterSwift/blob/04d474ade1aa7d8e6bde9a65d5f8d1a3595dc3a0/Sources/SwifterSwift/SwiftStdlib/StringExtensions.swift#L764-L778

    and

    https://github.com/SwifterSwift/SwifterSwift/blob/04d474ade1aa7d8e6bde9a65d5f8d1a3595dc3a0/Sources/SwifterSwift/SwiftStdlib/StringExtensions.swift#L1159-L1177

    I suggest we only leave the static one, so it will be the same as Int.random(in:) in Foundation

    opened by viktart 0
Releases(5.3.0)
Owner
SwifterSwift
We Make Swift, well, Swifter 😎
SwifterSwift
Collection of native Swift extensions to boost your development. Support tvOS and watchOS.

SparrowKit Collection of native Swift extensions to boost your development. Support iOS, tvOS and watchOS. If you like the project, don't forget to pu

Ivan Vorobei 119 Dec 20, 2022
Collection of Swift-extensions to boost development process.

SwiftBoost Collection of Swift-extensions to boost development process. Community Installation Ready to use on iOS 13+, tvOS 13+, watchOS 6.0+. Swift

Sparrow Code 119 Dec 20, 2022
SharkUtils is a collection of Swift extensions, handy methods and syntactical sugar that we use within our iOS projects at Gymshark.

SharkUtils is a collection of Swift extensions, handy methods and syntactical sugar that we use within our iOS projects at Gymshark.

Gymshark 1 Jul 6, 2021
A handy collection of Swift method and Tools to build project faster and more efficient.

SwifterKnife is a collection of Swift extension method and some tools that often use in develop project, with them you might build project faster and

李阳 4 Dec 29, 2022
PagingKit provides customizable menu UI. It has more flexible layout and design than the other libraries.

PagingKit provides customizable menu & content UI. It has more flexible layout and design than the other libraries. What's this? There are many librar

Kazuhiro Hayashi 1.3k Jan 9, 2023
Conv smart represent UICollectionView data structure more than UIKit.

Conv Conv smart represent UICollectionView data structure more than UIKit. Easy definition for UICollectionView DataSource and Delegate methods. And C

bannzai 157 Nov 25, 2022
Conv smart represent UICollectionView data structure more than UIKit.

Conv Conv smart represent UICollectionView data structure more than UIKit. Easy definition for UICollectionView DataSource and Delegate methods. And C

bannzai 155 May 12, 2022
Handy Combine extensions on NSObject, including Set.

Storable Description If you're using Combine, you've probably encountered the following code more than a few times. class Object: NSObject { var c

hcrane 23 Dec 13, 2022
Handy RxSwift extensions on NSObject, including rx.disposeBag.

NSObject+Rx If you're using RxSwift, you've probably encountered the following code more than a few times. class MyObject: Whatever { let disposeBag

RxSwift Community 625 Dec 12, 2022
A declarative UIKit for improve layout productivity when developing an iOS application

TifoKit A declarative UIKit for improve layout productivity when developing an iOS application Requirements Min. iOS 11 Swift 5+ Installation Currentl

Tifo Audi A.P 22 Aug 9, 2022
XCMetrics is the easiest way to collect Xcode build metrics and improve developer productivity.

XCMetrics is the easiest way to collect Xcode builds metrics and improve your developer productivity. Overview ?? Keep your build times under control

Spotify 989 Jan 2, 2023
Escuela - A student-productivity app. Everything in one place

escuela a student productivity app Features Tasks Notes Calendar (coming soon) A

Isaac Barsoum 1 Feb 8, 2022
TypeStyle is a handy app for iPhone and iPad that generates text using different styles and decorations. It is a native Swift iOS app.

TypeStyle TypeStyle is a handy app for iPhone and iPad that generates text using different styles and decorations. It is a native Swift iOS app. Featu

Eugene Belinski 31 Dec 14, 2022
A Swift package for rapid development using a collection of micro utility extensions for Standard Library, Foundation, and other native frameworks.

ZamzamKit ZamzamKit is a Swift package for rapid development using a collection of micro utility extensions for Standard Library, Foundation, and othe

Zamzam Inc. 261 Dec 15, 2022
Rock - Paper - Scissors game. CPU gives you a sign and asks to win or lose your move. Than you have to decide witch sign do you choose to score a point

RockPaperScissors 2nd challange from HackingWithSwift.com. The CPU gives you a sign (rock, paper or scissors) and asks you either to win or to lose th

Pavel Surový 0 Nov 27, 2021
Learn about how SoulverCore can give Swift "better than regex" data parsing features (for many common tasks)

String Parsing with Soulver Core A declarative & type-safe approach to parsing data from strings SoulverCore gives you human-friendly, type-safe & per

Soulver 140 Nov 23, 2022
Snitch - A handy library to access useful information about your application from the Home Screen

Snitch Access your app's useful information from Home Screen Table of Contents I

Tamerlan Satualdypov 12 Jan 2, 2023
URLScheme router than supports auto creation of UIViewControllers for associated url parameters to allow creation of navigation stacks

IKRouter What does it do? Once you have made your UIViewControllers conform to Routable you can register them with the parameters that they represent

Ian Keen 94 Feb 28, 2022
RxAlamoRecord combines the power of the AlamoRecord and RxSwift libraries to create a networking layer that makes interacting with API's easier than ever reactively.

Written in Swift 5 RxAlamoRecord combines the power of the AlamoRecord and RxSwift libraries to create a networking layer that makes interacting with

Dalton Hinterscher 9 Aug 7, 2020
Create fully customizable popups easier than ever before ⚜️

FlexFlex Create fully customizable popups easier than ever before. ?? Installation FlexFlex requires iOS 13 and Xcode 12. 1️⃣ In Xcode go to File ➤ Ad

adri567 2 Aug 15, 2022