Okay, let's break down this error.
The error Load failed: 5: Input/output error when trying to load com.apple.screensharing.plist often points to a couple of common issues on modern macOS versions (Catalina and later).
Likely Cause: System Integrity Protection (SIP) and the -w Flag
- Read-Only System Volume: On macOS Catalina (10.15) and newer, the main system volume (where
/System/Library/ resides) is mounted as read-only. This is a security feature enforced by SIP.
- The
-w Flag: The -w flag in launchctl load tells launchctl to write to the .plist file itself, specifically to remove or add a Disabled key. This makes the enabled/disabled state persistent across reboots by modifying the file.
- The Conflict: You are trying to use
-w (which attempts to write to the file) on a file located in the read-only /System/Library/ directory. The operating system prevents this write operation, resulting in an "Input/output error".
How to Fix It (Modern macOS Approach)
Instead of using launchctl load -w, you should use the modern launchctl enable and launchctl load (without -w) or launchctl kickstart commands.
-
Enable the Service Persistently:
-
Load/Start the Service Now (if it's not already running):
Alternative / Easier Method: System Settings/Preferences
Often, the easiest way to manage standard system services like Screen Sharing is through the GUI:
- Go to System Settings (Ventura+) or System Preferences (Monterey and earlier).
- Navigate to Sharing.
- Check the box for Screen Sharing on the left. This handles enabling and loading the service correctly behind the scenes.
Other Troubleshooting Steps if the Above Doesn't Work:
-
Follow the Error's Suggestion (for more details): While bootstrap isn't usually used for re-loading a service like this, running it might give a different error:
sudo launchctl bootstrap system /System/Library/LaunchDaemons/com.apple.screensharing.plist
Pay close attention to any different output it might give.
-
Check File Integrity: Although unlikely in /System, ensure the plist file isn't corrupted.
plutil -lint /System/Library/LaunchDaemons/com.apple.screensharing.plist
It should output: /System/Library/LaunchDaemons/com.apple.screensharing.plist: OK
-
Check Disk Health: An I/O error could theoretically indicate a disk problem, though less likely in this specific case. Run Disk Utility (Applications > Utilities > Disk Utility), select your startup volume (e.g., "Macintosh HD"), and click "First Aid".
-
Check SIP Status: Confirm SIP is enabled (it should be).
csrutil status
It should report System Integrity Protection status: enabled. Don't disable SIP unless you have a very specific, understood reason – it's a crucial security feature.
In summary: Stop using -w with launchctl load for files in /System/Library/. Use sudo launchctl enable system/com.apple.screensharing and potentially sudo launchctl kickstart -k system/com.apple.screensharing instead, or simply use the Sharing pane in System Settings/Preferences.