Xcode Plugin

Skip to end of metadata
Go to start of metadata

Plugin Information

Plugin ID xcode-plugin Changes In Latest Release
Since Latest Release
Latest Release
Latest Release Date
Required Core
Dependencies
1.4.8 (archives)
Feb 28, 2015
1.509
credentials (version:1.4)
token-macro (version:1.5.1)
Source Code
Issue Tracking
Pull Requests
Maintainer(s)
GitHub
Open Issues
Pull Requests
Ray Yamamoto Hilton (id: rayhilton)
Arnaud Heritier (id: aheritier)
Jerome Lacoste (id: lacostej)
Usage Installations 2014-Jul 4119
2014-Aug 4200
2014-Sep 4366
2014-Oct 4459
2014-Nov 4513
2014-Dec 4481
2015-Jan 4677
2015-Feb 4725
2015-Mar 5025
2015-Apr 5022
2015-May 5119
2015-Jun 5420
I need your help!!
To help us maintain the plugin, you can take contact to jerome.lacoste at gmail.com in particular if you are able to test upcoming releases

Thank you!

A problem, An idea ?
Please use our tasks and issues tracker to report bugs, improvements or new feature.

Also if you want to propose some code change using a Github pull request, please open also a Jira issue. It is easier for developers to track them.

This plugin adds the ability to call Xcode command line tools to automate build and packaging iOS applications (iPhone, iPad, ...).

Features

Versioning

This builder can invoke agvtool to dynamically update the CFBundleVersion (a.k.a. Technical Version) or CFBundleShortVersionString (a.k.a. Marketing Version). It supports all macros from the Token Macro Plugin. For example the value ${BUILD_NUMBER} will be replaced with the current build number. We advice you to generate a unique value for each build for the CFBundleVersion if you want for example deploy it into a private store. In that case you can use for example : ${JOB_NAME}-${BUILD_NUMBER}

Building

The target (optional), configuration (e.g. Debug, Release) and SDK (optional) can be specified in the per-project config along with whether to perform a clean before the build phase.

Packaging

The builder can be used to package the .app into a .ipa. Since a .app is actually a directory, it can be awkward to work with and, especially, distribute. We can simplify this by packaging the .app into a single .ipa file, which is just a
zip file with a well-known internal structure

Signing

This plugin has two features that help you simplify the code signing process.

Allowing Jenkins to stage developer profile

This plugin builds on top of Credentials Plugin to allow you to store your Apple Developer Profile (*.developerprofile) file. This file contains a code signing private key, corresponding developer/distribution certificates, and mobile provisioning profiles. You can create this file from your XCode.

To upload the developer profile into Jenkins, go to "Manage Credentials" in the system configuration page, and select "Apple Developer Profile" from the "Add" button. See Credentials Plugin for further details.

To use this profile for signing, add "Import developer profile" as a build step before you run xcode, and select the developer profile to import into the build machine. This build step will install the developer profile into the slave's keychain.

Work with existing populated keychains

If you create a dedicated keychain that stores the code signing private key and certificate on every build slave, you can configure the plugin to just unlock this keychain (so that xcode can use it for signing)

Unlocking
If you store your keys in the user keychain (most probably) and if you run jenkins as daemon, make sure you installed a recent version of jenkins for Mac, or configured the daemon to create a session (through the CreationSession=true parameter in your org.jenkins-ci.plist daemon config file). See also
Timeouts
The keychain has a default timeout of 300 seconds. One can override it using the security set-keychain-settings command, which isn't supported in the plugin today. Support in the plugin could be improved by adding options to modify the timeout as part of the build process. See JENKINS-17184.
Unit Testing

This plugin will listen to the xcodebuild output when running OCUnit or XC tests and write out JUnit-format test reports that Jenkins can understand. Jenkins will then use these to publish test failure reports and graphs.

Sample of the configuration panel

Documentation

Installation guide

