Configuring Your Xcode Project for Distribution

You can edit your project settings anytime, but some settings are necessary during development. Others are recommended when you distribute your app for beta testing and required when you submit your app to the App Store or Mac App Store.

你可以在任何时候编辑项目设置,除了一些在开发期间必要的设置。 其它设置建议你可以在发布应用做beta测试以及当你把应用程序提交到应用商店或Mac 应用商店要求时设置。

During development, your app must be provisioned and code signed to use certain app services and run on an iOS device (iPad, iPhone, or iPod touch). If you assign a bundle ID and team to your project, Xcode can create the necessary certificates, identifiers, and profiles for you in Member Center. You can enter this information now using the project editor or as needed when you add app services and launch your app.

在开发期间,你的应用程序必须是已经配置而且是经过代码签名之后才能使用特定的应用程序服务,才能在一个iOS设备(比如iPad, iPhone, 或iPod touch)上运行。当你给应用程序设置了一个bundle ID 和 team后,Xcode就在Member Center里为应用程序创建必要的cerfificates(证书), identifiers(识别码)以及profiles(配置文件)。你可以现在用项目编辑器(project editor)输入这些信息,也可以在你运行应用服务以及加载应用程序请求时添加。

Before you distribute your app for testing or to the store, provide all the required information about your app. For example, set app icons to pass iTunes Connect validation tests.

当你发布应用程序进行测试或到应用商店之前,提供应用程序所需要的所有信息。比如设置应用程序图标通过iTunes Connect的验证测试。

Before you upload your app to the store, verify your build settings and set the copyright key for Mac apps.

上传应用程序到应用商店之前,验证你的构建设置,并为Mac应用程序设置版权(copyright)。

Setting Properties When Creating Your Xcode Project

一、创建Xcode项目时设置各种特性

An assistant guides you through the process of creating an Xcode project. First, you select a template for your project. Starting with the right template helps speed the development process. The assistant also prompts you to enter information about your app that’s used to determine your app’s capabilities and distribute it to customers. If you don’t have this information when you create the project, you can set these properties later. If you are a member of the iOS Developer Program or Mac Developer Program, some of the data in the Xcode project is similar to the data you enter in iTunes Connect, but only the bundle ID needs to match the bundle ID you enter in iTunes Connect before you can upload your app to the store.

一个助手将引导您完成创建Xcode项目的进程。首先,为你的项目创建选择一个模板。选择一个正确地模板可以加快开发进程。 助手还提示你输入应用程序的信息,这些信息将决定你的应用程序能干什么并把它发布给用户。如果你在创建项目时没有设置这些信息,你可以在以后设置。如果你是iOS 开发者计划 或 Mac 开发者计划中的一员,一些你在Xcode项目中输入的数据跟你在iTunes Connect中数据会很相似,但是只有项目的bundle ID 跟iTunes Connect中输入的bundle ID保持一致,才能让你成功把应用程序上传到应用商店。

Note: If you don’t have an Xcode project, read the tutorial in Start Developing iOS Apps Today or Start Developing Mac Apps Today to learn how to create one. You can’t perform the tasks in this book without first creating an Xcode project that builds and runs an app.

注意:如果你还没有一个Xcode 项目,阅读Start Developing iOS Apps Today教程或阅读Start Developing Mac Apps Today 教程,学习如何创建Xcode项目。 如果你不首先创建一个Xcode项目并构建运行一个应用程序,你无法执行本书中的任何任务。

 

For iOS apps, a dialog similar to this appears when you create an Xcode project from a template:

当你创建iOS项目时,你会发现选择了一个模板后会出现跟下图相似的对话框:  

../Art/3_xcodeassistant_2x.png

The product name is the name of your app as it will appear to customers in the store and should be similar to the app name you enter later in iTunes Connect. Most importantly, a customer should instantly associate the app name and icon in the App Store with the product name and app icon that installs on their devices. The product name is also the name that will appear in Springboard when the app is installed. The product name can’t be longer than 255 bytes and can be no fewer than 2 characters. (Read Best Practices in iTunes Connect Developer Guide for guidelines on choosing an app name.)

product name 是应用程序的名称,它将显示在应用商店让用户看到。该名字跟你以后在iTunes Connect中要输入的应用名称应该类似。 最重要的是,当用户下载了该应用后看到产品名称(product name)和应用图标(app icon)能立即跟应用商店里的应用名称和图标关联上。当应用程序被下载后,该产品名称还会被显示在Springboard上。产品名称不能超过255字节,也不能少于2个字节。(参见  iTunes Connect Developer Guide 中 Best Practices 里 关于如何选择一个应用名称的指南。)

The organization name is an attribute of the Xcode project and is used in boilerplate text throughout your project folder. For example, the organization name is used in the source and header file copyright strings. The organization name in your Xcode project isn’t the same as the company name that you enter later in iTunes Connect.

organizetion name 是Xcode 项目的一个属性,它被用于整个项目文件夹的样板文本(boilerplate text)中。 比如,组织名称(organization name)被用于资源文件和头文件的版权字符串中。 Xcode 项目中组织名称(organization name)跟你以后在iTunes Connect中输入的公司名称(company name)不一样。

The product name and company identifier you enter are concatenated to create the default bundle ID using reverse domain name service (reverse DNS) notation. The bundle ID needs to be unique to your app, so it’s important to set the company identifier to a unique string as well.

你输入的产品名称(product name)和公司识别符(company identifier)用反向域名服务符号(反向DNS)串联起来用于创建默认的bundle ID。应用程序中的bundle ID必须是唯一的,所以设置一个唯一的公司识别符(company identifier)也很重要。

For iOS apps, you can choose the types of devices you support from the Devices pop-up menu. For Mac apps, you can choose the Mac App Store categories from a pop-up menu.

对于iOS应用程序,你可以从Devices 弹出菜单选择你所要支持的设备类型。 Mac应用程序则可以从一个弹出菜单选择Mac应用商店类别。

The other values used by the Xcode template are sufficient for building and running your app locally, but later you’ll need to finalize properties, such as the bundle ID. Also, the assistant doesn’t set all required properties for the store. You complete the basic store configuration before you submit. Ideally, you’ll complete this configuration before you distribute your app for testing too.

