xcode 在真正的 iPhone 上测试应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6371632/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Test App on Real iPhone
提问by user559142
Possible Duplicate:
Deploy an iphone app from xcode to iphone
Hi I have tested my app using the iOS simulator. How can I test it on my own iphone? I am an Apple developer member.
嗨,我已经使用 iOS 模拟器测试了我的应用程序。如何在我自己的 iphone 上测试它?我是苹果开发者会员。
回答by Mike Weller
The first thing you need is a development certificate. Visit the iOS provisioning portal and follow the steps here: http://developer.apple.com/ios/manage/certificates/team/howto.action:
您需要的第一件事是开发证书。访问 iOS 配置门户并按照以下步骤操作:http: //developer.apple.com/ios/manage/certificates/team/howto.action:
Once that is done, you can do everything else from Xcode. Using Xcode 4:
完成后,您可以从 Xcode 执行其他所有操作。使用 Xcode 4:
- Connect your device via USB.
- Open the Xcode organizer (
Window->Organizer
) Select "Provisioning Profiles"
Check the "Automatic Device Provisioning" checkbox and click "Refresh"
You will be prompted to enter your developer account username and password. Do this.
This step will automatically create and download a wildcard (*) provisioning profile that you can use for testing any application on your device.
After a few seconds you should see this new profile appear in the list with the name "Team Provisioning Profile: *"
Restart Xcode just to be safe. Sometimes it can get confused.
Open a project and select your device from the main schemes dropdown box:
Build and run.
If that doesn't work straight away, make sure your target has the correct code signing options. Find your target's build settings and for the Debug configuration choose "iPhone Developer" under the "Automatic Profile Selector" group in the dropdown:
This should be selected by default.
- 通过 USB 连接您的设备。
- 打开 Xcode 管理器 (
Window->Organizer
) 选择“配置文件”
选中“自动设备配置”复选框,然后单击“刷新”
系统将提示您输入您的开发者帐户用户名和密码。做这个。
此步骤将自动创建并下载通配符 (*) 配置文件,您可以使用它来测试设备上的任何应用程序。
几秒钟后,您应该会看到此新配置文件出现在列表中,名称为“团队配置文件:*”
重新启动 Xcode 只是为了安全。有时它会混淆。
打开一个项目并从主要方案下拉框中选择您的设备:
构建并运行。
如果这不能立即生效,请确保您的目标具有正确的代码签名选项。找到目标的构建设置,对于调试配置,在下拉列表中的“自动配置文件选择器”组下选择“iPhone 开发人员”:
默认情况下应选择此项。
Good luck!
祝你好运!
回答by Ozair Kafray
You need to learn about creating Adhoc Distributions for iOS devicesfor detailed reference. I am however putting all of it here in the answer:
您需要了解有关为 iOS 设备创建 Adhoc Distributions的详细信息。但是,我将所有内容都放在答案中:
Creating iPhone Ad Hoc Distribution Builds
创建 iPhone Ad Hoc 分发版本
1. Adding Beta Tester Devices
1. 添加 Beta 测试仪设备
Apple allows an Ad Hoc build to be distributed to up to 100 devices which they enforce by making you add the devices to the distribution provisioning certificate. This means that you need to retrieve the UDID for all of the test devices, add them to the provisioning profile using the iOS Provisioning Portal and then download and install the profile.
Apple 允许将 Ad Hoc 构建分发到最多 100 台设备,他们通过让您将设备添加到分发配置证书来强制执行此操作。这意味着您需要检索所有测试设备的 UDID,使用 iOS 配置门户将它们添加到配置文件,然后下载并安装配置文件。
2. Finding the UDID
2. 查找UDID
To get started you need to ask your beta testers to supply the Unique Device ID (UDID) for their devices. To find UDIDs they can follow the steps on:
要开始使用,您需要让 Beta 测试人员为其设备提供唯一设备 ID (UDID)。要查找 UDID,他们可以按照以下步骤操作:
3. Registering the Device
3. 注册设备
Once you have the UDID you need to add it to your account in the iOS Provisioning Portal in the same way you would for a development device. You do this in the Devices section of the portal and can either use the ‘Add Device' button to manually add a single device or use the Upload Devices button to bulk upload multiple UDIDs from a text file.
获得 UDID 后,您需要像添加开发设备一样将其添加到 iOS 供应门户中的帐户中。您可以在门户的“设备”部分执行此操作,并且可以使用“添加设备”按钮手动添加单个设备或使用“上传设备”按钮从文本文件批量上传多个 UDID。
Note:
If you want to bulk upload multiple devices the format of the text file needs to be as follows with the two columns separated with tabs:
Note:
如果你想批量上传多台设备,文本文件的格式需要如下,两列之间用制表符分隔:
Device ID Device Name
1234567890123456789012345678901234567890 Test_iPad
The contents of the first line are not important but you need to put something as the first line is ignored when you upload.
第一行的内容并不重要,但你需要放一些东西,因为上传时第一行会被忽略。
Also be aware that you can only register up to 100 devices each year. You can delete devices any time you want but once added they still count towards your annual allocation. (So if you add 100 devices and then delete 50 of them you still have to wait until the next year before you can add any more).
另请注意,您每年最多只能注册 100 台设备。您可以随时删除设备,但一旦添加,它们仍会计入您的年度分配。(因此,如果您添加 100 台设备,然后删除其中的 50 台,您仍然需要等到明年才能添加更多设备)。
4. Creating the Distribution Provisioning Profile
4. 创建分发配置文件
Assuming you already have a distribution certificatethe process to create an Ad Hoc provisioning profile is quick and easy. In the Distribution tab of the Provisioning section use the New Profile button.
假设您已经拥有分发证书,那么创建 Ad Hoc 配置文件的过程既快速又简单。在 Provisioning 部分的 Distribution 选项卡中,使用 New Profile 按钮。
The only difference between an Ad Hoc profile and a normal App Store profile is the Distribution Method.
Ad Hoc 配置文件和普通 App Store 配置文件之间的唯一区别是分发方法。
Ensure you select the Ad Hoc method and then enter a profile name, the App ID and finally ensure you select all of the devices you want the Ad Hoc build to run on. Once you have finished submitting the profile you should download it and save it somewhere safe as you will need to send it to each of the beta testers. The file should have an extension of .mobileprovision. You should also drag the file onto your Xcode icon to install it, you can use the Xcode organiser to verify that it installed ok. You should see the profile in the Provisioning Profiles section.
确保选择 Ad Hoc 方法,然后输入配置文件名称、App ID,最后确保选择了希望 Ad Hoc 构建运行的所有设备。完成提交配置文件后,您应该下载它并将其保存在安全的地方,因为您需要将其发送给每个 Beta 测试人员。该文件的扩展名应为 .mobileprovision。您还应该将文件拖到您的 Xcode 图标上进行安装,您可以使用 Xcode 管理器来验证它是否安装正常。您应该会在 Provisioning Profiles 部分看到配置文件。
5. Building for Ad Hoc Distribution
5. 构建临时分发
With the provisioning profiles configured correctly the next step is to prepare the project in Xcode for an Ad Hoc build. It might be useful to create a configuration just for Ad Hoc builds so that you do not have to worry about the details each time. The easiest way to do that is to copy an existing configuration, if you already have a Distribution configuration that is probably a good starting point otherwise you can start from the default “Release” configuration.
正确配置配置文件后,下一步是在 Xcode 中为 Ad Hoc 构建准备项目。为 Ad Hoc 构建创建一个配置可能很有用,这样您就不必每次都担心细节。最简单的方法是复制现有配置,如果您已经有一个分发配置,这可能是一个很好的起点,否则您可以从默认的“发布”配置开始。
With the project open in Xcode, right-click on the target and select “Get Info” to bring up the Info dialog window and select the Build tab and then in the Configuration drop down menu select “Edit Configurations…”
在 Xcode 中打开项目后,右键单击目标并选择“获取信息”以打开信息对话框窗口并选择“构建”选项卡,然后在“配置”下拉菜单中选择“编辑配置...”
Select an existing configuration (e.g. Release or Distribution) and then at the bottom of the window use the Duplicate button to create a copy of the configuration and name it “AdHoc”.
选择现有配置(例如发布或分发),然后在窗口底部使用复制按钮创建配置的副本并将其命名为“AdHoc”。
In the Target Info window ensure this new AdHoc configuration is selected and then adjust the following settings in the Build tab. In the Code Signing section, look for the “Any iOS” setting under Code Signing Identity and make sure it is set to iPhone Distribution and matches the Ad Hoc provisioning profile we installed previously.
在 Target Info 窗口中,确保选择了这个新的 AdHoc 配置,然后在 Build 选项卡中调整以下设置。在代码签名部分,查找代码签名标识下的“任何 iOS”设置,并确保将其设置为 iPhone 分发并与我们之前安装的 Ad Hoc 配置文件匹配。
6. Entitlements
6. 权利
There is one additional step if your project includes an Entitlements.plist file (perhaps because you needed to enable keychain data sharing). For an Ad Hoc distribution you need to ensure that the get-task-allow flag is not set in the plist file. One way to handle this is to add a second file (Entitlements-adhoc.plist) just for the Ad Hoc build which is identical apart from the get-task-allow flag:
如果您的项目包含 Entitlements.plist 文件,则还有一个额外的步骤(可能是因为您需要启用钥匙串数据共享)。对于 Ad Hoc 发行版,您需要确保未在 plist 文件中设置 get-task-allow 标志。处理此问题的一种方法是为 Ad Hoc 构建添加第二个文件 (Entitlements-adhoc.plist),除了 get-task-allow 标志外,该文件是相同的:
To ensure this new Entitlements file is used you need to modify the Code Signing Entitlements setting in the AdHoc configuration to reference the new file.
为确保使用此新权利文件,您需要修改 AdHoc 配置中的代码签名权利设置以引用新文件。
7. Build and Archive
7. 构建和存档
With the AdHoc build settings active use the Build and Archive command to create the distribution build. Assuming the build was successful you should find it in the Xcode Organizer in the Archived Applications section. You can add a name and comment to the organizer for future reference at this point.
在 AdHoc 构建设置处于活动状态时,使用 Build and Archive 命令创建分发构建。假设构建成功,您应该在 Xcode Organizer 的 Archived Applications 部分找到它。此时您可以向组织者添加名称和评论以供将来参考。
8. Sharing the Application
8. 分享应用
The easiest way to send the application files to a beta tester is to use the Xcode organizer to create an ipa file. To do that select the AdHoc build in the Archived Applications section and use the Share button and then select Save to Disk. Xcode will create a signed application file and save it to disk with a name of your choosing. Name the file something useful like appName-x.y.z.ipa where x.y.z is the version number.
将应用程序文件发送给 beta 测试人员的最简单方法是使用 Xcode 管理器创建一个 ipa 文件。为此,请在“存档应用程序”部分中选择 AdHoc 构建并使用“共享”按钮,然后选择“保存到磁盘”。Xcode 将创建一个签名的应用程序文件,并使用您选择的名称将其保存到磁盘。将文件命名为 appName-xyzipa 之类的有用名称,其中 xyz 是版本号。
You can then send this .ipa file together with the .mobileprovision file to your beta tester with instructions to drag onto their iTunes library to install it on the test device.
然后,您可以将此 .ipa 文件与 .mobileprovision 文件一起发送给您的 Beta 测试人员,并附上将其拖到他们的 iTunes 资料库中以将其安装在测试设备上的说明。
For sharing and application versioned release management you can also use testflightapp
对于共享和应用程序版本化发布管理,您还可以使用testflightapp
回答by Adarsh V C
You should add your device UUID to your iOS provisioning portal. Create an App id. Create a mobile provisioning profile by selecting your device and App Id. Download and install that profile to your device. The build and run your app on the device. Please let me know if you need further clarification.
您应该将您的设备 UUID 添加到您的 iOS 配置门户。创建一个应用程序 ID。通过选择您的设备和应用程序 ID 创建移动配置文件。下载该配置文件并将其安装到您的设备上。在设备上构建并运行您的应用程序。如果您需要进一步说明,请告诉我。