IOS开发之证书
证书有什么作用就不再说明了.
当你的App要在真机调试或发布时,需要一个Provisioning Profile.具体位置在: Build Settings -> Code Signing: Provisioning Profile
Provisioning Profile
分为 开发版本 和 发布版本
1.开发版本一般选择: iOS App Development 2.发布版本一般选择: App Store
iOS App Development内容
- App ID
- 证书Certificates
- 设备devices
App Stroe内容
- App ID
- 证书Certificates
App ID 说明
就是Product ID,用于标识一个或一组App.通常来说,如果是 开发版本,Boundle Identifier只需用*来表示.如果是 发布版本,那么Boundle Identifier必须与App ID一致
一个App ID 是由两部分组成的,一部分是我们自己输入的,一部分是Apple给我们强制添加的(Team ID).我们自己输入的可以分为两种:
- 精确匹配 Explicit App ID : 一个App ID只能配置与之完成一致的Boundle Identifier.在发布App时,必须使用这一种
- 模糊匹配 Wildcard App ID : 可以与多个Boundle Identifier匹配,用”*“来表示任何字符.一般开发模式时使用这一种,方便
设备Devices
真机测试时有用,比如你想使用某一台IOS的手机来调试你的APP,就需要把这台手机的UUID添加进来.如果已经有了一个 Wildcard App ID 的 Provisioning Profile,那么你需要修改它的设备信息.如果还没有,在创建 Provisioning Profile时,需要选择指定的设备
证书Certificates
证书分两种,一种是 开发版本,一种是 发布版本
证书说明
一般来说,一个开发者帐户下的证书,每个类型只需要一个证书,比如你创建一个 iOS App Development 类型的证书后,在创建证书的页面就变成:
可以看到,红框是不可选的.
创建证书的步骤
To manually generate a Certificate, you need a Certificate Signing Request (CSR) file from your Mac. To create a CSR file, follow the instructions below to create one using Keychain Access.
Create a CSR file.
In the Applications folder on your Mac, open the Utilities folder and launch Keychain Access.
Within the Keychain Access drop down menu, select Keychain Access > Certificate Assistant > Request a Certificate from a Certificate Authority.
In the Certificate Information window, enter the following information:
In the User Email Address field, enter your email address.
In the Common Name field, create a name for your private key (e.g., John Doe Dev Key).
The CA Email Address field should be left empty.
In the "Request is" group, select the "Saved to disk" option.
Click Continue within Keychain Access to complete the CSR generating process.
这是Apple官方的说明:
- 创建一个CSR文件
使用 Keychain Access 来创建
从 证书助理 中选择 从证书颁发机构请求证书
输入邮箱,名称,将其保存到本地.(扩展名为 .certSigningRequest)之后再将其上传到Apple.就会生成一个证书了.
各种证书的作用
开发时使用证书
- iOS App Development: 用于开发调试的数字证书(只能创建一个)
- Apple Push Notification service SSL(Sandbox): APNS,沙盒调试,当需要使用远程通知时,创建此证书,使用此证书时,App ID必须是精确匹配的(每个App都需各自创建一个)
产品证书
- App Store and Ad Hoc: 发布App时使用(只能创建一个)
- Apple Push Notification service SSL(Production):远程通知APNS使用