Xcode模板提供的其它值用来构建和运行本地应用程序已经足够,但是以后你将需要完成特性的设置,比如bundle ID. 而且助手没有为商店设置所有需要的特性。你需要在提交之前完成基本的商店配置。理想情况下,你将在发布应用程序进行测试之前完成该配置。

After your app is released, you can’t change some of this metadata, so it’s important to choose your settings carefully. To learn which app states cause some properties to be locked in iTunes Connect, refer to iTunes Connect App Properties in iTunes Connect Developer Guide.

当你的应用程序被发布(release)了之后, 一些元数据就无法改变,因此仔细选择你的设置很重要。要了解哪些应用程序状态造成iTunes Connect 中的一些特性被锁定,请参阅 iTunes Connect Developer Guide 中的  iTunes Connect App Properties

Before You Begin Configuring Your Project

二、开始配置你的项目之前

All of the options discussed in this chapter are located in the General pane in the project editor for your target. To open the project navigator, choose View > Navigators > Show Project Navigator. Choose the target from the Project/Targets pop-up menu or in the Targets section of the second sidebar if it appears. Click General to view settings discussed in this chapter.

本章讨论的所有选项都在你的target的项目编辑器(project editor)的General面板中。要想开启项目导航(project navigator),选择View > Navigators > Show Project Navigator. 从Project 或Targets弹出菜单中选择target, 或者如果出现第二边栏(second sidebar),可以在它上面的Targets区选择target。点击General查看本章中讨论的设置(settings)。

The screenshot below shows the General pane for an iOS app.

下图显示了一个iOS应用程序的General面板快照。

../Art/3_project_navigator_2x.png

Configuring Identity and Team Settings

三、配置标识和团队设置

For Xcode to create the team provisioning profile, the app’s bundle ID needs to be unique and the project assigned to a team. Later, you provide other information that identifies this version of your app. The identity settings appear in the Identity section of the target’s General pane. For iOS apps, the Identity section appears as shown here:

对于Xcode,要想创建团队配置文件(team provisioning profile), 首先应用程序的bundle ID必须得唯一,并把项目分配为一个team。然后,提供其他信息来识别应用程序的版本。 在target的General面板中的Identity区设置identity settings。下图为iOS应用程序的Identity区快照:

../Art/3_ios_app_target_pane_2x.png

About Bundle IDs

1、关于Bundle IDs

bundle ID precisely identifies a single app. A bundle ID is used during the development process to provision devices and by the operating system when the app is distributed to customers. For example, Game Center and In-App Purchase use a bundle ID to identify your app when using these app services. The preferences system uses this string to identify the app for which a given preference applies. Similarly, Launch Services uses the bundle ID to locate an app capable of opening a particular file, using the first app it finds with the given identifier. The bundle ID is also used to validate an app’s signature.

bundle ID 可以明确地识别一个应用程序。bundle ID 在开发过程中提供给设备以及当应用程序发布给用户后提供给操作系统使用。比如,当使用Game Center 和 内置购买(In-App Purchase) 时,它们将使用bundle ID来识别你的应用程序。类似地,启动服务用bundle ID来让应用程序能够打开一个特殊文件,该应用程序就是使用给定的标识符(identifier)能够找到的第一个应用程序。bundle ID还可以验证一个应用程序的签名。

The bundle ID string must be a uniform type identifier (UTI) that contains only alphanumeric characters (A-Z,a-z,0-9), hyphen (-), and period (.). The string should be in reverse-DNS format. For example, if your company’s domain is Acme.com and you create an app named Hello, you could assign the string com.Acme.Helloas your app’s bundle ID.

bundle ID字符串必须是一个同一类型标识符(UTI),它只包括字母数字字符(A-Z, a-z,0-9),连字符(-),以及点(.). 字符串应该是反向域名服务格式。比如,如果你的公司的域名为Acme.com,并且你创建一个已经名叫Hello的应用,你的bundle ID就是com.Acme.Hello.

During the development process, you use an app’s bundle ID in many different places to identify the app.

在开发期间,你需要在很多不同的地方使用应用bundle ID来识别应用程序。

../Art/BundleID.png

Specifically, the bundle ID is located and used as follows:

具体来说,bundle ID可以在以下地方使用:

    • In the Xcode project, the bundle ID is stored in the information property list file (Info.plist). This file is later copied into your app’s bundle when you build the project.

在Xcode项目中,bundle ID被存储在Info.plist文件中。 当你构建(build)该项目时,该文件会被拷贝进应用程序的bundle里。

    • In Member Center, you create an App ID that matches the app’s bundle ID. If the App ID is an explicit App ID, it exactly matches the bundle ID. However, unlike domain names, bundle IDs are case sensitive. If the App ID is lowercase, your bundle ID needs to be lowercase, too.

在Member Center中,你创建一个App ID跟应用bundle ID相匹配. 如果App ID 是一个explicit App ID, 它能跟bundle ID完全匹配。然而,不像域名,bundle ID 都是区分大小写的。 如果App ID是小写的,那么你的bundle ID也需要小写。

    • In iCloud, the container IDs you specify in your Xcode project are based on the bundle IDs of one or more apps.

在iCloud中,你在Xcode项目中指定的容器ID都是基于一个或多个应用程序的bundle ID的。

    • In iTunes Connect, you enter the bundle ID to identify your app. After your first version is available on the store, you can’t change your bundle ID or delete the associated explicit App ID.

在iTunes Connect中,你输入bundle ID来识别你的应用程序。 当你的应用程序在应用商店上线了之后,你不能再更改你的bundle ID,也不能删除相关的 Explicit App ID。

Note: A Mac app and an iOS app can’t share the same bundle ID.

注意:一个Mac 应用程序和一个iOS应用程序之间不能共享一个bundle ID.

 

Setting the Bundle ID

2. 设置Bundle ID

The default bundle ID in your Xcode project is a string formatted as a reverse-domain—for example, com.MyCompany.MyProductName. To create the default bundle ID, Xcode concatenates the company identifier with the product name you entered when creating the project from a template, as described in Setting Properties When Creating Your Xcode Project. (Xcode replaces spaces in the product name to create the default bundle ID.) It may be sufficient to replace the company identifier prefix in the bundle ID, or you can replace the entire bundle ID. For example, change the company identifier prefix to match your company domain name, or replace the entire bundle ID to match an explicit App ID.

