打包准备工作
- 确保Xcode 安装 Command Line Tools (XCode自带,一般情况下都有)
- 项目的证书配置文件准确无误
- 项目可以编译运行无误
- 准备打包需要 exportOptionsPlist 文件
文件介绍
-
文件格式
exportOptionsPlist 文件的 Source Code 你可以直接复制进行替换关键key-value
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>generateAppStoreInformation</key>
<false/>
<key>method</key>
<string>app-store</string>
<key>provisioningProfiles</key>
<dict>
<key 填写您的bundleid</key>
<string>配置文件名称</string>
</dict>
<key>signingCertificate</key>
<string>iPhone Distribution</string>
<key>signingStyle</key>
<string>manual</string>
<key>stripSwiftSymbols</key>
<true/>
<key>teamID</key>
<string>填写您的teamID</string>
<key>uploadBitcode</key>
<false/>
<key>uploadSymbols</key>
<true/>
</dict>
</plist>
实际使用中 我们需要修改 method , provisioningProfiles , teamID
method :描述Xcode 如何 导出 archive ,具体参数见下文
provisioningProfiles: 一个字段 , key = 应用的 bundleid , value = 配置文件名称
teamID:在ITC后台 进行查看
tips: exportOptionsPlist 设置简便方法,我们可以先使用Xcode 正常导出一个任何类型ipa,我们可以在导出的文件夹里面直接找到此文件,直接修改即可
- 具体参数含义介绍 (我们可以在 终端 中使用命令 ‘ xcodebuild -help ’ 进行获取 )
compileBitcode : Bool
For non-App Store exports, should Xcode re-compile the app from bitcode? Defaults to YES.
destination : String
Determines whether the app is exported locally or uploaded to Apple. Options are export or upload. The available options vary based on the selected distribution method. Defaults to export.
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.
generateAppStoreInformation : Bool
For App Store exports, should Xcode generate App Store Information for uploading with iTMSTransporter? Defaults to NO.
iCloudContainerEnvironment : String
If the app is using CloudKit, this configures the "com.apple.developer.icloud-container-environment" entitlement. Available options vary depending on the type of provisioning profile used, but may include: Development and Production.
installerSigningCertificate : String
For manual signing only. Provide a certificate name, SHA-1 hash, or automatic selector to use for signing. Automatic selectors allow Xcode to pick the newest installed certificate of a particular type. The available automatic selectors are "Mac Installer Distribution" and "Developer ID Installer". Defaults to an automatic certificate selector matching the current distribution method.
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, validation, ad-hoc, package, enterprise, development, developer-id, and mac-application. 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.
provisioningProfiles : Dictionary
For manual signing only. Specify the provisioning profile to use for each executable in your app. Keys in this dictionary are the bundle identifiers of executables; values are the provisioning profile name or UUID to use.
signingCertificate : String
For manual signing only. Provide a certificate name, SHA-1 hash, or automatic selector to use for signing. Automatic selectors allow Xcode to pick the newest installed certificate of a particular type. The available automatic selectors are "Mac App Distribution", "iOS Distribution", "iOS Developer", "Developer ID Application", and "Mac Developer". Defaults to an automatic certificate selector matching the current distribution method.
signingStyle : String
The signing style to use when re-signing the app for distribution. Options are manual or automatic. Apps that were automatically signed when archived can be signed manually or automatically during distribution, and default to automatic. Apps that were manually signed when archived must be manually signed during distribtion, so the value of signingStyle is ignored.
stripSwiftSymbols : Bool
Should symbols be stripped from Swift libraries in your IPA? Defaults to YES.
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: <none> (Xcode produces a non-thinned universal app), <thin-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 <none>.
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.
- 使用命令行进行打包(这里介绍其中一种)
=> 其中 引号 部分 代表 需要我们填写的参数
xcodebuild clean -workspace " " -scheme " " -configuration " "
参数1:workspace 所在绝对路径(找到文件,直接拖进终端即可)
参数2:项目APP的scheme
参数3:Debug 或者 Release
xcodebuild archive -workspace " " -scheme " " -archivePath " "
参数1:workspace 所在绝对路径(找到文件,直接拖进终端即可)
参数2:项目APP的scheme
参数3:archive 文件 存放位置(导出ipa时候需要使用)
xcodebuild -exportArchive -archivePath " " -exportPath " " -exportOptionsPlist " "
参数1:在上一步中我们 设置archive 文件 的存放位置
参数2:导出ipa之后存放的位置
参数3:我们编辑好的plist 文件路径
使用时候需要注意,命令行中的scheme 并不是 我们拉起应用时候使用的scheme
这里的scheme 通俗点说 就是 我们定义的target
Scheme
scheme定义了可以用于编译若干target,以及编译这些target时的一些配置和要执行的测试。我们可以定义多个scheme,但是每次只能使用其中一个。我们可以设置scheme保存在project中还是workspace中。如果保存在project中,那么任意包含了这个project的workspace都可以使用。如果保存在workspace中,那么只有这个workspace可以使用。选择了scheme就意味着选择了运行目标。