Note: This documentation is still a work in progress. If you have any questions, feel free to get in contact with me.

Vendor makes the process of using and managing libraries in iOS easy. Vendor is modeled after Bundler. Vendor streamlines the installation and update process for dependent libraries. It also tracks versions and manages dependencies between libraries.

Installation

If you have RVM installed, simply run:

$ gem install vendor

Otherwise, you'll need to:

$ sudo gem install vendor

Installing Libraries

Step 1: Specify dependencies

Specify your dependencies in a Vendors file in your project's root.

# Downloads the latest version of DKBenchmark from
# http://vendorkit.com
lib "DKBenchmark"

# Downloads version 0.5 of DKPredicateBuilder from
# http://vendorkit.com
lib "DKPredicateBuilder", '0.5'

# Include all the source files found in ~/Development/DKRest/Classes
# This is usefull when developing your own libraries
lib "DKRest", :path => "~/Development/DKRest", :require => "Classes"

# Checks out the git repo and includes all the files found in the
# AFNetworking folder in the repo. The require option is handy for
# repo's that haven't created vendor libraries and pushed them to
# VendorKit
lib "DKRest", :git => "git://github.com/gowalla/AFNetworking.git", :require => "AFNetworking"

# The Vendorfile allows you to specify targets to add your libraries to.
# By default, each library will be added to all targets, but if you have
# library that you only wanted to use in the "Integration Tests" target,
# you could do the following
target "Integration Tests" do
  lib "cedar", '0.2'
end

# These lines are an alternative syntax to the target specification above
lib "OCMock", :targets => [ "Integration Tests", "Specs" ]
lib "Kiwi", :target => "Specs"

You can do this by either creating a Vendorfile manually, or by running:

$ vendor init

Step 2: Install dependencies

$ vendor install
$ git add Vendors.lock

Installing a vendor library gets the latest version of the code, and adds them directly to your project in a Vendor group.

As part of the installation process the required frameworks are added aswell as any compiler/linker flags. The installed version of the library is captured in the Vendors.lock file.

Step 3: There is no spoon

Or step 3 for that matter!

Creating Libraries

If a vendor library has no framework dependencies, has no required additional compiler/linker flags, and has an XCode project, it doesn’t require a "vendorspec". An example is JSONKit, which may be specified as below. However, if another Vendor library requires JSONKit, JSONKit must have a vendorspec.

lib "JSONKit", :git => "https://github.com/johnezang/JSONKit.git"

However, if the vendor library requires frameworks or has dependencies on other Vendor libraries, it must have a vendorspec. As with Rubygems, a vendorspec is some declarative Ruby code that is open source and centrally managed.

To create a vendorspec, simply run:

$ vendor library init

This command will create a blank .vendorspec file that looks something like this:

Vendor::Spec.new do |s|

    s.name           "DKBenchmark"
    s.version        "0.1"

    s.authors        "keithpitt"
    s.email          "me@keithpitt.com"
    s.description    "Easy benchmarking in Objective-C using blocks"

    s.homepage       "http://www.keithpitt.com"
    s.source         "https://github.com/keithpitt/DKBenchmark"
    s.docs           "https://github.com/keithpitt/DKBenchmark/wiki"

    s.files          [ "DKBenchmark.h", "DKBenchmark.m" ]

    s.build_setting  :other_linker_flags, [ "-ObjC", "+lsdd" ]
    s.build_setting  "CLANG_WARN_OBJCPP_ARC_ABI", false
    s.build_setting  "GCC_PRECOMPILE_PREFIX_HEADER", "YES"

    s.framework      "CoreGraphics.framework"
    s.framework      "UIKit.framework"

    s.dependency     "JSONKit", "0.5"
    s.dependency     "ASIHTTPRequest", "~> 4.2"
    s.dependency     "AFINetworking", "<= 2.5.a"

end

Change what you need to match your project, then build a packaged vendor library by running:

$ vendor library build my_library.vendorspec

Now that you have a packaged library, you can push it to http://vendorkit.com by running:

$ vendor library push my_library.vendor