Xcode项目中的默认bundle ID是一个反域名格式的字符串---比如,com.myCompany.MyProductName. 当你从一个模板创建一个项目时,Xcode会把公司标识符和你输入的产品名称串联起来创建一个默认的bundle ID,正如在 Setting Properties When Creating Your Xcode Project 中所述。 (Xcode 把产品名称中的空格替换掉后创建默认的bundle ID) 你可以修改bundle ID中的公司标识符前缀,或者你可以把整个bundle ID都改成跟Explicit App ID相匹配的bundle ID.

For Mac apps, ensure that every bundle ID is unique within your app bundle. For example, if your app bundle includes a helper app, make sure that its bundle ID is different from your app’s bundle ID.

对于Mac应用程序,确保你的应用bundle中的每个bundle ID都是唯一的。比如,如果你的应用bundle中包含了一个helper 应用程序,请确保它的bundle ID跟你的应用程序的bundle ID不一样。

Follow these steps to change the bundle ID prefix in the General pane in the project editor.

跟着以下步骤来修改项目编辑器(project editor)的General面板中的bundle ID的前缀。

To set the bundle ID prefix

要想设置bundle ID前缀:

  1. In the project navigator, select the project and your target to display the project editor.

    在项目导航区, 选择project 以及你的target,显示项目编辑器(project editor)。

  2. Click General and, if necessary, click the disclosure triangle next to Identity to reveal the settings.

    点击General, 如果需要,点击Identity边上的展开三角把设置展开。

    ../Art/3_ios_app_target_pane_2x.png
  3. Enter the bundle ID prefix in the Bundle Identifier field.

    在Bundle Identifier区输入bundle ID前缀。

Alternatively, follow these steps to change the entire bundle ID in the Info pane in the project editor.

另外,跟随以下步骤更改项目编辑器重Info面板中的整个bundle ID。

To set the bundle ID

设置bundle ID

  1. In the project navigator, select the project and your target to display the project editor.

    在项目导航,选择项目和你的target, 显示项目编辑器。

  2. Click Info.

    点击Info。

  3. Enter the bundle ID in the Value column of the “Bundle identifier” row.

    在“Bundle identifier"行输入bundle ID的值。

    ../Art/3_ios_info_bundle_id_2x.png

Choosing a Signing Identity (Mac Only)

3. 选择一个签名标识符(仅Mac)

You have the choice of submitting your Mac app to the store, signing it with a Developer ID certificate to distribute it outside of the store, or not code signing it at all. If you select Mac App Store, you assign your Xcode project to a team and can enable app services, as described in Adding Capabilities. If you select Developer ID, you assign your Xcode project to a team but can’t use any app services in your application (read Distributing Applications Outside the Mac App Store for how to create a Developer ID-signed application). If you select None, the Team pop-up menu is disabled and you don’t need to read this guide.

 

 

To select a signing identity

 

  1. In the project navigator, select the project and your target to display the project editor.

     

  2. Click General and, if necessary, click the disclosure triangle next to Identity to reveal the settings.

     

  3. Select the type of signing identity you want to use.

     

    • If you want to submit your app to the store, select Mac App Store.

       

    • If you want to distribute your Mac application outside of the store and not use app services, select Developer ID.

       

    • If you don’t want to sign your application or use app services, select None.

       

    ../Art/3_selectdistributionmethod_2x.png

Assigning the Xcode Project to a Team

4. 给Xcode项目设置一个团队

Each Xcode project is associated with a single team. If you enroll as an individual, you’re considered a one-person team. The team account is used to store the certificates, identifiers, and profiles needed to provision your app. All iOS apps and some Mac apps need to be code signed and provisioned to run on a device and use certain app services. Xcode creates these assets for you when needed, but you can avoid warnings and dialogs later if you set the team now.

每个Xcode项目都跟一个单独的团队有关。 如果你是个人开发,则你被认为是一个一人团队。 团队账号用来存储各种证书(certificates),标识符(identifiers)以及应用程序的各种配置文件(provision profiles)。所有的iOS应用程序和一些Mac应用程序都需要签名和配置后才能在设备上运行和使用一些特定的应用服务。 Xcode在需要的时候为你创建这些assets,但是如果你现在设置了团队你就可以避开各种警告和对话框。

To assign the project to a team

为项目设置一个团队:

  1. In the project navigator, select the project and your target to display the project editor.

    在项目导航,选择项目和你的target,显示项目编辑器。

  2. Click General and, if necessary, click the disclosure triangle next to Identity to reveal the settings.

    点击General ,如果需要点击Identity边上的展开三角展开各种设置。

  3. Choose your team from the Team pop-up menu.

    从Team弹出菜单选择你的团队。

    • If you’re an individual, choose your name from the pop-up menu.

      如果你是个人开发,从弹出菜单选择你的名字。

    • If you’re a company, choose your company name from the pop-up menu.

      如果你是一个公司,从弹出菜单选择你的公司名称。

    ../Art/3_assignteam_ios_2x.png

    Xcode may attempt to create a team provisioning profile. For iOS apps, Xcode creates a team provisioning profile if you have an iOS device connected or have previously registered an iOS device. To resolve issues related to the team provisioning profile, read Creating the Team Provisioning Profile.

    Xcode或许会尝试着创建一个团队配置文件(provisioning profile)。对于iOS应用程序,Xcode创建一个团队配置文件,如果你连接了一个iOS设备或者以前注册过一个iOS设备。想要解决团队配置文件相关的问题,请看Creating the Team Provisioning Profile.

  4. If a team doesn’t appear in the Team pop-up menu, choose “Add an Account” and follow the steps described in Adding Your Apple ID Account in Xcode.

    如果在Team弹出菜单中没有出现团队,选择”Add an Account"并根据 Adding Your Apple ID Account in Xcode中描述的步骤。

 

Creating the Team Provisioning Profile

5、创建团队配置文件

After you select a team, Xcode attempts to create your code signing identity and a development provisioning profile. Xcode creates a specialized development provisioning profile called a team provisioning profile that it manages for you. A team provisioning profile allows an app to be signed and run by all team members on all their devices. If Xcode fails to create the team provisioning profile, a warning and Fix Issue button appear below the Team pop-up menu.

