如何在 iOS 11、Apple TV 4K 等的 Xcode 9 中进行无线调试?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44382841/
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
How do you perform wireless debugging in Xcode 9 with iOS 11, Apple TV 4K, etc?
提问by iPC
Wireless debugging was recently added as a feature in Xcode 9, iOS 11, and tvOS 11. Apple TV 4K doesn't have a USB port, so it requires wireless debugging. How do you perform this wireless debugging in Xcode?
最近在 Xcode 9、iOS 11 和 tvOS 11 中添加了无线调试功能。Apple TV 4K 没有 USB 端口,因此需要无线调试。您如何在 Xcode 中执行此无线调试?
回答by Surjeet
Set up a device for network debugging
设置网络调试设备
from help.apple.com
来自 help.apple.com
NOTE: Mac system and iPhone/iPad should share same network to use wireless debugging.
注意:Mac 系统和 iPhone/iPad 应该共享同一个网络才能使用无线调试。
Debug your app running on an iOS or tvOS device over a WiFi or other network connection.
通过 WiFi 或其他网络连接调试在 iOS 或 tvOS 设备上运行的应用程序。
Note:Network debugging requires Xcode 9.0 or laterrunning on macOS 10.12.4 or later, and on the device, requires iOS 11.0 or later, or tvOS 11.0 or later.
注意:网络调试需要在macOS 10.12.4 或更高版本上运行的Xcode 9.0 或更高版本,并且在设备上,需要 iOS 11.0 或更高版本,或tvOS 11.0 或更高版本。
Steps to set up iPhone, iPad, or iPod touch
设置 iPhone、iPad 或 iPod touch 的步骤
Choose Window > Devices and Simulators, then in the window that appears, click Devices.
Connect your device to your Mac with a Lightning cable.
- Check if passcode enables in your device settings. Enable if not already enabled.
In the left column, select the device, and in the detail area, select Connect via network.
Xcode pairs with your device. If Xcode can connect with the device using a network, a network icon appears next to the device in the left column.
Disconnect your device.
选择“窗口”>“设备和模拟器”,然后在出现的窗口中单击“设备”。
使用 Lightning 线缆将您的设备连接到 Mac。
- 检查密码是否在您的设备设置中启用。如果尚未启用,请启用。
在左列中,选择设备,然后在详细信息区域中,选择通过网络连接。
Xcode 与您的设备配对。如果 Xcode 可以使用网络与设备连接,则左列中的设备旁边会出现一个网络图标。
断开您的设备。
Note: Device require a passcode to enable remote debugging.
注意:设备需要密码才能启用远程调试。
Now you are ready for debugging over the network.
现在您已准备好通过网络进行调试。
Steps to set up Apple TV:
设置 Apple TV 的步骤:
Make sure your Mac and your Apple TV are on the same network.
Choose Window > Devices and Simulators, then in the window that appears, click Devices.
On your Apple TV, open the Settings app and choose Remotes and Devices > Remote App and Devices.
The Apple TV searches for possible devices including the Mac. (If you have any Firewall or Internet security, disable/turn off to allow searching.)
On your Mac, select the Apple TV in the Devices pane. The pane for the Apple TV is displayed and shows the current status of the connection request.
Enter the verification code displayed on your AppleTV into the Device window pane for the device and click Connect.
确保您的 Mac 和 Apple TV 位于同一网络上。
选择“窗口”>“设备和模拟器”,然后在出现的窗口中单击“设备”。
在 Apple TV 上,打开“设置”应用并选取“遥控器和设备”>“远程应用和设备”。
Apple TV 会搜索可能的设备,包括 Mac。(如果您有任何防火墙或 Internet 安全功能,请禁用/关闭以允许搜索。)
在 Mac 上,在“设备”面板中选择 Apple TV。将显示 Apple TV 的窗格并显示连接请求的当前状态。
将 AppleTV 上显示的验证码输入设备的“设备”窗口窗格,然后单击“连接”。
Xcode sets up the Apple TV for wireless debugging and pairs with the device.
Xcode 设置 Apple TV 以进行无线调试并与设备配对。
Edit: -------
编辑: - - - -
Sometime pairing doesn't work for wireless debugging, So just restart your device and internet connection. Also if firewallis enabled, you need to turn off Firewall for pairing device.
有时配对不适用于无线调试,因此只需重新启动您的设备和互联网连接。此外,如果防火墙已启用,则需要关闭防火墙设备配对。
回答by damithH
I have tried using Xcode Devices window's Connect via network options. but I am unable to see the "Connected over the network" icon next to the device name. also as soon as remove the USB the "Connect via network" option disappeared. also, the device name appears under the disconnected device list.
我曾尝试使用 Xcode Devices 窗口的 Connect via network 选项。但我看不到设备名称旁边的“通过网络连接”图标。同样,只要移除 USB,“通过网络连接”选项就会消失。此外,设备名称会出现在断开连接的设备列表下。
But using the "Connect via IP Address..." option, I am able to connect.
但是使用“通过 IP 地址连接...”选项,我可以连接。
- Right-click on the device name(Under Disconnected list) and choose "Connect via IP Address...." option.
- 右键单击设备名称(在断开连接列表下)并选择“通过 IP 地址连接....”选项。
回答by ios_dev
If you have completed all steps given by Surjeetand still not getting network connection icon then follow below steps:
如果您已完成Surjeet 提供的所有步骤,但仍未获得网络连接图标,请按照以下步骤操作:
Unpair Device using right click on the device from the Connectedsection.
Reconnect the device.
Click on "+"button from the end of the lefthand side of the popup.
- Select the device and click on nextbutton
- 选择设备并单击下一步按钮
- Click on Trustand passcode(if available)from the device.
- 单击设备上的信任和密码(如果可用)。
- Click on Donebutton.
- 单击完成按钮。
- Now, click on connect via network.
- 现在,单击通过网络连接。
Now you can see the network connection icon after the device name. Enjoy!
现在您可以在设备名称后看到网络连接图标。享受!
回答by Aleem
Prerequisite
先决条件
- Your Mac Machine should have at least Mac OSX 10.12.4 or later
- Your iOS device should have at least iOS 11.0 or later
- Both devices should be on same network.
- 你的 Mac 机器至少应该有 Mac OSX 10.12.4 或更高版本
- 您的 iOS 设备应至少具有 iOS 11.0 或更高版本
- 两台设备应该在同一个网络上。
Steps to Activate
激活步骤
Plug your iOS device with Mac machine from cable.
Open Xcode then from top menu Window -> Devices and Simulators
Chose Devicessegment and chose your desired Device from left device list.
On right side you can see open Connect via network, enable this option as shown in attached image.
After few seconds you can see network sign in front of you device.
Unplug your device and use debugging as you're using normally.
从电缆将您的 iOS 设备与 Mac 机器连接起来。
打开 Xcode,然后从顶部菜单 Window -> Devices and Simulators
选择设备部分并从左侧设备列表中选择所需的设备。
拔下您的设备并像正常使用一样使用调试。
Thanks
谢谢
回答by Joppe Geluykens
If after following the steps as described by Surjeetyou still can't connect, try turning your computer's Wi-Fi off and on again. This worked for me.
如果按照Surjeet 描述的步骤操作后仍然无法连接,请尝试关闭并重新打开计算机的 Wi-Fi。这对我有用。
Also, be sure to trust the developer certificate on the iOS device (Settings - General - Profiles & Device Management - Developer App).
此外,请务必信任 iOS 设备上的开发者证书(设置 - 通用 - 配置文件和设备管理 - 开发者应用)。
回答by lilalinux
Network debugging requires Xcode 9.0 or later running on macOS 10.12.4 or later, and on the device, requires iOS 11.0 or later, or tvOS 11.0 or later.
网络调试需要在 macOS 10.12.4 或更高版本上运行的 Xcode 9.0 或更高版本,并且在设备上,需要 iOS 11.0 或更高版本,或 tvOS 11.0 或更高版本。
iPhone
苹果手机
iOS 11 won't be available for 32bit devices, i.e. iPhone 5 and iPhone 5c and below. The first 64bit iPhone is 5s.
iOS 11不适用于 32 位设备,即 iPhone 5 和 iPhone 5c 及以下。第一款 64 位 iPhone 是 5s。
iPad
iPad
iPad mini 2 will be the oldest iPad with iOS 11 support.
iPad mini 2 将成为支持 iOS 11 的最老的 iPad。
iPod
iPod
iPod needs to be an iPod 6 to be able to run iOS.
iPod 必须是 iPod 6 才能运行 iOS。
If you use your devices not only for developing but also for production, be warned that a beta OS is not for the faint hearted ;-)
如果您的设备不仅用于开发,还用于生产,请注意 Beta 版操作系统不适合胆小的人 ;-)
回答by D4ttatraya
In the new Xcode9-beta, we can use wireless debuggingas said by Apple:
在新的 Xcode9-beta 中,我们可以使用Apple 所说的无线调试:
Cut the Cord
Choose any of your iOS or tvOS devices on the local network to install, run, and debug your apps – without a USB cord plugged into your Mac. Simply click the ‘Connect via Network'checkbox the first time you use a new iOS device, and that device will be available over the network from that point forward. Wireless development also works in other apps, including Instruments, Accessibility Inspector, Quicktime Player, and Console.
切断
电源线选择本地网络上的任何 iOS 或 tvOS 设备来安装、运行和调试您的应用程序 - 无需将 USB 线插入您的 Mac。第一次使用新的 iOS 设备时,只需单击“通过网络连接”复选框,从那时起该设备将可通过网络使用。无线开发也适用于其他应用程序,包括 Instruments、Accessibility Inspector、Quicktime Player 和 Console。
Try this!
尝试这个!
If facing disconnection issues, try this:
如果遇到断线问题,试试这个:
Workaround: Enable airplane mode on your device for 10 seconds and then disable airplane mode to re-establish your connection
解决方法:在您的设备上启用飞行模式 10 秒钟,然后禁用飞行模式以重新建立连接
回答by Paul van Roosendaal
I just talked to some Xcode engineers at WWDC and the auto discovery of iDevices is still a little buggy. Also sometimes your phone is not correctly broadcasting. Switching your device on and off can help.
我刚刚和 WWDC 的一些 Xcode 工程师交谈过,iDevices 的自动发现仍然有点问题。此外,有时您的手机无法正确广播。打开和关闭设备会有所帮助。
There are a few workarounds/fallbacks:
有一些解决方法/回退:
You can check if your phone is broadcasting with Bonjour Browser (www.tildesoft.com). Look if your wifi address is listed under the service called '_apple-mobdev2._tcp. - 215' (you can find your wifi address here: settings > general > about > wifi address.
您可以使用 Bonjour 浏览器 (www.tildesoft.com) 检查您的手机是否正在播放。查看您的 wifi 地址是否列在名为“_apple-mobdev2._tcp”的服务下。- 215'(您可以在此处找到您的 wifi 地址:设置 > 常规 > 关于 > wifi 地址。
As a fallback you can connect to your device by manually entering the IP address (right click on your devices in the Devices window). However this IP address will be persisted, so if you change networks you'll need to reset this. That option is not available in Xcode yet, but you can do it via the terminal with the following command:
作为后备,您可以通过手动输入 IP 地址来连接到您的设备(在“设备”窗口中右键单击您的设备)。但是,此 IP 地址将被保留,因此如果您更改网络,则需要重置此地址。该选项在 Xcode 中尚不可用,但您可以使用以下命令通过终端执行此操作:
defaults read com.apple.dt.Xcode | grep IDEIDS
This will print an identifier which you need to use in the next command:
这将打印您需要在下一个命令中使用的标识符:
defaults delete com.apple.dt.Xcode <identifier>
Now the ip address is cleared and you can enter a new one.
现在IP地址被清除,你可以输入一个新的。
The last option is to create a computer-to-computer network. This works fine, but logically you won't have internet access then.
最后一个选项是创建一个计算机到计算机的网络。这工作正常,但从逻辑上讲,那时您将无法访问互联网。
回答by ejovrh
You can open Xcode Help -> Run and debug -> Network debugging for more info. Hope it helps.
您可以打开 Xcode 帮助 -> 运行和调试 -> 网络调试以获取更多信息。希望能帮助到你。
回答by magpie
i followed all the suggested steps, in particular the ones provided from ios_dev but my iPhone was not recognized from Xcode and i was not able to debug over WiFi. Right click on the left panel over my iDevice in "Devices and Simulators" window, then "Connect via IP Address...", inserted the iPhone IP and now it correctly works
我遵循了所有建议的步骤,特别是 ios_dev 提供的步骤,但我的 iPhone 无法从 Xcode 识别,我无法通过 WiFi 进行调试。右键单击“设备和模拟器”窗口中 iDevice 上的左侧面板,然后“通过 IP 地址连接...”,插入 iPhone IP,现在它可以正常工作