Target Devices and Processes
In order to profile something with a trace document, you need to target it. That is, you need to tell Instruments what you want to profile and where you want to profile it, such as on a device or in a simulator.
When you create a new trace document, Instruments displays the profiling template selection dialog. The top of this dialog includes a target device list and a target process list (), which allow you to specify the desired target when when you choose a template. These lists include any devices that are configured or connected to your Mac, including simulators, as well as any processes available for profiling on those devices. Recently targeted processes, app extensions, active processes, and system processes are also listed.
Target lists are also available in the toolbar of every trace document (see), allowing you to change the target at any time while working in a trace document.
Click the target device list or target process list, and select the desired device and process.
Some instruments allow you to target all processes. If you want to do this, select All Processes in the target process list.
If the desired process isn’t listed, select Choose Target in the target process list. This displays a dialog that allows you to browse for any process. You can also configure environment variables for a process through this dialog.
Target an iOS Device
To target an iOS device, connect the device to your development Mac. Once connected, the device appears in the target device list, as shown in.
Target an iOS Device Wirelessly
Instruments also allows you to collect data from an iOS device wirelessly. Wireless profiling is especially useful when testing the following:
Accelerometers. Move the device in all directions without its being tethered.
Accessories. Plug your USB accessory into the free slot and test it.
Make sure your iOS device is connected to your development Mac by a USB or Lightning cable.
Press the Option key, and click the target device list.
Select your mobile device to enable wireless profiling for it.
Click the target device list again to open it, select the wireless version of your device, and select a process.
Disconnect the device from the USB or Lightning cable.
You should now be able to profile the process wirelessly on your device.
Target an Apple Watch
Before targeting an Apple Watch with Instruments, you must first prepare the Apple Watch for profiling.
Ensure that your Apple Watch is paired with your development iPhone.
Connect the iPhone that’s paired with your Apple Watch to your development Mac by a USB or Lightning cable.
Choose Window > Devices (or press Shift-Command-2) to open the Devices window in Xcode.
Wait for the iPhone to appear in the Devices list.
Wait for the Apple Watch to appear as a paired device for the iPhone.
Wait for Xcode to indicate that the Apple Watch has been prepared. This process may take several minutes.
Disconnect the iPhone from the USB or Lightning cable.
Connect the iPhone to the USB or Lightning cable again.
Once your Apple Watch has been prepared for profiling, relaunch Instruments, and the Apple Watch should appear in the target device list, as shown in.
Other Ways to Target
In this chapter, you learned how to specify a target app and device in Instruments. However, you can also target an app externally, without actually entering the Instruments app directly. Visit the following sections to learn more: