iPhone开发入门:设备上运行程序
注册iPhoneDeveloperProgram
要在设备上运行自己的程序,需要在「iPhoneDeveloperProgram」上注册。首先登录iPhoneDevCenter。
iPhoneDevCenter
点击上图右侧「iPhoneDeveloperProgram」的「Applynow」进入注册画面。在之后的页面中点击「LearnMore」→「ApplyNow」,并登录。

注册页面
登录之后,选择是以个人名义注册(Individual),还是以企业/团体名义注册(Company/Organization),并确认金额和契约。完成注册流程后,过上几天会以邮件的形式通知你接下来的流程,按照要求处理就可以了。
正事完成注册之前,你可以下载最新的iPhoneSDK,更新手头iPhone或iPodtouch的固件版本。
启动程序的准备
在iPhoneDeveloperProgram上注册后,就可以按照以下顺序启动我们的应用程序了。
连接Xcode
将iPhone或者iPodtouch设备与Xcode连接。平常,会经常用iTunes连接设备,这回使用的是Xcode。打开Xcode菜单中的「窗口」→「组织者(organizer)」。在「DEVICES」中会显示接续设备的信息,如下图:

organizer
在organizer表示的信息中,「Identifier」表示的40位的「DeviceID」是需要确认的。
生成证明
从应用程序点击「utility」→「Keychainaccess」。

然后点击「Keychainaccess」→「证明助手」→「发行证明书...」。

其中在「用户的邮箱地址」中填写注册AppleID时的地址,并在CommonName中输入英文的名字。最后选择「保存到硬盘」和「指定对称键情报」后点击「下一步」。

适当选择文件保存的位置。

对称键情报中,确认键的大小为「2048位」,算法是「RSA」后点击「下一步」。

过上一会儿,出现结束画面。刚才保存的文件可以用来请求证明书。
创建和下载配置文件
点击iPhoneDevCenter右边的「ProgramPortal」。

利用ProgramPortal可以设置iPhone或者iPodtouch设备中的应用程序。有简单的向导,使用起来很方便。
注册证明书
如下图,点击左边的「Certificates」可以注册刚才做好的证明书。

点击「RequestCertificate」,在下面的画面中选择请求证明书的文件,最后点击「Submit」。

提交之后被添加到表格中,之后点击「Approve」等待。

之后,表格中显示「Download」按钮,点击它下载证明书。

同时不要忘了下载表格下面的「WWDRintermediatecertificate」。之后分别双击这两个下载的文件,在「提交证明书」对话框中选择OK。这之后就可以在Keychain的「证明书」一项中确认添加的证明书了。

设备注册
接下来注册iPhone或者iPodtouch。选择「Devices」的右上角的「AddDevice」。

在「DeviceName」中输入任意的设备名称。在「DeviceID」中输入刚才Xcode中确认的值后就OK了。

生成AppID
接下来点击「AppIDs」,来生成AppID。

在「AppIDName」中输入任意的名字,在右边的「AppID」中输入“*”。利用AppID将应用程序按不同的组管理起来。如果你输入的「BundleIdentifier」与应用程序中包含的「BundleIdentifier」不一致的话,程序是不会启动的。它主要是为了方便多人开发的项目,对于个人而言没有什么必要。所以这里将AppID写作「*」就是说含有任何BundleIdentifier的程序等可以运行。
最后点击Submit,就完成了注册。

创建ProvisioningProfile
最后来创建ProvisioningProfile。选择「Provisioning」点击右上角的「AddProfile」。

在「ProfileName」中输入任意名称。「Certificates」「AppID」「Devices」选择刚才设置好的,随后点击Submit创建ProvisioningProfile。

等待一会儿,表格中「Download」显示出来。点击它下载ProvisioningProfile文件。
安装Provisioning
打开应用程序程序的Xcode项目。由菜单打开「窗口」→「organizer」,拖动刚才创建的Provisioning文件到Provisioning项目中。

项目设定
接下来,使用安装好的Provisioning来设定应用程序。点击菜单的「项目」→「项目设定」。

点击「编译」。

「CodeSigning」中的「代码署名ID」是「AnyiPhoneOSDevice」与「iPhoneDeveloper」的组合。右边选择刚才安装的Provisioning,即「iPhoneDeveloper:MyCertificateName」。
编译与执行