# iOS Simulator

> Capture and decrypt traffic from iOS, tvOS and watchOS Simulators, and install the Cloak Proxy certificate in every booted simulator with one click.

Source: https://docs.subcloak.com/cloak-proxy/devices/ios-simulator/

Simulators are the quickest way to debug an iOS app's network calls. iOS, tvOS and watchOS Simulators use your Mac's network settings, so their traffic is captured whenever the macOS proxy is on. Each simulator keeps its own trusted certificates, though, so it needs the Cloak Proxy certificate installed once before HTTPS can be decrypted.

## Requirements

- **Xcode**, installed and selected as the active developer directory. The one-click install uses `simctl`, which comes with Xcode.
- At least one simulator booted (running) when you install the certificate.
- The macOS proxy on, so the simulator's traffic goes through Cloak Proxy. See [macOS traffic](https://docs.subcloak.com/cloak-proxy/capture/macos-traffic/).

If `simctl` isn't available, the **iOS Simulator** page shows: **This needs Xcode (simctl isn't installed). Install Xcode from the App Store, then run `sudo xcode-select -s /Applications/Xcode.app`.**

*[Screenshot: The iOS Simulator page of Device & Runtime Setup explaining that simulators use the Mac's network settings and need the certificate installed once per simulator, with an Install Certificate on All Booted Simulators button. The iOS Simulator page on a Mac with Xcode. Without Xcode, an orange warning that simctl isn't found replaces the button.]*

```bash title="Terminal"
sudo xcode-select -s /Applications/Xcode.app
```

Cloak Proxy checks for `simctl` each time you open the tab, so switch to another tab and back after you install Xcode.

## Install the certificate

1. Boot the simulators you want to use. Open them from Xcode or the Simulator app.

2. Open **Device & Runtime Setup** (click **Devices** in the toolbar) and choose **iOS Simulator** in its sidebar.

3. Click **Install Certificate on All Booted Simulators**.

   Cloak Proxy runs this command with the path of its root certificate:

   ```bash
   xcrun simctl keychain booted add-root-cert "$HOME/Library/Application Support/CloakProxy/cloak-proxy-ca.pem"
   ```

4. Read the result below the button:

   - **Installed. Restart the app in the simulator.** The certificate is trusted. Quit and reopen your app so it picks up the change.
   - **simctl: no booted simulator?** No simulator was running. Boot one and click the button again.
   - **simctl:** followed by other text is the error `simctl` reported.

5. Turn on the macOS proxy if it's off: click **macOS Proxy** in the toolbar or press <kbd>⇧</kbd> <kbd>⌘</kbd> <kbd>P</kbd>.

You don't need to set a proxy inside the simulator or turn on **Allow other devices to connect**. The simulator's requests come from your Mac itself, the same way any other Mac app's do.

> **Tip:**
> The certificate stays installed until you erase the simulator. A new simulator, or one you erase with **Device › Erase All Content and Settings**, needs it installed again.

(added in Cloak Proxy 0.5.1) The [Doctor](https://docs.subcloak.com/cloak-proxy/capture/doctor/) watches for booted simulators that don't have the certificate, including ones booted or created after setup, and offers **Install the certificate** for them. It reads each simulator's files, so it doesn't run `simctl` until you click.

## Install on one specific simulator

To install the certificate on one particular simulator while several are booted, run `simctl` yourself with that simulator's UDID. List the UDIDs first; booted simulators are marked `(Booted)`.

```bash title="Terminal"
xcrun simctl list devices
xcrun simctl keychain <UDID> add-root-cert "$HOME/Library/Application Support/CloakProxy/cloak-proxy-ca.pem"
```

To print the certificate's path from a script, use `cloakctl ca`. See [cloakctl](https://docs.subcloak.com/cloak-proxy/automation/cloakctl/).

(added in Cloak Proxy 0.4.0)

In a script or CI job, `cloakctl setup ios_simulator --apply simulator-certificate` installs the certificate in every booted simulator (add `--udid UDID` for one), without the app or a password, and exits with `2` if anything is still missing. An AI assistant does the same with the `capture_setup` or `install_certificate` MCP tools. See [Agent skills and setup tools](https://docs.subcloak.com/cloak-proxy/automation/agent-skills/#guided-capture-setup).

## Decrypt the hosts you need

Installing the certificate makes decryption possible. Cloak Proxy still decrypts only the hosts in [SSL Proxying](https://docs.subcloak.com/cloak-proxy/capture/ssl-proxying/), or the apps you turned SSL Proxying on for. Add your API's host, for example `api.example.com`, then repeat the request in the simulator.

> **Note:**
> Hosts in the [Bypass](https://docs.subcloak.com/cloak-proxy/capture/macos-traffic/) list skip Cloak Proxy entirely, in simulators too, because simulators use the Mac's proxy settings. The defaults bypass `localhost`, `*.local` and `169.254/16`.

## Undo the setup

1. Turn off the macOS proxy when you no longer want to capture (<kbd>⇧</kbd> <kbd>⌘</kbd> <kbd>P</kbd>). Simulators then connect directly again.

2. To remove the certificate from a simulator, reset its keychain or erase it:

   ```bash title="Terminal"
   xcrun simctl keychain booted reset
   ```

   Resetting removes every certificate you added to that simulator's keychain, not only Cloak Proxy's. **Device › Erase All Content and Settings** in the Simulator app removes everything.

If you regenerate the root certificate in **Settings › Certificate**, simulators that trusted the old one need the new one installed. Click **Install Certificate on All Booted Simulators** again.

## Related

  - [macOS traffic](https://docs.subcloak.com/cloak-proxy/capture/macos-traffic/): Turn the macOS proxy on and off.
  - [SSL Proxying](https://docs.subcloak.com/cloak-proxy/capture/ssl-proxying/): Choose which hosts are decrypted.
  - [iPhone and iPad](https://docs.subcloak.com/cloak-proxy/devices/iphone-and-ipad/): Capture a real device over Wi-Fi.
  - [Certificate](https://docs.subcloak.com/cloak-proxy/capture/certificate/): Install, remove or regenerate the root certificate.
