Swiftpack.co - Package - draveness/RbSwift


RbSwift provides a series of Swift struct/class extension including lots of handy functions with elaborate API Reference.

Most of the APIs and test cases are from Ruby Core Libraries and ActiveSupport example.


  • [x] Transform functions support for Sequence, Array, and Dictionary

    [1, 2, 3, nil, nil, 4, 5, 6, 7]
        .flatten()              //=> [1, 2, 3, 4, 5, 6, 7]
        .select { $0 > 2 }      //=> [3, 4, 5, 6, 7]      
        .reject { $0.isEven }   //=> [3, 5, 7]
        .count                  //=> 3
  • [x] Built-in Regex support for String

    "hello".gsub("l", "abc")    //=> "heabcabco"
    "hello".gsub("l", "lll")    //=> "lllllllllllllll"
    if "hello world" =~ "hello" {
        print("this will match")
  • [x] Convenient methods build Date instance

    Date.now + 1.day            //=> 2017-01-01 12:00:00 +0000
    2.years + 1.day > 1.year    //=> true
  • [x] File and IO supports which build on top of low-level C API

    File.basename("/home/work/file.swift") //=> file.swift
    File.open("empty.txt", "w") { file in
    Dir.isEmpty("a/empty/folder")   //=> true
    Dir.entries(entriesDir)         //=> [".", "..", "file.swift"]
    FileUtils.mkdir_p("draveness/spool/mail") // create folder recursively
  • [x] Bridge between NS to swift type

    let str: NSString = "string"
    "string".bridge         //=> String
    "string".bridge.bridge  //=> NSString


Full documentation for RbSwift can be found here.



CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

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

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'

target '<Your Target Name>' do
    pod 'RbSwift', '~> 0.5.0'

Then, run the following command:

$ pod install


Carthage is a decentralised dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

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

github "Draveness/RbSwift" ~> 0.5.0

Run carthage update to build the framework and drag the built RbSwift.framework into your Xcode project.

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. It is in early development, but RbSwift does support its use on supported platforms.

Once you have your Swift package set up, adding RbSwift as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .Package(url: "https://github.com/Draveness/RbSwift.git", majorVersion: 0)


If you prefer not to use either of the aforementioned dependency managers, you can integrate RbSwift into your project manually.


Follow and contact me with email. If you find an issue, open a ticket. Pull requests are warmly welcome as well.


RbSwift is released under the MIT license. See LICENSE for details.


Stars: 312
Help us keep the lights on


Used By

Total: 1


0.5.0 - May 15, 2017

0.4.1 - May 14, 2017

0.4.0 - Apr 22, 2017

0.3.3 - Apr 17, 2017

0.3.2 - Apr 15, 2017