In this demo, you’ll learn a few things about working with a phone attached to your computer. You’ll see an attached phone in Devices and Simulators. The Take Screenshot button is at the top. The screenshots are images the device sends to the screen. The screenshots will even show perfectly if your device has cracks or dead pixels.
The Open Console button is also in the header. Remember from the last lesson that the system console shows all the messages for a simulator. The same is true for a physical device.
Click Open Console and select the device from the list on the left. Then, click Start to begin the flood of messages. Like before, use the filters to see only the messages your app generates.
Back in Xcode, select one of the apps in the list. Now select the circle button and download the container. This will save your app’s sandbox to your computer. With the simulators, you had access to almost all of the data files on the device, but with the phone, you only have access to the files in the app’s sandbox.
Once you save the .xcappdata container somewhere, you can open it by right-clicking and choosing Show Package Contents. In the AppData folder, you’ll see the Documents and tmp directories. Your app accesses these the most. The Library and SystemData directories contain information the system stores about your app.
You can add, edit, or remove files from these directories. Then, back in Xcode, you can use the circle button to replace the container. This lets you write this .xcappdata bundle back onto the phone.
You’d mostly use this to inspect files your app generates when running. You can also use it if you have a test database or some other files you want to use.
The easiest way to share your actual device on a conference call is to use QuickTime Player, which comes installed on your Mac. With the device connected, you can open the app. Select New Movie Recording from the File menu. Select the attached phone from the Screen section in the drop-down next to the record button.
You could make a recording while using your phone or leave the preview open and share that on a video call, but your touches won’t appear. You can make them appear using the Assistive Touch settings in Accessibility and attaching a Bluetooth mouse, but that’s beyond the scope of this demo. You can get instructions with a quick web search.
Back in Xcode, you can see on the Device settings screen that you can connect via network. This does exactly what you’d think. This phone appears as a run destination when unlocked and on the same network as this Mac. You’ll see this little globe icon when you disconnect the phone and look at the run destinations. That indicates it’s attached through the network, not via wire.
You can still build and run to the device, and it’ll work as if connected with a wire. This can be helpful if you’re working with a few different devices or just forgot your USB cable.