d1iwgq
Last Updated: September 22, 2016
·
102
· phaus
902a4faaa4de6f6aebd6fd7a9fbab46a

check for OBJC_IMAGE_SUPPORTS_GC (Applications still using the objective-C Garbage Collector) for macOS Sierra compatibility

#!/bin/bash

checkFile(){
    FILE=$1
    OTOOL=`which otool`
    TAIL=`which tail`
    IFS='/' read -ra ADDR <<< "$FILE"
    unset APP
    for i in "${ADDR[@]}"; do
        if [[ ! "${i-}" = $'\n' ]]; then
            if [[ ! $APP ]] && [[ "$i" == *.app ]]; then
                APP="${i}"; 
            fi
        fi
    done
    if [ "$APP" != "$LASTAPP" ]; then
        LASTAPP=$APP
        PROG=${APP%".app"}
        PATH=${FILE%"/Contents/Info.plist"}
        if [[ -f ${PATH}/Contents/MacOS/${PROG} ]]; then
            CMD=`${OTOOL} -oV "${PATH}/Contents/MacOS/${PROG}" | ${TAIL} -3`
            if [[ $CMD == *"OBJC_IMAGE_SUPPORTS_GC"* ]]; then
                echo "${PATH}: false";
                echo "$CMD";
            #else 
            #   echo "${PATH}: true";
            fi

        fi  
    fi
}

export -f checkFile


LASTAPP="null"

find / -path "*.app/Contents/Info.plist" -exec bash -c 'checkFile "$0"' {} \;