Version: 2022.1
使用 Unity 开发者控制面板 (Developer Dashboard) 对 Unity Cloud Build 进行 Plastic 配置
Set up a Gymfile in Unity Cloud Build

发布到 iOS

Cloud Build helps you automate the process of building your Unity Project for iOS devices.

This article describes the prerequisites necessary to build your Project for iOS and create the supporting components to configure Cloud Build. Topics covered include:

  • 加入 Apple Developer Program
  • Creating an iOS certificate and p12 file
  • 将设备添加到配置文件
  • 创建资源调配配置文件
  • 配置应用程序以发布到 iOS

加入 Apple Developer Program

To develop iOS apps, you must be a member of the Apple Developer Program. This lets you build, test, and eventually release your apps in the Apple App Store.

注意:必须具有基于 Intel 并运行 OS X Yosemite (v10.10) 或更高版本的 Mac 系统才能开发和分发 iOS 应用程序和 Mac 应用程序。

After you sign in to the Apple Developer program portal, you’ll see a list labeled Program Resources on the left. Click Certificates, IDs & Profiles to manage the certificates, identifiers, profiles, and devices you need to develop and distribute apps.

Provisioning profiles

A provisioning profile ties developers and devices to an authorized Development Team and enables you to use a device for testing. You must install a Development Provisioning Profile on each device you plan to run your application code.

Each Development Provisioning Profile contains a set of Development Certificates, Unique Device Identifiers (UDID), and an App ID.

要使用设备进行测试,还必须在配置文件中包括开发证书。单个设备可以包含多个资源调配配置文件。

资源调配配置文件的组成部分

Certificates determine whether your app is development-only or a release candidate for the App Store. You should use an Ad Hoc Production Certificate so that you can test all the features of your game (such as GameCenter).

Identifiers are the unique IDs that identify your project. For basic projects, or if this is your first iOS project, you should make an App ID. This is often the same as your Unity3D Project’s Bundle ID.

提示:有关签名标识和证书的更多信息,请参阅 Apple 开发者网站上的维护签名身份和证书 (Maintaining Your Signing Identities and Certificates)

Devices are the hardware—such as an iPhone, iPad, or iPod—on which you plan to test your project. You must retrieve the UDID for each device on which you plan to test your game. You then add the UDID to the Devices section in the iOS developer portal.

Note: Each year, you can register a fixed number of devices. The maximum number of devices you can register is 100 devices per product family per membership year. For more information see, Registering Devices Using Your Developer Account in the Maintaining Identifiers, Devices, and Profiles topic on the Apple developer website.

创建 iOS 证书和 p12 文件

创建证书时,必须决定是创建开发证书(仅用于测试),还是生产证书(用于通过 App Store 分发应用程序)。

Tip: Create a Production Certificate. While either certificate type works for development, Production Certificates make it easier to release your app to the App Store.

创建证书

1.登录 Apple Developer Program。 1.单击 Member Center > Certificates > Identifiers & Profiles > Certificates。 1.在左栏的 Certificates 下,单击 All。 2. In the screen labeled What type of certificate do you need, choose the type of certificate to generate. Typically, if you’re starting, you should to pick an App Store and Ad Hoc production certificate. 3. Use the Keychain Access program on your Mac (open your Finder and find it in Applications/Utilities) to generate a Certificate Signing Request (CSR) file. Follow the instructions in the iOS portal to complete this step. Make a note of where you save the CSR file. 4. In the Generate your certificate screen, upload your CSR file (which might have the extension .certSigningRequest). Click the Choose File button and select your CSR file, and then click the Generate button. 5. To download your certificate to your Mac, click the Download button on the Your Certificate is Ready screen. Store this file somewhere safe and back it up.

要将证书添加到密钥链,请找到证书文件并双击它。这将打开 Keychain Access 程序。如果看到弹出消息 “Do you want to add the certificate to a keychain?”,请选择登录并单击 Add 按钮。

导出 p12 文件

To create apps using Unity Cloud Build, you must convert your certificate file to a p12 file. A p12 file is a file that contains your private key and certificate and is used to sign your code. Typically, if you develop a project in native Xcode, this process is handled behind the scenes.

要生成 p12 文件:

1.在 Mac 上,打开 Finder,然后在 Applications/Utilities 中打开 Keychain Access 程序。 1. In the left-hand column, under keychains, verify that Login is selected. 1. In the left-hand column, under Category, verify that My Certificates is selected. In the main Keychain Access pane, select your certificate.

**Note**: Typically, your certificate is located under **My Certificates**. If it is not there, check under **Certificates**.

1.从 File menu 中,选择 File > Export Items,或右键单击再选择 Export。 1.从 File Format 下拉菜单中选择 Personal Information Exchange (.p12)。

**注意**:如果未选择 **Category** 下的 **Keychains and My Certificates** 下的 **Login**,则 p12 选项将灰显。
  1. Ceate a password for the p12 file.

    Note: Record the password somewhere safe as you must supply it when setting up iOS builds on Unity Cloud Build.

添加设备

For development purposes, Apple requires the UDID for each device on which you intend to install your app. Once your app is accepted into the App Store, anyone can download and install it; provided they have the correct version of iOS and meet any other requirements.

查找您的 UDID

You can use iTunes to retrieve the UDID of your device. For a walkthrough of the retrieval process, see WhatsMyUDID.com.

基本步骤为:

1.在 Mac 上打开 iTunes。 2. Connect the device (iPhone, iPad, etc) to the computer. 3. In iTunes, select the device. 4. You should see a screen with the device name, capacity, and other details about the device. To display the UDID, click the Serial # field. 5. Copy and paste the UDID into a document where you can retrieve it later. 6. Close iTunes and disconnect your device.

在 Apple Developer Portal 中添加 UDID

To add your device UDID(s) to the Apple Developer Portal:

  1. Click the All section under Devices in the left column of the Apple Developer Portal. 1.要添加新的 UDID,单击右上角的 Add 按钮 (+)。 1.为设备指定一个便于识别的名称,并将从 iTunes 获得的 UDID 复制并粘贴到 UDID 字段。 1.单击 Continue

对每个设备重复以上步骤。

创建 App ID

Now that you’ve created your iOS Certificate, you can create an App ID:

1.在 Apple Developer Portal 的左栏中,单击 App ID。 1.在 Register iOS App IDs 面板的右上角,单击 Add 按钮 (+)。 1.在 Registering an App ID 面板中,输入以下信息: 1.App ID Description:应用程序的名称(不含任何特殊字符)。 1. App ID Suffix: If you intend to incorporate specific services such as Game Center or In-App Purchases, create an Explicit ID. If you don’t need these services, then create a Wildcard App ID. A Wildcard App ID lets you re-use the App ID for multiple projects. 1. App Services: Optional. Indicate whether you plan to use any of the Apple App Services.

有关注册 App ID 的更多信息,请参阅[维护标识符、设备和配置文件 (Maintaining Identifiers, Devices, and Profiles)](https://help.apple.com/xcode/mac/current/#/dev8b4250b57)。

1.单击 Continue 按钮。 1.在 Confirm your App ID 页面上,检查您提供的信息,然后单击 Submit 按钮。

创建资源调配配置文件

下一步是生成 .mobileprovision 文件。.mobileprovision 文件包含您的 p12 证书和 App ID 并指出了应用程序测试设备的 UDID。

1.在 Apple Developer Portal 中,单击 Certificates, IDs & Profiles。 1.在 Apple Developer Portal 的左栏中,选择 Provisioning Profiles 下的 All。 1.要添加新的资源调配配置文件,单击右上角的 Add 按钮 (+)。 1. Under Development, select the type of provisioning profile to create and click Continue. Note: If you’re just getting started, you should use a Distribution > Ad Hoc certificate, as this lets you build your game and test it on devices. 2. Select the App ID to use for development, and click the Continue button. 3. Select one or more development certificates, and click the Continue button. 4. Select one or more devices, and click the Continue button. 5. Enter a profile name, and click the Generate button. 6. Click Done.

将生成的 .mobileprovision 文件下载到台式计算机。

配置应用程序以发布到 iOS

要配置 iOS Cloud Build,需要以下几项:

  • 您的资源调配配置文件 (.mobileprovision)
  • 您的 .p12 文件
  • The password for your .p12 file

对于基本的 iOS 使用情况,此过程应该已经足够。对于包含 Xcode framework 的项目,必须执行一些额外的配置。

使用 Xcode Framework

To add Xcode frameworks manually, use the Xcode Manipulation API. The API lets you manage external Xcode frameworks.

有关采用此 API 的 Unity 项目示例,请参阅 BitBucket 上的 UpdateXcodeProject 示例项目。您可以使用该示例进行实验和学习。

该示例项目的插件之一是外部 Xcode 项目操作 DLL。此 DLL 是 Unity Bitbucket 代码仓库中提供的源代码的编译产品。添加 Xcode 项目操作功能的首选方法是将 C# 源代码文件复制到项目中的 Assets/Editor 文件夹。

You can use the Xcode Manipulation API in the following ways:

  • 使用内置的 Unity PostProcessBuildAttribute(在 Unity Cloud Build 导出后方法运行之前执行它)。
  • 使用 Unity Cloud Build 导出后方法(需要访问高级设置)。
使用 Unity 开发者控制面板 (Developer Dashboard) 对 Unity Cloud Build 进行 Plastic 配置
Set up a Gymfile in Unity Cloud Build