Skip to content

Instantly share code, notes, and snippets.

@mayoff
Created November 5, 2021 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mayoff/1c12f3344e6a84b83a996efb931eec74 to your computer and use it in GitHub Desktop.
Save mayoff/1c12f3344e6a84b83a996efb931eec74 to your computer and use it in GitHub Desktop.
A launchd agent (put it in ~/Library/LaunchAgents) to stop simulator Spotlight processes
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.dqd.stop-simulator-spotlight</string>
<key>ProcessType</key>
<string>Background</string>
<key>ProgramArguments</key>
<array>
<string>/bin/sh</string>
<string>-c</string>
<string>/bin/ps -wwxo 'pid state command' | /usr/bin/grep '/CoreSimulator/.*/Spotlight$' | /usr/bin/awk '$2 ~/^[^T]/ { print $1 }' | /usr/bin/xargs /bin/kill -STOP</string>
</array>
<key>StartInterval</key>
<integer>10</integer>
</dict>
</plist>
@mayoff
Copy link
Author

mayoff commented Nov 5, 2021

Xcode 13's simulator starts a Spotlight process that continuously spews errors to the system log. This is still happening as of at least Xcode 13.2 beta 1.

This launchd agent looks for simulator Spotlight processes every 10 seconds, and sends them SIGSTOP if they're not already stopped.

Put the file in ~/Library/LaunchAgents, then either reboot or run this:

launchctl load ~/Library/LaunchAgents/com.dqd.stop-simulator-spotlight.plist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment