码迷,mamicode.com
首页 > 其他好文 > 详细

mac xcworkspace xcodebuild

时间:2014-08-21 19:09:34      阅读:537      评论:0      收藏:0      [点我收藏+]

标签:des   http   使用   os   io   strong   文件   for   

xcodebuild

  在介绍xcodebuild之前,需要先弄清楚一些在XCode环境下的一些概念【4】:

  • Workspace:简单来说,Workspace就是一个容器,在该容器中可以存放多个你创建的Xcode Project, 以及其他的项目中需要使用到的文件。使用Workspace的好处有,1),扩展项目的可视域,即可以在多个项目之间跳转,重构,一个项目可以使用另一个项目的输出。Workspace会负责各个Project之间提供各种相互依赖的关系;2),多个项目之间共享Build目录。
  • Project:指一个项目,该项目会负责管理生成一个或者多个软件产品的全部文件和配置,一个Project可以包含多个Target。
  • Target:一个Target是指在一个Project中构建的一个产品,它包含了构建该产品的所有文件,以及如何构建该产品的配置。
  • Scheme:一个定义好构建过程的Target成为一个Scheme。可在Scheme中定义的Target的构建过程有:Build/Run/Test/Profile/Analyze/Archive
  • BuildSetting:配置产品的Build设置,比方说,使用哪个Architectures?使用哪个版本的SDK?。在Xcode Project中,有Project级别的Build Setting,也有Target级别的Build Setting。Build一个产品时一定是针对某个Target的,因此,XCode中总是优先选择Target的Build Setting,如果Target没有配置,则会使用Project的Build Setting。

  弄清楚上面的这些概念之后,xcodebuild就很好理解了,官网上对其作用的描述如下:

xcodebuild builds one or more targets contained in an Xcode 
project, or builds a scheme contained in an Xcode workspace or 
Xcode project.

  xcodebuild就是用了构建产品的命令行工具,其用法可以归结为3个部分:

  • 可构建的对象
  • 构建行为
  • 一些其他的辅助命令

  可以构建的对象有,默认情况下会运行project下的第一个target:

  • workspace:必须和“-scheme”一起使用,构建该workspace下的一个scheme。
  • project:当根目录下有多个Project的时候,必须使用“-project”指定project,然后会运行
  • target:构建某个Target
  • scheme:和“-workspace”一起使用,指定构建的scheme。
  • ……

  构建行为包括:

  • clean:清除build目录下的
  • build: 构建
  • test: 测试某个scheme,必须和"-scheme"一起使用
  • archive:打包,必须和“-scheme”一起使用
  • ……

  辅助命令包括:

  • -sdk:指定构建使用的SDK
  • -list:列出当前项目下所有的Target和scheme。
  • -version:版本信息
  • …...

  关于xcodebuild更多详细的命令行请参见:https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/xcodebuild.1.html

  下图是使用XcodeBuild运行一个scheme的build的结果:

  bubuko.com,布布扣

  了解了xcodebuild的用法之后,接下来分析一下xcodebuild的主要缺陷:

  • 从上图直接可以得到的感觉,其脚本输出的可读性极差,
  • 只能要么完整的运行一个target或者scheme,要么全部不运行。不能指定运行Target中特定的测试。
  • 最令人发指的是,XCode 4中的xcodebuild居然不支持iOSUnitTest的Target【5】,当我尝试运行一个iOS App的测试target时,得到如下的错误:

      bubuko.com,布布扣

文章来源:

http://jishu.zol.com.cn/12244.html?qq-pf-to=pcqq.c2c

xcodebuild命令:

Usage: xcodebuild [-project <projectname>] [[-target <targetname>]...|-alltargets] [-configuration <configurationname>] [-arch <architecture>]... [-sdk [<sdkname>|<sdkpath>]] [-showBuildSettings] [<buildsetting>=<value>]... [<buildaction>]...

       xcodebuild [-project <projectname>] -scheme <schemeName> [-destination <destinationspecifier>]... [-configuration <configurationname>] [-arch <architecture>]... [-sdk [<sdkname>|<sdkpath>]] [-showBuildSettings] [<buildsetting>=<value>]... [<buildaction>]...

       xcodebuild -workspace <workspacename> -scheme <schemeName> [-destination <destinationspecifier>]... [-configuration <configurationname>] [-arch <architecture>]... [-sdk [<sdkname>|<sdkpath>]] [-showBuildSettings] [<buildsetting>=<value>]... [<buildaction>]...

       xcodebuild -version [-sdk [<sdkfullpath>|<sdkname>] [<infoitem>] ]

       xcodebuild -list [[-project <projectname>]|[-workspace <workspacename>]]

       xcodebuild -showsdks

       xcodebuild -exportArchive -exportFormat <format> -archivePath <xcarchivepath> -exportPath <destinationpath> [-exportProvisioningProfile <profilename>] [-exportSigningIdentity <identityname>] [-exportInstallerIdentity <identityname>]

Options:

    -usage                                    print brief usage

    -help                                     print complete usage

    -verbose                                  provide additional status output

    -license                                  show the Xcode and SDK license agreements

    -checkFirstLaunchStatus                   Check if any First Launch tasks need to be performed

    -project NAME                             build the project NAME

    -target NAME                              build the target NAME

    -alltargets                               build all targets

    -workspace NAME                           build the workspace NAME

    -scheme NAME                              build the scheme NAME

    -configuration NAME                       use the build configuration NAME for building each target

    -xcconfig PATH                            apply the build settings defined in the file at PATH as overrides

    -arch ARCH                                build each target for the architecture ARCH; this will override architectures defined in the project

    -sdk SDK                                  use SDK as the name or path of the base SDK when building the project

    -toolchain NAME                           use the toolchain with identifier or name NAME

    -destination DESTINATIONSPECIFIER         use the destination described by DESTINATIONSPECIFIER (a comma-separated set of key=value pairs describing the destination to use)

    -destination-timeout TIMEOUT              wait for TIMEOUT seconds while searching for the destination device

    -parallelizeTargets                       build independent targets in parallel

    -jobs NUMBER                              specify the maximum number of concurrent build operations

    -dry-run                                  do everything except actually running the commands

    -showsdks                                 display a compact list of the installed SDKs

    -showBuildSettings                        display a list of build settings and values

    -list                                     lists the targets and configurations in a project, or the schemes in a workspace

    -find-executable NAME                     display the full path to executable NAME in the provided SDK and toolchain

    -find-library NAME                        display the full path to library NAME in the provided SDK and toolchain

    -version                                  display the version of Xcode; with -sdk will display info about one or all installed SDKs

    -resultBundlePath PATH                    specifies the directory where a result bundle describing what occurred will be placed

    -derivedDataPath PATH                     specifies the directory where build products and other derived data will go

    -archivePath PATH                         specifies the directory where any created archives will be placed, or the archive that should be exported

    -exportArchive                            specifies that an archive should be exported

    -exportFormat FORMAT                      specifies the format that the archive should be exported as (e.g. ipa, pkg, app)

    -exportPath PATH                          specifies the destination for the product exported from an archive

    -exportProvisioningProfile PROFILE NAME   specifies the provisioning profile that should be used when re-signing the exported archive; if possible, implies a signing identity

    -exportSigningIdentity IDENTITY NAME      specifies the codesigning identity that should be used to re-sign the exported archive

    -exportInstallerIdentity IDENTITY NAME    specifies the installer signing identity that should be used during export; this may be inferable from -exportSigningIdentity

    -exportWithOriginalSigningIdentity        specifies that the signing identity used to create the archive should be used to sign the exported product

    -skipUnavailableActions                   specifies that scheme actions that cannot be performed should be skipped instead of causing a failure

xcodebuild: error: If you specify a workspace then you must also specify a scheme.  Use -list to see the schemes in this workspace.

xcodebuild -workspace xx.xcworkspace -list:查看xcworkspace下所有的scheme

mac xcworkspace xcodebuild,布布扣,bubuko.com

mac xcworkspace xcodebuild

标签:des   http   使用   os   io   strong   文件   for   

原文地址:http://www.cnblogs.com/ppsunlight/p/3927800.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!