Obviously, the build machine has to be an OSX machine with XCode developer tools installed.
Certificates, Identities and Provisions must be installed on the build machine separately.
Just install the latest version of the plugin from the update center and configure a freestyle job (see Usage Guide) that will use your OSX node (If your central instance isn't running under OSX).
If xcode related binaries aren't stored in the default location, update the global configuration of the plugin (Manage Jenkins -> Configure System)

Usage guide
Setting up a build step

Add the XCode build step to a free-style project and set the target (e.g. MyApp), configuration (e.g. Release) and check the build IPA and update version number options. This will give you a single, versioned .ipa file. You can also select to clean the project before a build; while this will make sure that the project is starting from a clean state, it will make large projects take a lot longer.

Setting up a unit test step

Add the XCode build step and this time specify your unit test target (e.g. MyAppTests), configuration (e.g. Debug) and the SDK (e.g. Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.1.sdk/).
Leave all the checkboxes unselected. The SDK needs to be supplied here as the unit tests will only be run when building under the simulator's SDK.
Check the "Publish JUnit test result report" option in the project config and set the value "*/test-reports/*.xml" under "Test report XMLs". This will tell Jenkins to pick up the JUnit-format test reports.

XCode Builder configuration parameters
Parameter Since version Description
Clean before build? 1.0 This will delete the build directories before invoking the build. This will force the rebuilding of ALL dependencies and can make large projects take a lot longer.
Target 1.0 The target to build. If left empty, this will build all targets in the project. If you wish to build your binary and the unit test module, it is best to do this as two separate steps each with their own target. This was, the iPhone Simulator SDK can be specified for the unit tests.
Xcode Schema File 1.2 Only needed if you want to compile for a specific schema instead of a target. It takes precedence over 'Xcode Configuration' setting and this job 'target' parameter.
SDK 1.0 You only need to supply this value if you want to specify the SDK to build against. If empty, the SDK will be determined by XCode. If you wish to run OCUnit tests, you will need to use the iPhone Simulator's SDK, for example: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.1.sdk/
SYMROOT 1.1 You only need to supply this value if you want to specify the SYMROOT path to use. If empty, the default SYMROOT path will be used (it could be different depending of your Xcode version). Supports all macros and also environment and build variables from the Token Macro Plugin. For example you can use the value : ${WORKSPACE}/build
Configuration 1.0 This is the name of the configuration as defined in the XCode project. By default there are Debug and Release configurations.
Custom xcodebuild arguments 1.3 Passing custom arguments is convenient when you need to change some project options for Jenkins build, but don't want them to persist in project file. For example when running application tests, following settings often are nice fit: GCC_SYMBOLS_PRIVATE_EXTERN=NO COPY_PHASE_STRIP=NO. Otherwise Release build will usually fail because it won't be able to find application symbols to link with test bundle. Arguments are currently separated by space, enclosing them in quotes won't help.
Xcode Workspace File 1.2 Only needed if you want to compile a workspace instead of a project. It takes precedence over 'Xcode Project File' setting and this job 'configuration' parameter."
Xcode Project Directory 1.0 This is the relative path from the workspace to the directory that contains the XCode project file. You only need to supply this value if the XCode project you wish to build is not in the root of the workspace.
Xcode Project File 1.0 If there is more than one XCode project file in the project path, you will need to specify the file name of the project you wish to build. If you need to build all project, you will need to create an XCode build step for each one manually.
Build output directory 1.2 The value to use for CONFIGURATION_BUILD_DIR setting. You only need to supply this value if you want the product of the XCode build to be in a location other than the one specified in project settings and this job 'SYMROOT' parameter. Supports all macros and also environment and build variables from the Token Macro Plugin. For example you can use the value : ${WORKSPACE}/build
Marketing version 1.0 This will set the CFBundleShortVersionString to the specified string. Supports all macros and also environment and build variables from the Token Macro Plugin.
Technical version 1.0 This will set the CFBundleVersion to the specified string. Supports all macros and also environment and build variables from the Token Macro Plugin. For example the value ${BUILD_NUMBER} will be replaced with the current build number. We advice you to generate a unique value for each build if you want for example deploy it into a private store. In that case you can use for example : ${JOB_NAME}-${BUILD_NUMBER}
Clean test reports? 1.3 This will delete the processed test reports before invoking the build. Usually it is a good idea only to do it in test targets, otherwise if other Xcode target is built before tests – the build will fail to collect test reports.
Build IPA? 1.0 Checking this option will create a .ipa for each .app found in the build directory. An .ipa is basically a zipped up .app. This is quite handy for distributing ad-hoc builds to testers as they can just double-click the .ipa and it will import into iTunes.
Embedded Profile 1.0 The relative path to the mobileprovision to embed, leave blank for no embedded profile.
Unlock Keychain? 1.0 Automatically unlock the keychain before signing the archive?
Keychain path 1.0 The path of the keychain to use to retrieve certificates to sign the package (default : ${HOME}/Library/Keychains/login.keychain).
Keychain password 1.0 The password of the keychain to use to retrieve certificates to sign the package.
Using multiple versions of xcode.

One can easily support multiple versions by using environment variables. But first one need to install multiple versions on the build server. Here's one strategy:

install multiple versions of xcode

0. Note current config.

xcode-select -p

1. download xcode DMGs from http://developer.apple.com/downloads/

2. enable install from everywhere (under System preferences / Security)

Without that I had problems installing xcode, without graphical feedback, tested on 10.9.5, freshly booted.

Symptoms were:

  • app not responsive
  • Getting errors like in /var/log/system.log

Someone attempted to start application App:"Xcode" asn:0x0-1b62b61 pid:57656 refs=6 @ 0x7fa5d9f6df40 but it still has _kLSApplicationLockedInStoppedStateKey=true, so it is is staying stopped. : LASApplication.cp #2468 SetApplicationInStoppedState() q=LSSession 100027/0x186bb queue

3. open DMG file, copy app to /Applications. This might take a while.

4. close /Volumes/Xcode (otherwise installation won't start)

5. start Xcode, accept agreement, install missing packages if necessary. This might take a while. Close xcode after GUI opens.

6. move freshly installed Xcode to new path, e.g.

sudo mv /Applications/Xcode.app /Applications/Xcode6.1.app

(I use this so that the xcode app appears with version number under spotlight)

7. reset default xcode-select if necessary (installation might have changed it / reset to /Applications/Xcode.app)

sudo xcode-select -s /Applications/Xcode6.1.app

(Note the part above could be fully automated....)

Select the xcode version at runtime

1. Use EnvInject plugin
2. for jobs that require the non default do something like

DEVELOPER_DIR=/Applications/Xcode6.0.1.app/Contents/Developer

under Inject environment variables to the build process

FAQ

User interaction is not allowed

When code-signing, a prompt may appear on the build machine asking whether to allow keychain access.
This will block the build with a message like "User interaction is not allowed" until it is dismissed.
Just select 'Always Allow' the first time and it shouldn't need to ask again.

If this prompt is not showing on the build machine, you can force it to appear by running the codesign command that failed from a terminal on the build machine:   /usr/bin/codesign --force --sign "iPhone Distribution: .....

No Xcode folder is set
[sources] $ /usr/bin/xcodebuild -version
xcode-select: Error: No Xcode folder is set. Run xcode-select -switch <xcode_folder_path> to set the path to the Xcode folder.
Error: /usr/bin/xcode-select returned unexpected error.
FATAL: Check your XCode installation. Jenkins cannot retrieve its version.

You probably just installed XCode (by default it is in /Developer) but its path isn't configured. You can fix it with

xcode-select -switch /Developer/

You should now be able to execute xcodebuild. Ex :

host:~ user$ /usr/bin/xcodebuild -version
Xcode 4.2
Build version 4C199
Xcode 4.3

XCode 4.3 changes 2 things that are important for our usage on a slave or a master :

  • Command-Line Tools Are Optional : The command-line tools are not bundled with Xcode 4.3 by default. Instead, they have to be installed using the Components tab of the Downloads preferences panel
  • /Developer No Longer Exists : You may have to reconfigure its path like this:
    sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer/
    

Known issues2

Changelog

Version 1.4.9 (under development)
Version 1.4.8 (28th February, 2015)
Version 1.4.7 (5th January, 2015)
Version 1.4.6 (16th December, 2014)
  • Fix: broken dSYM packaging (since 1.4.5)
  • Fix: BUILD_DATE does not produce the correct last modified date if built on a slave machine (pull request xcode-plugin/50)
  • Fix: make sure to set provideApplicationVersion properly upon upgrade from per-1.4.1 (issue #JENKINS-26027)
  • New: developerProfileLoader: use show-keychain-info to display job specific keychain information
  • New: support XC test output (issue #JENKINS-19955)
  • New: display warning when simulator SDK selected and IPA about to be packaged (issue #JENKINS-21293)
  • New: document xcodebuildArguments (issue #JENKINS-13930)
Version 1.4.5 (10th December, 2014)
Version 1.4.2 (31st December, 2013)
Version 1.4.1 (30th October, 2013)
Version 1.4 (2nd Oct, 2013)
Version 1.3.1 (27th March 2012)
  • Fix: Custom xcodebuild arguments values are not persisted (issue #12510).
Version 1.3 (20th January 2012)
  • New : Ability to specify custom arguments to xcodebuild (so that values in project file can be overridden). It is needed to specify custom build options to make in-app unit tests work.
  • New : Ability to disable clean up of test reports on per-target level, so that it is possible to run several targets in single job and not mess-up test reports.
  • Fix : The plugin fails by searching for a double .app extension while compressing .dsym (issue #12273)
  • Fix : The plugin fails to delete previous generated IPA results in a failed build (issue #12237).
  • Fix : The plugin fails to set default keychain when using an alternate (non login) keychain (By default the login keychain is the default keychain) (issue #12217).
  • Fix : Restore Java 1.5 runtime compatibility. (issue #12378)
Version 1.2.2 (19th December 2011)
  • Fix : Build IPA fails if the plugin is launched on a remote agent using a relative path for its FS Root directory (issue #12144)
Version 1.2.1 (18th December 2011)
  • Fix : Build IPA switch doesn't work properly for a default Xcode project always results in FATAL error (issue #12089)
Version 1.2 (8th December 2011)
  • New build parameter to specify the build output directory. This overrides the setting in the user's project file, so it will be put into a known directory rather than XcodeDerivedData, etc. This makes it much easier to set up subsequent build steps in Jenkins that do something with the output of the build. It does this by passing the setting CONFIGURATION_BUILD_DIR to xcodebuild if a path is set for this new job config value.
  • Add support for building schemes and workspaces : The plugin now supports two extra configuration parameters xcodeScheme and xcodeWorkspaceFile. The scheme maps to xcodebuild's parameter "-scheme" and the workspace to "-workspace". The scheme takes precedence over the target setting and the workspace takes precedence over the project setting.
Version 1.1 (29th November 2011)
  • Upgrade the token macro plugin to version 1.5.1 to support environment and build variables (issue #11892)
  • New configuration parameter to set the SYMROOT value passed to the build. This parameter accepts environment and build variables and Macros (issue #11813)
  • Various code cleanup and improvements.
Version 1.0.1 (14th November 2011)
  • Minor fix about the default value and the documentation of the keystore path parameter.
Version 1.0 (14th November 2011)
  • Initiated from Ray Yamamoto Hilton's Xcode plugin for Hudson with few changes :
    • It improves jenkins compatibility, and is available in its update center.
    • It uses the Token Macro Plugin to configure values of CFBundleVersion and CFBundleShortVersionString
    • It allows to configure the keychain to use and to unlock it
    • It is ready for internationalization
If you previously used the version provided by Ray you should be able to test this one in parallel as it has a new identity. Also you'll have to reconfigure a large part of it if you want to upgrade thus don't forget to save your settings.

Labels

Edit
plugin-builder plugin-builder Delete
token-consumer token-consumer Delete
plugin-ios plugin-ios Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Add Comment