Last Updated: September 22, 2016
·
546
· phaus

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"' {} \;