Search code examples
swiftxcodesnapkit

Adding Snapkit to xcode manually


How to add Snapkit in xcode manually without using cocoapods or carthage ?


Solution

  • Download project from repo or you can download only source file.

    Then drag and drop that source file into your project.

    And you are good to go.

    Check example code which is given into their repo.

    import UIKit
    
    class ViewController: UIViewController {
    
        lazy var box = UIView()
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            self.view.addSubview(box)
            box.snp.makeConstraints { (make) -> Void in
                make.width.height.equalTo(50)
                make.center.equalTo(self.view)
            }
        }
    }
    

    And its running without and errors:

    enter image description here

    Note: You don't need to import SnapKit if you are adding it manually.

    Check complete project HERE.