IOS – Cannot remove iOS simulator receipt files from Trash

ios-simulatormacosxcode

I was trying to use the iOS7 simulator in El Capitan in Xcode 6.4, deleted it, reinstalled it etc. Part of that was dragging iOS 7.1.simruntime from /Library/Developer/CoreSimulator/Profiles/Runtimes to Trash. Now I want to empty the Trash and it does not work.

  1. Open Trash, click "Empty": "The operation can’t be completed because the item “iOS 7.1.simruntime” is in use"

  2. Terminal:

mba7:.Trash fsc$ rm -rf iOS\ 7.1.simruntime
rm: iOS 7.1.simruntime/System/Library/Receipts/com.apple.pkg.iPhoneSimulatorSDK7_1.bom: Operation not permitted
rm: iOS 7.1.simruntime/System/Library/Receipts/com.apple.pkg.iPhoneSimulatorSDK7_1.plist: Operation not permitted
rm: iOS 7.1.simruntime/System/Library/Receipts: Operation not permitted
rm: iOS 7.1.simruntime/System/Library: Directory not empty
rm: iOS 7.1.simruntime/System: Directory not empty
rm: iOS 7.1.simruntime: Directory not empty
mba7:.Trash fsc$ 
  1. Terminal: "sudo"
mba7:.Trash fsc$ sudo rm -rf iOS\ 7.1.simruntime
... same error
  1. "lsof" (output manually wrapped)
mba7:.Trash fsc$ sudo lsof | grep "simruntime"
com.apple 743            root  txt       REG                1,4     
58608            21307311 /Library/Developer/CoreSimulator/Profiles/Runtimes/
iOS 8.4.simruntime/Contents/Resources/RuntimeRoot
/usr/lib/system/host/liblaunch_sim.dylib

I already restarted several times, tried to change permissions etc.

What other steps can I take to get rid of the files?

Best Answer

You need to disable System Integrity Protection (SIP).

  • Reboot the Mac in Recovery mode : Hold down Command + R after you hear the startup chime
  • Launch the terminal (Utilities > Terminal)
  • csrutil disable
  • Reboot
  • Empty your trash
  • Reboot again in Recovery mode
  • Launch the terminal
  • csrutil enable
  • Reboot