Skip to content

Latest commit

 

History

History
199 lines (124 loc) · 4.82 KB

xcodebuild-deploy.md

File metadata and controls

199 lines (124 loc) · 4.82 KB

自动打包并发布应用

$ xcodebuild --help
-parallelizeTargets                                      build independent targets in parallel
-jobs NUMBER                                             specify the maximum number of concurrent build operations
-maximum-concurrent-test-device-destinations NUMBER      the maximum number of device destinations to test on concurrently
-maximum-concurrent-test-simulator-destinations NUMBER   the maximum number of simulator destinations to test on concurrently
-parallel-testing-enabled YES|NO                         overrides the per-target setting in the scheme
-parallel-testing-worker-count NUMBER                    the exact number of test runners that will be spawned during parallel testing
-maximum-parallel-testing-workers NUMBER                 the maximum number of test runners that will be spawned during parallel testing

xcodebuild 打包

各参数使用说明

$ man xcodebuild 查看xcodebuild所有用法

-workspace

指定workspace. 必须和“-scheme”一起使用,构建该workspace下的一个scheme。

-project

指定project. 当根目录下有多个project的时候,必须使用“-project”指定project,

-target

指定target

-scheme

指定scheme. 和“-workspace”一起使用,指定构建的scheme。

-showsdks

列出可用的SDK

$ xcodebuild -showsdks

-sdk

设置SDK

-sdk iphoneos9.2

-list

列出所有可用的TargetsBuild ConfigurationsSchemes

// 列出默认Project的
$ xcodebuild -list
// 列出指定workspace的
$ xcodebuild -list -workspace <NAME>.xcworkspace/

-configuration

编译的方式,Release,Debug,Adhoc 等

-destination

generic/platform=iOS

ONLY_ACTIVE_ARCH

ONLY_ACTIVE_ARCH=NO

-showBuildTimingSummary

显示编译时间

-parallel-testing-enabled [YES | NO]

是否开启单元测试并行执行

-parallelizeTargets

开启并发编译无依赖的目标

-jobs NUMBER

并发编译数

构建行为

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

scheme

用到的scheme都要设置成share

编译

$ xcodebuild -workspace ${WORKSPACE_NAME}.xcworkspace -scheme ${SCHEME_NAME} -sdk ${SDK_VERSION} -configuration ${CONFIGURATION} ONLY_ACTIVE_ARCH=NO build

打包

clean

$ xcodebuild -workspace ${WORKSPACE_NAME}.xcworkspace -scheme ${SCHEME_NAME} -sdk ${SDK_VERSION} -configuration ${CONFIGURATION} ONLY_ACTIVE_ARCH=NO clean

archive

导出.xcarchive该文件

$ xcodebuild -workspace ${WORKSPACE_NAME}.xcworkspace -scheme ${SCHEME_NAME} -sdk ${SDK_VERSION} -configuration ${CONFIGURATION} -destination ${ARCHIVE_DESTINATION} -archivePath ${APP_DIR}/${APP_NAME}.xcarchive ONLY_ACTIVE_ARCH=NO archive

export ipa

导出ipa文件

-exportProvisioningProfile

描述该文件名称,描述该文件<key>Name</key>对应的值

-exportOptionsPlist

plist文件路径。 $ xcodebuild --helpplist文件参数

eg:
$ TIMESTAMP=`date "+%Y_%m_%d_%H_%M_%S"`
$ IPA_PATH_NO_SUFFIX=${APP_DIR}/${APP_NAME}_${TIMESTAMP}
$ xcodebuild -exportArchive -archivePath ${APP_DIR}/${APP_NAME}.xcarchive -exportPath ${IPA_PATH_NO_SUFFIX} -exportProvisioningProfile "${PROFILE_NAME}" -exportFormat ipa -verbose

发布到fir.im

安装cli

https://github.com/FIRHQ/fir-cli/blob/master/README.md

$ ruby -v # > 1.9.3
$ gem install fir-cli

发布ipa

fir publish ${IPA_PATH_NO_SUFFIX}.ipa -T ${FIR_TOKEN} || failed "fir publish"

常见问题

Q1

** ARCHIVE FAILED **


The following build commands failed:
	CompileC ***** normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

A1

直接用Archive :Xode > Product > Archive,可以提示具体的代码错误。

实例

Example

相关资料