xcodebuild打包命令

简介

打包一般使用GUI操作进行。但是对于复杂工程还是繁琐。比如同一个工程对应多个target,多个scheme,多个证书。另外对于持续化集成还不足够,所以需要使用Xcodebuild进行脚本化。

Tips:针对Xcode进行过重签名,in-house包会失败。

 

使用

以下针对xcode8,xcworkspace文件进行打包。

打包分为三步:

1、 清理 - clean

xcodebuild clean -workspace MyWorkspace.xcworkspace -scheme MyScheme

2、 归档 - archive

xcodebuild archive -workspace MyWorkspace.xcworkspace -scheme MyScheme

3、 导出 - export

xcodebuild -exportArchive -archivePath MyMobileApp.xcarchive -exportPath ExportDestination -exportOptionsPlist 'exportPlist.plist'

 

需要参数

@requiredbundle_identifierdevelopment_teamcode_sign_identityprovisioning_profile@optionalapp_groupextension_bundle_identifierextension_provisioning_profile

 

相关问题

  • 多环境

1、PROJECT -> Info -> Configurations 中添加configuration。 

2、PROJECT -> Build Settings -> Preprocessor Macros 中添加宏。 

如:DEBUG_LOG=1 

3、在代码中判断宏,配置不同环境变量:

#ifdef DEBUG_LOG#endif

4、增加scheme对应configuration。 

5、针对scheme打包即是针对环境打包。

 

  • 多工程

一个工程对应一个scheme,针对scheme打包即是针对工程打包。

 

  • 不同证书

打包时设置bundle_identifier、development_team、code_sign_identity、provisioning_profile等参数即可。

 

  • exportPlist相关参数

简单来说method中enterprise为企业包,app-store为App Store发布包。

methodapp-storeuploadBitcodeuploadSymbols

 

对应参数详情

Available keys for -exportOptionsPlist:

    compileBitcode : Bool

        For non-App Store exports, should Xcode re-compile the app from bitcode? Defaults to YES.

    embedOnDemandResourcesAssetPacksInBundle : Bool

        For non-App Store exports, if the app uses On Demand Resources and this is YES, asset packs are embedded in the app bundle so that the app can be tested without a server to host asset packs. Defaults to YES unless onDemandResourcesAssetPacksBaseURL is specified.

    iCloudContainerEnvironment

        For non-App Store exports, if the app is using CloudKit, this configures the "com.apple.developer.icloud-container-environment" entitlement. Available options: Development and Production. Defaults to Development.

    manifest : Dictionary

        For non-App Store exports, users can download your app over the web by opening your distribution manifest file in a web browser. To generate a distribution manifest, the value of this key should be a dictionary with three sub-keys: appURL, displayImageURL, fullSizeImageURL. The additional sub-key assetPackManifestURL is required when using on demand resources.

    method : String

        Describes how Xcode should export the archive. Available options: app-store, ad-hoc, package, enterprise, development, and developer-id. The list of options varies based on the type of archive. Defaults to development.

    onDemandResourcesAssetPacksBaseURL : String

        For non-App Store exports, if the app uses On Demand Resources and embedOnDemandResourcesAssetPacksInBundle isn't YES, this should be a base URL specifying where asset packs are going to be hosted. This configures the app to download asset packs from the specified URL.

    teamID : String

        The Developer Portal team to use for this export. Defaults to the team used to build the archive.

    thinning : String

        For non-App Store exports, should Xcode thin the package for one or more device variants? Available options: (Xcode produces a non-thinned universal app), for-all-variants> (Xcode produces a universal app and all available thinned variants), or a model identifier for a specific device (e.g. "iPhone7,1"). Defaults to .

    uploadBitcode : Bool

        For App Store exports, should the package include bitcode? Defaults to YES.

    uploadSymbols : Bool

        For App Store exports, should the package include symbols? Defaults to YES.

  • extension打包

包含extension的项目,需要指定多个provisioning_profile。以下步骤适用于主工程和extension工程: 

1、手动选择证书 

2、Build Settings -> Product Bundle Identifier -> 清空release对应的value 

3、Build Settings -> Provisioning Profile -> release对应的value改为$APP_PROFILE(extension改为$EXTENSION_PROFILE)`

tips:APP_PROFILE、EXTENSION_PROFILE均可自定义,如extension有多个自行改名区分。 

打包的归档部分修改如下:

xcodebuild archive -workspace MyWorkspace.xcworkspace -scheme MyScheme DEVELOPMENT_TEAM=${development_team} CODE_SIGN_IDENTITY=${code_sign_identity} APP_PROFILE=${provisioning_profile}  EXTENSION_PROFILE=${extension_provisioning_profile}

总结

脚本如下:

ios-build.shbuildPath="yourbuildPath"scheme="yourscheme"package="yourpackage"develop_team="yourdevelop_team"code_sign_identity="yourcode_sign_identity"provisioning_profile="yourprovisioning_profile"extension_provisioning_profile="yourextension_provisioning_profile"xcodebuild clean -workspace "${package}.xcodeproj/project.xcworkspace" -scheme ${scheme}xcodebuild archive -workspace "${package}.xcodeproj/project.xcworkspace" -scheme ${scheme} -archivePath "${buildPath}/${package}.xcarchive" DEVELOPMENT_TEAM="${develop_team}" CODE_SIGN_IDENTITY="${code_sign_identity}" APP_PROFILE="${provisioning_profile}"  EXTENSION_PROFILE="${extension_provisioning_profile}"xcodebuild -exportArchive -archivePath "${buildPath}/${package}.xcarchive" -exportPath "${buildPath}/${package}" -exportOptionsPlist exportPlist.plist

exportPlist.plist

methoddevelopmentuploadBitcodeuploadSymbolsprovisioningProfiles{bundle_identifier}{provisioning_profile}

 


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部