Accidentally deleted a system framework, macOS screwed!

I accidentally deleted AddressBook.framework. Now when I restart my iMac the system can't load this framework thus nothing is working.

I have a bootable disk of macOS Sierra but going to recovery mode and installing macOS Sierra is not possible because downgrading High Sierra isn't allowed.

Formatting my disk will result in losing all my files because I don't have a Time Machine backup.

How can I restore AddressBook.framework to get my system working again.

enter image description here


Usually you would have to reinstall High Sierra in Recovery Mode. If you don't have access to another Mac running High Sierra locally and with limited download quota do the following:

  • Ask someone to upload High Sierra's AddressBook.framework as zip somewhere (e.g. a file sharing host) and submit the download link.

  • Boot to High Sierra's Recovery Mode.

  • Open Terminal and disable SIP (which should be disabled anyway or you wouldn't have been able to delete the framework).

  • Quit Terminal and open Safari. Enter the download link and save the zip file to /Volumes/< main_volume_name>/System/Library/Frameworks/

    Alternatively (if the link doesn't allow to choose a download location, which can occur on some file sharing hosts) open the Preferences in Safari and set in General > File download location > "Ask for each download":

    enter image description here

    Then save the file to /Volumes/< main_volume_name>/System/Library/Frameworks/:

    In the example below the name of the main volume is System. Your main volume name may be different (e.g. Macintosh HD or macOS).

    enter image description here

    enter image description here

  • Open Terminal and enter:

    cd /Volumes/<main_volume_name>/System/Library/Frameworks/
    

    Depending on your Safari settings the zip will be unzipped automatically after the download and the next two steps (unzip/rm) aren't necessary!

    /Volumes/<main_volume_name>/usr/bin/unzip -a AddressBook.framework.zip
    rm AddressBook.framework.zip
    
  • check codesigning:

    codesign -dv --verbose=4 AddressBook.framework
    

    if this step fails delete AddressBook.framework and get a proper one.

  • Check the restricted flag:

    ls -laO AddressBook.framework
    

    which should show for . (the dot: . is the "bundle/package" AddressBook.framework here - the date will be different of course):

    drwxr-xr-x    7 root  wheel restricted 224 Sep 25 21.59 .
    ...
    

    (You may have to add the restricted attribute to AddressBook.framework later if it's missing)

  • (Enable SIP) and reboot.

Ok I will give another easy answer first boot to recovery partition by holding CMD+R at startup chime then after it finishes booting click utilities in the upper panel then click terminal type csrutil disable then restart the your Mac Now once you hear the startup chime hold CMD+S till you see plain text now do the following steps:

• First type mount -uw / • Then plug in another high capacity pendrive • then type mkdir /usb • then type mount -t [filesyatem of pendrive] /dev/disk2s1 /usb

• Now we are going to copy the entire home directory from your MacBook to the pendrive Tip: you can find out the size of your home directory by ls -la /Users • Then type rsync -p -P -o /Users --exclude /Users/your username/Library /Users /usb

Then you can reinstall the OS again by asking a friend by giving a bootable os.