当你选择了一个团队后,Xcode尝试创建你的代码签名标识,以及一个开发配置文件。 Xcode创建一个专门的开发配置文件,叫做team provisioning profile。团队配置文件允许所有的团队成员对应用程序进行签名并在他们全部的设备中运行。如果Xcode创建团队配置文件识别,会再Team弹出菜单的下面显示一个warning和一个Fix Issue按钮。

 

../Art/3_tb_noprovisioningprofile_2x.png

 

To create the team provisioning profile, Xcode performs these steps:

创建团队配置文件,Xcode执行以下步骤:

  1. Requests your development certificate

    请求你的开发者证书。

  2. Registers the iOS device chosen in the Scheme toolbar menu or your Mac

    注册在Scheme toolbar menu(计划工具栏菜单)或你的Mac中注册的iOS设备。

  3. Creates an App ID that matches your app’s bundle ID and enables app services

    创建一个跟应用程序bundle ID相匹配的App ID,并开启应用服务。

  4. Creates a team provisioning profile containing these assets

    创建一个包含这些assets的团队配置文件(team provisioning profile)

  5. Sets your project’s code signing build settings accordingly

    设置你的项目的代码签名构建相应的设置。

Important: If you are a team member for a company account, ask your team agent or admin to register your Mac on your behalf, as described in Registering Team Member Devices. Also, ask the team agent or admin to follow these steps to create the team provisioning profile if it doesn’t already exist. To download the team provisioning profile to your Mac, refresh the provisioning profiles, as described in Refreshing Provisioning Profiles in Xcode, or click the Fix Issue button under the Team pop-up menu.

 重要提示:如果你事一个公司账号的团队成员,请求你的团队代理人或管理者注册以你的名义注册你的Mac,请看 Registering Team Member Devices中所述。同时如果在member center 中没有团队配置文件,也请他照着以下步骤创建一个。 然后把团队配置文件下载到你的Mac电脑,照着 Refreshing Provisioning Profiles in Xcode 中的方法刷新配置文件,或者点击Team弹出菜单下面的Fix Issue方法。

You can assist Xcode and avoid common problems by creating the team provisioning profile now.

你可以现在就创建团队配置文件帮助Xcode并避免常见问题。

To create a team provisioning profile

创建一个团队配置文件:

  1. In the project navigator, select the project and your target to display the project editor.

    在项目导航,选择project 和 你的target, 显示项目编辑器(project editor)。

  2. Click General and, if necessary, click the disclosure triangle next to Identity to reveal the settings.

    点击General,并且如有需要,点击Identity边上的展开三角来展开各种设置。

  3. Verify that your bundle ID is unique by using a unique prefix.

    用一个唯一的前缀来验证你的bundle ID是唯一的。

    Depending on your project’s configuration, Xcode may create either a wildcard App ID or an explicit App ID. Because Xcode uses the bundle ID to register an explicit App ID, the bundle ID also needs to be unique during development. To avoid an App ID registration error, enter a unique bundle ID now, as described in Setting the Bundle ID.

    根据你的项目配置,Xcode可能创建一个通配符(wildcard)App ID 或者是一个 explicit(明确) App ID.  因为Xcode使用bundle ID 来注册一个explicit App ID, 所以在开发过程中bundle ID也需要是唯一的。 为了避免产生一个App ID 注册错误,现在就输入一个唯一的bundle ID,请看Setting the Bundle ID中所述。

  4. For iOS apps, connect an iOS device you want to use for development and choose the device from the Scheme toolbar menu.

    对于iOS应用程序,连接开发需要使用的iOS设备,并从计划工具栏菜单(Scheme toolbar menu)选择设备。

    Xcode requires one or more registered devices in your account before it can create a team provisioning profile. (For Mac apps, Xcode automatically registers the Mac that’s running Xcode.) If you connect an iOS device to your Mac that matches the deployment target, Xcode registers the device for you. If the iOS device isn’t eligible because it doesn’t match the deployment target, upgrade the iOS on the device or change the deployment target, as described in Setting Deployment Info.

     在你的账户中,Xcode会在创建一个团队配置文件前请求一个或多个注册设备。 (对于Mac 应用程序, Xcode 自动注册运行Xcode的Mac。) 如果你连接了一个匹配系统目标的iOS设备,Xcode就为你注册该设备。如果iOS设备不符合条件,那时因为它不匹配系统目标,升级设备的iOS或者调整系统目标,请看 Setting Deployment Info描述。

  5. If necessary, choose your team from the Team pop-up menu.

    如果有必要,从Team弹出菜单中选择团队。 

    For Mac apps, Mac App Store must be selected as the type of signing identity before you can choose a team.

     对于Mac应用程序,Mac应用商店必须先选择签名标识的类型,然后才能选择团队。

  6. If a Fix Issue button appears below the Team pop-up menu, click it.

     如果在Team弹出菜单下面出现了一个Fix Issue按钮,点击它。

    ../Art/3_tb_noprovisioningprofile_2x.png

    Xcode starts performing all the steps needed to create a team provisioning profile for your app. If no warning message appears below the Team pop-up menu, Xcode already created your team provisioning profile.

     Xcodek为你的应用程序开始执行创建一个团队配置文件的所有步骤。 如果在Team弹出菜单下面没有出现warning信息,那就是说Xcode已经创建好团队配置文件。

  7. If dialogs or warnings appear, use the information to correct the problem and click Fix Issue again.

     如果出现对话框或警告,使用出现的信息来更正问题并在此点击Fix Issue。

    After Xcode creates the team provisioning profile, the warning message under the Team pop-up menu disappears.

     当Xcode创建完团队配置文件后,Team弹出菜单下面的警告消息就会消失。

    ../Art/3_tb_team_profile_created_2x.png

 

Setting the Application Category (Mac Only)

6. 设置应用程序类别(仅Mac)

Set the category under which your Mac app will be listed on the Mac App Store. The category you select should match the category you later select in your iTunes Connect app record.

 

To set the application category

 

  1. In the project navigator, select the project and your target to display the project editor.

     

  2. Click General and, if necessary, click the disclosure triangle next to Identity to reveal the settings.

     

  3. Choose the category from the Application Category pop-up menu.

     

    ../Art/3_selectdistributionmethod_2x.png

