Latest 1.1.1
License Apache License, Version 2.0
Platforms ios 8.0, osx 10.9, watchos 2.0, tvos 9.0
Cook classes/structs with the taste you love.
Naming your extensions in the Swifty way people love.

extension of Swift is powerful. We can extend not only our own class/struct, but also any frameworks’ class/struct.

Well, function naming conflict is a common issue in extension. People were using xxx_ prefix to deal with that. Now people are using a smarter, cleaner and finally Swifter approach.

Framework Was Now
RxSwift label.rx_text label.rx.text
SnapKit view.snp_makeConstraints view.snp.makeConstraints

Cooking is the library help you adopt this Swifty way to name extension.


Either class or struct has to conform to Edible protocol to have the wrapper with .cook.

Then extend Cooking with where constraint to extend your class or struct. You will have to use ingredient to refer the instance instead of using self.

For class, the constraint can use either == or :.
For struct, the constraint has to use ==.

import Cooking

extension String: Edible {}
//  Use `==` for structs.
extension Cooking where Ingredient == String {

    static func bitterOne() -> String {
        return "😭😭😭"

    func sweeten() -> String {
        return ingredient.replacingOccurrences(of: "😭", with: "😋")

let bitterString = String.cook.bitterOne()
//  bitterString = "😭😭😭"
let sweetString  = bitterString.cook.sweeten()
//  sweetString  = "😋😋😋"

extension UIView: Edible {}
extension Cooking where Ingredient: UIView {
    func area() -> CGFloat {
        return ingredient.frame.width * ingredient.frame.height

let view = UIView(frame: .init(origin: .zero, size: .init(width: 50, height: 20)))
let area = view.cook.area()
//  area = 1000



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

$ gem install cocoapods

To use Cooking in your Xcode project using CocoaPods, specify it in your Podfile:

pod 'Cooking'

Then, run the following command:

$ pod install

Swift Package Manager

Add this project as a dependency in your Package.swift file.

.Package(url: "", majorVersion: 1, minor: 0)


Include file Sources/Cooking.swift in your project.



Latest podspec

    "name": "Cooking",
    "version": "1.1.1",
    "summary": "Cook Classes/Structs with the taste you love.",
    "description": "Cook classes/structs with the taste you love. Naming your extensions in the Swifty way people love.nThe library helps you name your extension in the way as `label.rx.text` other than 'label.rx_text'.",
    "homepage": "",
    "license": {
        "type": "Apache License, Version 2.0",
        "file": "LICENSE"
    "authors": {
        "Shane Qi": "[email protected]"
    "social_media_url": "",
    "platforms": {
        "ios": "8.0",
        "osx": "10.9",
        "watchos": "2.0",
        "tvos": "9.0"
    "source": {
        "git": "",
        "tag": "1.1.1"
    "source_files": "Sources",
    "pushed_with_swift_version": "3.1"

Pin It on Pinterest

Share This