HoseyifyXcodeWarnings.scpt

I usually recommend .xcconfig files, but if you don’t want to mess with them, here’s an AppleScript that will Hoseyify all your currently-open Xcode project warnings:

property kHoseyXcodeWarningSettings : {¬
    {"GCC_WARN_CHECK_SWITCH_STATEMENTS", "YES"}, ¬
    {"GCC_WARN_SHADOW", "YES"}, ¬
    {"GCC_WARN_64_TO_32_BIT_CONVERSION", "YES"}, ¬
    {"GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED", "YES"}, ¬
    {"GCC_WARN_ABOUT_RETURN_TYPE", "YES"}, ¬
    {"GCC_WARN_MISSING_PARENTHESES", "YES"}, ¬
    {"GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS", "YES"}, ¬
    {"GCC_WARN_ABOUT_MISSING_NEWLINE", "YES"}, ¬
    {"GCC_WARN_SIGN_COMPARE", "YES"}, ¬
    {"GCC_WARN_STRICT_SELECTOR_MATCH", missing value}, ¬
    {"GCC_WARN_TYPECHECK_CALLS_TO_PRINTF", "YES"}, ¬
    {"GCC_WARN_UNDECLARED_SELECTOR", "YES"}, ¬
    {"GCC_WARN_UNUSED_FUNCTION", "YES"}, ¬
    {"GCC_WARN_UNUSED_LABEL", "YES"}, ¬
    {"GCC_WARN_UNUSED_VALUE", "YES"}, ¬
    {"GCC_WARN_UNUSED_VARIABLE", "YES"}, ¬
    {"GCC_TREAT_WARNINGS_AS_ERRORS", "YES"}, ¬
    {"RUN_CLANG_STATIC_ANALYZER", "YES", "Release"} ¬
        }

repeat with setting in kHoseyXcodeWarningSettings
    if (count of setting) is 2 then
        set setting to setting & missing value
    end if
    setBuildSetting(item 1 of setting, item 2 of setting, item 3 of setting)
end repeat

on setBuildSetting(buildSettingName, buildSettingValue, buildConfigurationName)
    if buildSettingValue is missing value then
        tell application "Xcode"
            set projectList to every project
            repeat with projectIt in projectList
                set buildConfigurationList to every build configuration of projectIt
                repeat with buildConfigurationIt in buildConfigurationList
                    if buildConfigurationName is missing value or name of buildConfigurationIt is buildConfigurationName then
                        delete (every build setting of buildConfigurationIt whose name is buildSettingName)
                    end if
                end repeat
            end repeat
        end tell
    else
        tell application "Xcode"
            if buildConfigurationName is missing value then
                set value of build setting buildSettingName of every build configuration of every project to buildSettingValue
            else
                set value of build setting buildSettingName of (every build configuration whose name is buildConfigurationName) of every project to buildSettingValue
            end if
        end tell
    end if
end setBuildSetting

You can download it here.

See also: @schwa's script for enabling Cocoa debugging options.

software-quality xcode applescript Nov 8 2009