iOS app categories are set in iTunes Connect only. For more details on app categories, read Best Practices in iTunes Connect Developer Guide.

Setting the Version Number and Build String

7、设置版本号和Build字符串

The version number is a two-period-separated list of positive integers, as in 4.5.2. The first integer represents a major revision, the second a minor revision, and the third a maintenance release. The version number is shown in the store and that version should match the version number you enter later in iTunes Connect. For details on possible values, see CFBundleShortVersionString in Information Property List Key Reference.

版本号是由两个点分隔的正整数,比如4.5.2。 第一个整数表示一个主要版本号,第二个整数是次要版本号,第三个数字是维护版本。版本号在应用商店中显示,版本号应该跟iTunes Connect中的版本号一致。更多可能值的详情,请参见 Information Property List Key Reference 中的CFBundleShortVersionString

The build string represents an iteration (released or unreleased) of the bundle and is also a two-period-separated list of positive integers, as in 1.2.3. For Mac apps, the user can click the version number in the About window to toggle between the version number and the build string. For details on possible values, seeCFBundleVersion in Information Property List Key Reference.

build字符串(buile string)表示一个bundle迭代(发布或未发布), 它也是由两个点分隔的正整数形成,比如1.2.3。对于Mac 应用程序,用户可以在About窗口里点击版本号来切换版本号和build字符串(build string)。 更多可能值详情,请看

 Information Property List Key Reference CFBundleVersion

For iOS apps, update the build string whenever you distribute a new build of your app for testing. iTunes will recognize that the build string changed and properly sync the new iOS app to the device. For how to configure your app for testing, read Beta Testing iOS Apps.

对于iOS应用程序,每次你发布应用程序的一个新版本进行测试时都可以更新build string。iTunes会识别出更新后的build 字符串并正确地把新的iOS应用同步到设备。 关于如何配置测试你的应用程序,请看Beta Testing iOS Apps.

Set the version number and build string in the General pane in the project editor.

可以在项目编辑器(project editor)的General面板查看版本号和build 字符串.

To set the version number and build string

设置版本号和build字符串

  1. In the project navigator, select the project and your target to display the project editor.

    在项目导航,选择项目和你的target,显示项目编辑器(project editor). 

  2. Click General and, if necessary, click the disclosure triangle next to Identity to reveal the settings.

     点击General,如果需要,点击Identity边上的展开三角来展开各种设置。

  3. Enter the version number in the Version field, and enter the build string in the Build field.

    在Version字段输入版本号,在Build字段输入build字符串。 

    ../Art/3_tb_team_profile_created_2x.png

Setting Deployment Info

四、设置系统信息

The default deployment settings are sufficient for development, but it’s best to review these settings before you distribute your app. Some settings must match values you enter in iTunes Connect later. For iOS apps, the deployment settings appear as shown here:

默认的系统设置对于开发已经足够,不过最好还是在发布应用程序之前在检查一下这些设置。 一些设置必须跟你稍后在iTunes Connect中输入的内容相一致。 以下是iOS应用程序系统设置:

../Art/3_deployment_info_2x.png

Setting the Deployment Target

1、设置系统目标

The deployment target setting specifies the lowest operating system version that your app can run on. For example, the lowest available setting for iPad apps is iOS 4.3.

系统目标设置指明了应用程序可以运行的最低操作系统版本。 比如,iPad应用程序最低可能的设置是iOS 4.3。

There are several strategies for choosing the deployment target when developing your app. Each version of iOS or OS X includes features and capabilities not present in earlier versions. As new versions are published, some users may upgrade immediately, while other users may wait before moving to the latest version. You can target the latest version, taking full advantage of all the new features but limiting the app to only users running the latest version. Or you can target an earlier version, making your app available to more users but limiting the features you can use in the app. Another approach is to target an earlier version but use weak linking to determine at runtime whether later version features are available before using them.

当你开发应用程序时,如何选择系统目标有几种方法。 每种iOS或OS X的版本都包含了一些以前的版本没有的特性和功能。 当新版本发布时,有些用户可能立即进行更新,然而其它客户可能会一直不更新到最新版本。 你可以选择适配最新的iOS版本,完全使用所有最新的功能,但是用户群就只能固定在使用最新版本的用户。或者你可以选择一个早期版本,让你的应用程序可以有更多的用户群,但是你的应用程序却只能使用限制的功能。另一个方法是使用一个早期的版本但在使用前用弱链接来确定运行时最近版本的功能是否能用。

For details on weak linking, read Weak Linking and Apple Frameworks in SDK Compatibility Guide.

关于弱连接的详情,请看SDK Compatibility Guide 中的 Weak Linking and Apple Frameworks

To set the target version

如何设置目标版本

  1. In the project navigator, select the project and your target to display the project editor.

     在项目导航,选择项目和你的target来显示项目编辑器(project editor)。

  2. Click General and, if necessary, click the disclosure triangle next to Deployment Info to reveal the settings.

     点击General,如果需要点击Deloyment Info展开各种设置。

  3. Choose the version you want to target from the Deployment Target pop-up menu.

     从Deployment Target的弹出菜单中选择你想要的目标版本。

    ../Art/3_deployment_target_2x.png

Xcode sets the Minimum System Version key in the app’s information property list to the deployment target you choose. When you publish your app to the store, it uses this property value to indicate which versions your app supports.

Xcode在应用程序Info.plist中的Minimum System Version中显示了你选择的最低系统版本。当你发布应用到商店时,它用该特性值来指示你的应用程序支持哪些版本。

Note: The SDK version, not the deployment target, determines which features you can use in an app. If the SDK you’re using to build the app is more recent than the app’s deployment target, Xcode displays build warnings when it detects that your app is using a feature that’s unavailable in the deployment target.

注意:是SDK版本,而不是系统目标,决定你的应用程序可是使用功能。如果你用来构建应用程序的SDK版本比应用程序的deloyment target版本更高,当Xcode检测到你的应用程序使用了不符合你的deployment target的功能时,它会显示构建警告。

Ensure that the symbols you use are available in the app’s runtime environment. To check for their availability, use the techniques described in SDK Compatibility Guide.

