Skip to content

Tutorial: Creating a cal Target

Joshua Moody edited this page Oct 24, 2015 · 7 revisions

This tutorial describes how to create a -cal target. We will create a new Xcode application target by duplicating an existing production target. The -cal target is exactly like the original production application except that it will link to the calabash.framework. Linking the calabash.framework will start the Calabash iOS server when the -cal target application is launched.

Why a separate target?

The Calabash server contains symbols and methods that will cause any application that links to it to be rejected from the AppStore. A separate target with a different bundle identifier will ensure that you never accidently submit an application that has the Calabash server linked.

Some users like to have a physical and mental separation between their production and test applications.

Starting Point Completed Video
master demo/cal-target screencast.com ~7 minutes

Step 1. Create the -cal Target

Right-click on the Production target and duplicate.

00-duplicate-target

If you have an iPhone or iPad only app, you might see an alert like this one:

01-duplicate-alert

If so, be sure to select "Duplicate Only".

1.2 Rename with -cal

02-rename-duplicate-target

1.3 Change the bundle identifier

03-change-bundle-identifier

1.4 Change the Info.plist

04-change-info-plist

1.5 Delete duplicate Info.plist

05-delete-duplicate-info-plist

Step 2: Create the -cal Scheme

06-scheme-manage

2.2 Set the Scheme name

Be sure to check both the "Show" and "Share" options.

07-scheme-rename-and-share

2.3 Set Scheme Executable

This step may not be necessary. You should confirm that the Executable for the -cal scheme is the -cal target.

08-scheme-set-executable

3. Link CFNetwork.framework

If your production app does not already link the CFNetwork.framework, you must add it to the -cal target.

09-link-cfnetwork-0

10-link-cfnetwork-1

4. Link calabash.framework

Create a Gemfile in the same directory as your .xcodeproj:

source "https://rubygems.org"

gem "calabash-cucumber", ">= 0.16", "< 2.0"

Then execute the following commands in that directory:

$ bundle
$ bundle exec calabash-ios download

----------Info----------
caution: excluded filename not matched:  __MACOSX/*
caution: excluded filename not matched:  calabash.framework/.DS_Store
---------------------------

4.2 Add the calabash.framework

Be sure to add the calabash.framework to no targets.

11-add-calabash-framework-0

12-add-calabash framework-1

4.3 Link the calabash.framework

13-add-calabash framework-linker-flags

The linker flags are:

-ObjC -force_load "$(SOURCE_ROOT)/calabash.framework/calabash"

5. Build and Run

Be sure to select the -cal target scheme. You can target a simulator or physical device.

In your Xcode console you should see the following output - the exact content will differ by Calabash version:

DEBUG CalabashServer:222 | Creating the server: <LPHTTPServer: 0x7f80b3d066e0>
DEBUG CalabashServer:223 | Calabash iOS server version: CALABASH VERSION: 0.16.4
Clone this wiki locally