Skip to content
Andrew Kitchen edited this page Apr 12, 2014 · 27 revisions

You can install Cedar via Cocoapods, from source or by using a pre-built distribution.

Installation via Cocoapods

  • Install Cocoapods on your system with gem install cocoapods
  • Assuming you are working with a newly-created Xcode project named 'MyApp', add the following to your Podfile:
target :MyAppTests do
  pod 'Cedar'
end

If your test suite has a different name, enter it in place of MyAppTests in the example above. You may also want to use the podspec from Cedar's git repo, as the CocoaPods/Specs repo may not be up to date.

target :MyAppTests do
  pod 'Cedar', :git => 'https://github.com/pivotal/cedar.git'
end

Now run pod install in a terminal in the root of your project.

Installation of file and target templates is recommended, as it will simplify creation of Cedar spec files (see below). After creating a Cedar spec from the file templates, add the following import at the top (or add it to the pre-compiled headers for your test target):

#import <Cedar-iOS/SpecHelper.h>

If creating files by hand, they should be Objective-C++ (with a .mm extension). The file should resemble the following:

#import <Cedar-iOS/SpecHelper.h>

using namespace Cedar::Matchers;
using namespace Cedar::Doubles;

SPEC_BEGIN(MudSpec)

describe(@"My name", ^{
    __block NSString *string;

    beforeEach(^{
        string = @"My name";
    });

    it(@"should be Mud", ^{
        string should contain(@"Mud");
    });
});

SPEC_END

Quick installation of file and target templates from source

  • Install the Xcode command line tools package (Under the Preferences tab 'Downloads') if you haven't already done so.

  • Run the following in a terminal:

      $ curl -L https://raw.github.com/pivotal/cedar/master/install.sh | bash
    

Installing development version

  • If you'd rather install the latest master revision of Cedar, you can instead pass the head option like so:

      $ curl -L https://raw.github.com/pivotal/cedar/master/install.sh | bash -s head
    

Manual install from source

This works the same as the Quick install method, but if you're paranoid about running arbitrary scripts you can follow this procedure instead:

  • Install the Xcode command line tools package (Under the Preferences tab 'Downloads') if you haven't already done so.

  • Clone the Cedar repository from github:

      $ git clone https://github.com/pivotal/cedar.git && cd cedar
    
  • Build and install templates:

    $ ./installCodeSnippetsAndTemplates # or rake install

  • Restart Xcode

Installing a pre-built distribution

  • Download the most recent build from the Releases page

  • Expand the tarball into your home directory:

      $ cd ~
      $ tar -zxvf ~/Downloads/Cedar-v0.9.6.tar.gz
    
  • Restart Xcode

Installing as a submodule

Installing cedar as a submodule is useful if you want to stay up to date with development on master or experiment with development branches.

  1. Clone cedar using the link at Github

     $ git submodule add git://github.com/pivotal/cedar.git Externals/cedar
    
  2. Drag the cedar project into your Xcode project

  3. Add a Cedar Bundle or Test Suite as described in Getting Started.

  4. Edit the settings of the Bundle/Suite target by selecting it in Xcode.

  5. Under 'Build Phases', add Cedar-StaticLib in the 'Target Dependencies' section.

    This tells Xcode that building this library is necessary to build the target.

  6. Under 'Build Phases', add libCedar-StaticLib.a in the 'Link Binary With Libraries' section.

    This tells Xcode to link against the library and make its object code available.

  7. Under 'Build Settings', find 'Header Search Paths' and add '$SRCROOT/Externals/cedar', marking it recursive.

    This allows Xcode to find your header files.

  8. Under 'Build Settings', find 'Framework Search Paths' and add '$SRCROOT/Externals', marking it recursive.

    This allows Xcode to find additional frameworks.

  9. Edit your precompiled header file (-Prefix.pch), removing the Cedar-iOS framework import and replacing it with an import of SpecHelper.h

     #ifdef  __OBJC__
         #import <UIKit/UIKit.h>
         #import <Foundation/Foundation.h>
         //#import <Cedar-iOS/SpecHelper.h>
         #import "SpecHelper.h"
     #endif
    

You can now select different branches or selectively upgrade your Cedar submodule.

Verifying your installation

  • Open an existing project and add a target to it
  • You should see a category for Cedar under each of the iOS and OS X sections.
  • Check out Getting Started to start using Cedar right now.

Clone this wiki locally