确保你使用的符号(symbols)在应用程序的运行环境中都是可用的。检查它们是否可用,使用SDK Compatibility Guide中描述的技术。

 

Setting the Target Devices (iOS Only)

设置目标设备(仅iOS)

The Devices setting identifies the type of devices you want an iOS app to run on. There are two device types: iPhone and iPad. The iPhone type includes iPhone and iPod touch devices. The iPad type includes all iPad and iPad mini devices.

Devices 设置定义了一个iOS应用程序运行的设备类型。 目前有两种设备类型:iPhone 和 iPad。 iPhone类型包括了iPhone 和 iPod touch 设备。 iPad类型包括了所有iPad 和 iPad mini设备。

To set the target devices

设置目标设备:

  1. In the project navigator, select the project and your target to display the project editor.

     在项目导航,选择项目和你的target,显示项目编辑器(project editor)。

  2. Click General and, if necessary, click the disclosure triangle next to Deployment Info to reveal the settings.

     点击General,如果需要点击Deployment Info边上的展开三角来展开各种设置。

  3. From the Devices pop-up menu, choose iPhone, iPad, or Universal (to target both families).

     从Devices弹出菜单,选择iPhone,iPad或者 Universal(两种类型都选择)。

    ../Art/3_target_devices_setting_2x.png

For more information on configuring your app for iPhone, iPad, or both device families, see Advanced App Tricks in App Programming Guide for iOS.

更多关于为应用程序配置iPhone , iPad, 或者两种设备都选的信息,请看App Programming Guide for iOS中的 Advanced App Tricks 。

Adding App Icons and a Launch Screen File

五、添加应用图标和一个启动文件

App icons and the launch screen file are stored in the app bundle, not uploaded as separate assets to iTunes Connect. The operating system uses these images and the launch screen file (a .xib file) in various locations on a device to represent your app. In general, artwork displayed by the operating system resides in the bundle, and artwork displayed by iTunes is uploaded to iTunes Connect. Your app needs an app icon to represent it and pass validation tests.

应用图标和启动文件存储在应用程序的bundle中,不是单独作为assets上传到iTunes Connect。 操作系统在设备的不同地方都使用这些图片和启动文件(一个.xib文件),它们可以用来表示你的应用程序。 一般情况下,操作系统需要显示的图片(artwork)存在bundle中,而iTunes需要显示的artwork则被上传到iTunes Connect。 你需要一个应用图标来表示它并通过认证测试。

You use an asset catalog that manages the app icons for you or maintain individual image files yourself. If you create a new project, asset catalogs are used by default to store app icons and a launch screen file is used as a splash screen. For iOS 7 deployment targets, you can supply both a launch screen file and launch images. In iOS 8, the launch screen file is used, and in iOS 7, the launch images are used. If you have an older project, you can migrate from managing individual icon image files to an asset catalog. You can also add a launch screen file to an older Xcode project.

你可以使用一个asset catalog来管理你的所有应用图标,或者还是保留独立的图片文件。如果你创建了一个新的项目,项目默认使用asset catalogs 来存储应用图标,一个启动文件作为初始画面。对于iOS 7 系统目标, 你可以同时提供一个启动文件和启动图片。 在iOS 8中,使用启动文件,在iOS 7中,使用启动图片。如果你有一个老的项目,你可以把独立的图标文件移动到一个asset catalog中。 你还可以给老Xcode项目添加一个启动文件。

If you prefer to manage your assets as individual image files, read Setting Individual App Icon and Launch Image Files. If you want to migrate to an asset catalog, read Migrating Your Images to an Asset Catalog. To learn more about creating and managing asset catalogs, read Asset Catalog Help.

如果你更喜欢管理独立的图片文件,请看 Setting Individual App Icon and Launch Image Files. 如果你想把图片加入一个asset catalog, 请看 Migrating Your Images to an Asset Catalog.

Preparing Your Artwork

1、准备你的Artwork

For all artwork, keep the file size as small as possible for a positive purchase experience for your users.

为了给用户提供一个积极的购买体验,让所有的artwork文件大小尽可能的小。

For iOS apps, see Icon and Image Sizes in iOS Human Interface Guidelines for the sizes of all required app icons, launch images, and other icons.

对于iOS应用程序,参见 iOS Human Interface Guidelines 中的Icon and Image Sizes ,查看所有需要的应用图标,启动图片以及其它图标的尺寸。

In iOS 7, a launch image matching the device resolution appears as soon as the user taps your app icon. Use screenshots to create your app’s launch images. To take advantage of Retina displays, provide high-resolution images for each device you support. For guidance on creating launch images, read Launch Images.

在iOS 7中,当用户点击了你的应用图标后,一张匹配设备分辨率的启动出现就会出现在屏幕上。 使用屏幕快照来创建应用程序的启动图片。 为了体现Retina显示屏的优势,对每个你所支持的设备提供高分辨率图片。关于创建启动图片的指导,请看 Launch Images

For the required Mac app icons, see Creating Great Icons for Any Resolution in OS X Human Interface Guidelines. This table includes icon sizes that may be used on the Mac App Store. To create your app icon files, read Provide High-Resolution Versions of All App Graphics Resources in High Resolution Guidelines for OS X.

对于需要的Mac 应用图标,查看Creating Great Icons for Any Resolution in OS X Human Interface Guidelines. 这个表格包含了可能用于Mac 应用商店的图标尺寸。 要想为你的应用程序创建图标文件,请看High Resolution Guidelines for OS X 中的 Provide High-Resolution Versions of All App Graphics Resources。

For the specification of screenshots and other artwork that you upload later using iTunes Connect, read iTunes Connect App Properties in iTunes Connect Developer Guide.

关于你以后需要上传到iTunes Connect的屏幕快照和其它artwork的规则,请看 iTunes Connect Developer Guide中的 iTunes Connect App Properties 。

Adding App Icons to an Asset Catalog

2、把应用图标加入Asset Catalog

Versions of your app icons are organized into image sets in an asset catalog. Xcode automatically creates image sets for the app’s target device—for example, both iPhone and iPad image sets appear if your iOS app’s target is universal.

