xcode 插件

https://wiki.jenkins-ci.org/display/JENKINS/Xcode+Plugin


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) orCFBundleShortVersionString (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 theCFBundleVersion 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. DebugRelease) 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

To sign your binary you can configure the plugin to use a dedicated keychain and you can ask it to unlock it before the build with a password, if necessary.

Unit Testing

This plugin will listen to the xcodebuild output when running OCUnit 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.
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/
    


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值