sunknudsen / privacy-guides

Privacy guides reference material (archived)
MIT License
782 stars 92 forks source link

App cleaner doesn't find *Info.plist* file for iPhone/iPad apps on new Mac with Apple Silicon chip #244

Open leonardthomson opened 2 years ago

leonardthomson commented 2 years ago

Guide

How to clean uninstall macOS apps using AppCleaner open source alternative

Summary

I wanted to uninstall Chess from chess.com (iPad version) but got the error:

... % app-cleaner.sh /Applications/Chess.app
Cannot find app plist

I was able to reproduce the error for another iPhone app.

The error message is printed here. So for new Macs the if condition should be adapted.

leonardthomson commented 2 years ago

Ha sorry😅 I wanted to add something:

It seems that the Info.plist file is saved in the wrapped app (*$1/Wrapper/AppName.app/Info.plist*). For this file the condition gives plausible output.

... % /usr/libexec/PlistBuddy -c "Print CFBundleIdentifier" "/Applications/Chess.app/Wrapper/Chess.app/Info.plist"            
com.chess.iphone
leonardthomson commented 2 years ago

The WrappedBundle is apperantly simply an alias for the true app which is in the Wrapper folder. Since the app name and the wrapped app name don't doesn't have to be the same, it is easier to check for the file with "$1/WrappedBundle/Info.plist".

So my suggestion would be:

if [ -e "$1/Contents/Info.plist" ]; then
  bundle_identifier=$(/usr/libexec/PlistBuddy -c "Print CFBundleIdentifier" "$1/Contents/Info.plist" 2> /dev/null)
elif [ -e "$1/WrappedBundle/Info.plist" ]; then
  bundle_identifier=$(/usr/libexec/PlistBuddy -c "Print CFBundleIdentifier" "$1/WrappedBundle/Info.plist" 2> /dev/null)
else
  printf "%s\n" "Cannot find app plist"
  exit 1
fi

Convincing output:

... % app-cleaner.sh /Applications/Chess.app 
Checking for running processes…
Finding app data…
/Applications/Chess.app
/Users/username/Library/Application Scripts/com.apple.Chess
/Users/username/Library/Containers/com.apple.Chess
/var/folders/c2/flxghxsd6x1c3fjbngkzlpx00000gn/C/com.apple.Chess
/var/folders/c2/flxghxsd6x1c3fjbngkzlpx00000gn/C/com.chess.iphone
Move app data to trash (y or n)? y
Moving app data to trash…
Done
verityj commented 1 year ago

I agree. App-cleaner does not find iPhone/iPad apps installed into silicon Macs. I ended up manually following https://www.macrumors.com/how-to/uninstall-iphone-ipad-apps-m1-mac/ To note, app-cleaner should look through ~/Library/Containers. I don't think I know enough scripting to enable that, so I end up doing it manually right now.

verityj commented 1 year ago

I ended up modifying the original script to work with the iOS apps on Macs. But additionally, we need to delete the app containers (and any error log files or anything else that still persists). I shared the script and wrote it up: https://verityj.github.io/2023/06/21/clean.html. In case it helps anyone.

I specifically kept it as a two step process to have control of exactly what stays and what goes.