---
title: Capturing a Metal workload in Xcode
framework: xcode
role: article
role_heading: Article
path: xcode/capturing-a-metal-workload-in-xcode
---

# Capturing a Metal workload in Xcode

Analyze your app’s performance by configuring your project to use the Metal debugger.

## Overview

Overview You can use Xcode to capture your app’s Metal workload. First, ensure that the GPU Frame Capture option is enabled in the runtime diagnostics options. Then, when your app is running, click the Metal Capture button in the debug bar, select a scope, and click Capture. Configure the GPU Frame Capture options Xcode automatically enables the GPU Frame Capture option if your target links to the Metal framework, or any other framework that uses the Metal API. If you’re collaborating on a project, it’s possible that someone else may have disabled GPU Frame Capture. To ensure it’s enabled, follow these steps: In the Xcode toolbar, choose Edit Scheme from the Scheme menu.  Select the Run scheme action. Select the Options tab. Choose a GPU Frame Capture option and click Close.  The GPU Frame Capture options include the following: Capture your Metal workload while debugging While debugging your app, you can capture a GPU trace by following these steps: Click the Metal Capture button in the debug bar.  Select the scope that you want to capture. This can be a frame, Metal layer, command queue, device, or any custom scopes that you set up previously. For more information, see Creating and using custom capture scopes. Select the count. Depending on the scope, this might include the number of frames or command buffers. Click Capture. Xcode automatically starts capturing a GPU trace when the scope starts, then finishes the capture based on the scope and count you select. To manually stop the capture, you can click the Finish button at any time. Capture your Metal workload after deployment Capture a GPU trace after deploying your app by following these steps: In Xcode, choose Debug > Debug Executable. Select your app in Finder and click Choose. Xcode automatically brings up the scheme editor. Click the Options tab, choose a GPU Frame Capture option, and click Close.  Run your app by choosing Product > Run. Click the Metal Capture button in the debug bar.  Select the scope and count that you want to capture. Click Capture. Xcode automatically starts capturing a GPU trace when the scope starts, then finishes the capture based on the count you select. To manually stop the capture, you can click the Finish button at any time. Configure advanced capture options The Metal Capture popover includes an Advanced section with additional options for controlling capture behavior. To reveal these options, click Show next to Advanced in the popover.

The advanced capture options include the following: Save the capture to your computer To save your captured Metal workload as a GPU trace, choose File > Export. For more information on replaying GPU trace files, see Replaying a GPU trace file.

## See Also

### Essentials

- [Capturing a Metal workload programmatically](xcode/capturing-a-metal-workload-programmatically.md)
- [Replaying a GPU trace file](xcode/replaying-a-gpu-trace-file.md)
- [Investigating visual artifacts](xcode/investigating-visual-artifacts.md)
- [Optimizing GPU performance](xcode/optimizing-gpu-performance.md)
- [Debugging with interactive command-line tools](xcode/debugging-with-interactive-command-line-tools.md)
- [Investigating GPU issues with AI agents](xcode/investigating-gpu-issues-with-ai-agents.md)