你的应用程序的所有图标都被放进一个asset catalog中的图片集中。 Xcode会为应用程序的目标设备自动创建图片集---比如,如果iOS应用目标是iPhone 和 iPad都支持,则Xcode自动为iPhone 和iPad都创建图片集。

To add an app icon to an asset catalog

把一张应用图标加入一个asset catalog

  1. In the project navigator, select the project and your target to display the project editor.

     在项目导航,选择项目和你的target, 显示项目编辑器(project editor)。

  2. In the “App Icons and Launch Images” section of the General pane, click the arrow button to the right of the App Icons Source pop-up menu.

     在General面板的“App Icons and Launch Images”中,点击位于App Icons Souce弹出菜单右边的小箭头。

    ../Art/3_app_icon_arrow_2x.png
  3. In the Finder, drag an app icon to the image well that matches its resolution in the project navigator.

     在Finder中,把应用图标拖入项目导航的图片井中,拖入的图标要符合它的分辨率。

    ../Art/3_add_app_icon_to_asset_catalog_2x.png

Creating a Launch Screen File

3. 创建一个启动文件

The launch screen file is displayed as a splash screen while your app is launching. It’s a single, atomic .xib file that uses size classes to support different device resolutions. It contains basic UIKit views, such as UIImageView and UILabel objects, and uses Auto Layout constraints. Xcode adds a default launch screen file, called LaunchScreen.xib, to your project.

当你的应用程序启动时,启动文件是第一个屏幕。 它是一个单一的,原子.xib文件,它使用各种尺寸类来支持不同的设备分辨率。 它包含了基础UIKit视图,比如UIImageView和UILabel对象等,并且还使用了自动布局常量。 Xcode默认为你的项目添加了一个名叫LaunchScreen.xib的启动文件。

Follow these guidelines when creating a launch screen file:

当你创建一个启动文件时,请跟随以下步骤:

  • Use only UIKit classes.

     只用UIKit类。

  • Use a single root view that is a UIView or UIViewController object.

     使用一个单独的根视图,一个UIView或UIViewController对象。

  • Don’t make any connections to your code (don’t add actions or outlets).

     不要跟你的代码有任何连接(不要添加任何的动作或接口)。

  • Don’t add UIWebView objects.

     不要添加UIWebView对象。

  • Don’t use any custom classes.

     不要使用任何的自定义类。

  • Don’t use runtime attributes.

     不要使用运行时属性。

You can add a launch screen file to an older Xcode project.

你可以给老项目添加一个启动文件。

To create a launch screen file for an existing project

给一个已经存在的项目创建一个启动文件。

  1. Choose File > New > File.

     选择File > New >File.

  2. Under iOS, select User Interface.

     在iOS下,选择Uset Interface。

  3. Click Launch Screen and click Next.

     点击Launch Screen 并点击Next。

    ../Art/3_create_launch_screen_file_2x.png
  4. Enter a filename in the Save As text field, and click Create.

     输入文件名,并点击Create.

To set the launch screen file

 设置启动文件:

  1. If necessary, open the “App Icons and Launch Images” section of the General pane.

     如果需要,打开General 面板的App Icons and Launch Images.

  2. From the Launch Screen File pop-up menu, choose a launch screen file.

     从Launch Screen File 弹出菜单中,选择一个启动文件。

Adding Launch Images and Capturing Screenshots

4. 添加启动图片和捕捉屏幕快照。

For iOS 7 deployment targets, add an asset catalog for launch images, described in Migrating Your Images to an Asset Catalog. Capture screenshots to create the launch images and add them to the asset catalog, similar to adding app icons to an asset catalog, described in Adding App Icons to an Asset Catalog.

对于iOS 7 系统目标,为启动图片添加一个asset catalog, 请看Migrating Your Images to an Asset Catalog. 捕捉屏幕快照来创建启动图片并把它们加入asset catalog. 添加应用图标到asset catalog,跟添加启动图片很相似,请看 Adding App Icons to an Asset Catalog.

Follow these steps to capture a screenshot of your iOS app while your device is connected to your Mac. Although the screenshot includes the status bar as it looks when the screenshot is captured, iOS replaces it with the current status bar when your app launches.

当设备连接到Mac时,可以跟随以下这些步骤来步骤一张屏幕快照。 尽管捕捉的屏幕快照带有状态栏,但是iOS会在应用程序启动时用当前的状态栏替换它。

To capture a screenshot on your iOS app

为iOS应用程序截屏:

  1. Connect the iOS device to your Mac.

    把iOS设备连接到Mac。 

  2. Choose Window > Devices, and select the device under Devices.

     选择Window > Devices ,并选择Devices下面的设备。

  3. In the Device Information section, click Take Screenshot.

     在Device Information section,点击Take Screenshot。

    ../Art/3_take_screenshot_2x.png

    The screenshot appears on your desktop.

Setting Individual App Icon and Launch Image Files

5. 设置单独的应用图标和启动图片文件

If you don’t want to use an asset catalog, choose “Don’t use asset catalogs” from either the App Icons Source or Launch Images Source pop-up menu in the “App Icons and Launch Images” section of the General pane. If a Use Asset Catalog button appears, you are not using an asset catalog.

如果你不想用一个asset catalog, 从App Icons Source 或 Launch Images Source弹出菜单选择“Don't use asset catalogs", 它们位于General面板的”App Icons and Launch Images“区。 如果出现了”Use Asset Catalog“字样,就说明你已经没有使用asset catalog.

Migrating Your Images to an Asset Catalog

6. 把你的图片移入一个asset catalog

If you have an older project, you can migrate your image files to an asset catalog that manages your app icons and launch images for you. Xcode moves the image files from the tables to the new asset catalog. You create a separate asset catalog for app icons and launch images, but the steps are identical.

如果你有一个老项目,你可以把图片文件移入一个asset catalog, 它能为你管理应用图标和启动图片。 Xcode把图片从表格(tables)移入新的asset catalog. 你需要单独为应用图标和启动图片撞见一个asset catalog, 它们的创建步骤是一样的。

To migrate to an asset catalog

把图片移入一个asset catalog

  1. In the project navigator, select the project and your target to display the project editor.

    在项目导航,选择项目和你的target ,显示项目编辑器(project editor)。 

  2. Click General and, if necessary, click the disclosure triangle next to “App Icons and Launch Images.”

     点击General,如果需要点击”App Icons and Launch Images“边上的展开三角。

  3. Click the Use Asset Catalog button next to either App Icons Source or Launch Images Source.

     点击App Icons Source 或 Launch Images Source边上的Use Asset Catalog 按钮。

    ../Art/3_use_asset_catalog_2x.png
  4. In the dialog that appears, choose either Images or New Asset Catalog from the pop-up menu, and click Migrate.

     在出现的对话框中,选择Images 或者 New Asset Catalog,然后点击Migrate

    ../Art/3_migrate_to_catalog_2x.png

To view the asset catalog, click the arrow button to the right of the App Icons Source or Launch Images Source pop-up menu.

要想查看asset catalog, 点击 App Icons Source 或 Launch Images Source弹出菜单边上的箭头按钮。

Setting the Copyright Key (Mac Only)

7、设置版权键(仅Mac)

Make sure that your information property list file contains a valid value for the Copyright key. For details on possible values, see NSHumanReadableCopyright inInformation Property List Key Reference.

To edit the copyright key in the information property list

  1. In Xcode, select the project in the project navigator.

     

  2. Click the disclosure triangle next to the ProjectName folder to reveal its contents.

     

  3. Click the disclosure triangle next to the Supporting Files subfolder to reveal its contents.

     

  4. Select the ProjectName-Info.plist file.

     

    The information property list is displayed to the right in a property list editor.

     

    ../Art/3_copyright_key_2x.png
  5. Double-click in the Value column and in the row of the Copyright key.

     

  6. Enter a new value for the key.

     

For how to edit other cells in a property list, refer to Property List Editor Help.

Verifying Your Build Settings

六、验证你的Build Setting

If you changed the default build settings, verify some of the settings before submitting your app to the store. You do this in the Build Settings pane of the project editor.

如果你更改了默认的Build Setting,在把应用程序提交到商店之前验证一些设置。 你可以在项目编辑器的Build Setting面板完成这个。

To edit a build setting

如何编辑一个build setting

  1. In the project editor, select the project or target whose build setting you want to edit.

     在项目编辑器,选择项目或target来编辑build setting。

  2. At the top of the project editor, click Build Settings.

     在项目编辑器的顶部,点击Build Setting。

    ../Art/3_edit_build_settings_2x.png
  3. Locate the build setting in the left column, or enter the name of the build setting in the search field in the upper-right corner.

    从左列找到你要编辑的build setting,或者在右上角的搜索字段输入构建设置的名称。 

  4. If some build settings don’t appear, click All.

     如果一些build setting 没有出现,点击All。

  5. Set the value for the build setting in the right column.

     在右列设置build setting的值

Setting Architectures for iOS Apps

1. 为iOS应用程序设置Architectures

The Architectures build setting identifies the architectures for which your app is built. An iOS device uses a set of architectures, which include armv7 and arm64. You have two options for specifying the value of this setting:

Architectures 构建设置标识了应用程序构建哪个架构。 一个iOS设备使用了一系列的架构,包括armv7 和 arm64等. 该设置有两个选项。

  • Standard. Produces an app binary with a common architecture, compatible with all supported iOS devices. This option generates the smallest app, but it may not be optimized to run at the best possible speed for all devices.

     标准架构。  产生一个通用架构的二进制应用程序,它能适配所有支持的iOS设备。 该选项生成最小的应用程序, 但是它可能不能优化到能在所有的设备商都以最大可能的速度运行。

  • Other. Produces an app binary for a specified set of architectures.

     其它架构。产生一个指定架构集的二进制应用程序。

If you select Other from the Architectures build-setting value list, click the Add button (+) to enter the custom iOS-device architecture names you support.

你在此选择了Other选项,点击(+)来输入你所支持的自定义iOS设备架构名称。

Important: The store rejects a binary that supports only armv7s. If armv7s is included in the Valid Architectures list, armv7 must also be included.

 重要提示:应用商店不接受只支持armv7s的二进制应用。 如果armv7s被加入了有效的架构列表,那么armv7也必须被加入。

Setting the Base SDK

2. 设置Base SDK

The Base SDK version number must be greater than or equal to the software version number on your development device; otherwise, Xcode can’t initiate a debugging session with the device. Set the Base SDK for your project and targets to the latest operating system, which is the default value. The Base SDK property is located in the Architectures area in the Build Settings pane. For iOS apps, set Base SDK to Latest iOS. For Mac apps, set Base SDK to Latest OS X. If you select another value, download and install the latest SDK version that’s greater than or equal to your device software version.

Base SDK版本号必须大于或等于你的开发设备上的软件版本号;否则,Xcode无法用设备初始化一个调试会话。为项目设置Base SDK,把它设置为最新的操作系统,它是默认值。 Base SDK 特性位于Build Setting面板的Architectures 区。 对于iOS应用程序,把Base SDK设置为最新的iOS操作系统。 对于Mac 应用程序,则把它设为最新的OS X系统。 如果你设置了另外的值,下载并安装最新的SDK,它必须大于或等于设备软件版本号。

To go to the Architectures area, select the project or target and click Build Settings. The Architectures area appears first in the Build Settings pane.

要想进入Architectures 区,选择项目或者target并点击Build Settings. Architechtures区首先出现在Build Setting面板。

../Art/3_base_sdk_2x.png

Setting the Debug Information Format

3、设置Debug Information Format

Set the Debug Information Format build setting to “DWARF with dSYM File.” This is required to symbolicate crash reports, as described in Analyzing Crash Reports.

把Debug Information Format设置为“DWARF with dSYM File.” 正如Analyzing Crash Reports中所述,这是必要的symbolicate 崩溃报告。

../Art/3_debug_info_format_2x.png

Recap

总结

In this chapter, you learned how to configure your Xcode project from a template, set the app’s identity information, and create a team provisioning profile for development. During development, refer to this chapter as needed. Later, use this chapter as a checklist for the settings that are required by the App Store and Mac App Store.

在本章,我们学习了如果从一个模板配置Xcode项目, 设置应用程序的标识信息,并为开发创建看一个团队配置文件。 在开发过程中

 

posted on 2015-04-18 17:49  cainiaozhang  阅读(973)  评论(2编辑  收藏  举报