List app’s bundle folders in the user library (macOS)

Home   »   List app’s bundle folders in the user library (macOS)

#!/bin/sh
#
#  List app's bundle folders in the user library
#

targets=($(xcodebuild -list | awk '/Targets:/,/^$/' | grep -Ev '(^$|:)' | sed -e 's/ //g'))
for target in ${targets[@]}
do
    bundles=($(xcodebuild -showBuildSettings -target ${target} | awk '/PRODUCT_BUNDLE_IDENTIFIER/ {print $3}'))
    for ((bundle_i = 0; bundle_i < ${#bundles[@]}; bundle_i++))
    do
	bundle=${bundles[$bundle_i]}
	
        echo "# ${bundle}"
	dirs=(
	    "Application Support"
	    "Containers"
	    "Group Containers"
	)
	for ((dir_i = 0; dir_i < ${#dirs[@]}; dir_i++))
	do
	    dir=${dirs[$dir_i]}
	    
	    path="${HOME}/Library/${dir}/${bundle}/"
	    if [ -d "${path}" ]
	    then
		echo ${path}
	    fi
	done
    done
done

Leave a Reply

Your email address will not be published. Required fields are marked *