Skip to content

Instantly share code, notes, and snippets.

@steipete
Last active February 1, 2020 15:06
Show Gist options
  • Save steipete/d48dfb3b1d97f0037110 to your computer and use it in GitHub Desktop.
Save steipete/d48dfb3b1d97f0037110 to your computer and use it in GitHub Desktop.
The prelude to the warnings configuration we use in the PSPDFKit iOS framework - http://pspdfkit.com
//
// Defaults.xcconfig
//
// Common customizations/sanitizations of the platform defaults for our projects.
//
// For compatibility reasons, the iOS platform has a couple of not–so–sensible defaults.
// This file collects, and annotates the deviations from these defaults.
//
// :NOTE: Some of the settings herein may be redundant for newly created projects/targets:
// Xcode’s project/target templates take several (but not all!) of these issues into account.
// However, for uniformity it is probably more useful to simply delete the entire warning section in the Xcode project, and then set them up using the standard warning flags.
// :MARK: General Project Setup:
// :MARK: -Toolchain
// Universal Objective-C iOS Project
ARCHS = arm64 armv7 armv7s i386 x86_64
SDKROOT = iphoneos
CLANG_ENABLE_MODULES = YES
GCC_C_LANGUAGE_STANDARD = gnu99
GCC_DYNAMIC_NO_PIC = NO
CLANG_CXX_LANGUAGE_STANDARD = gnu++0x
CLANG_CXX_LIBRARY = libc++
OTHER_LDFLAGS = -ObjC
// :MARK: -Locations
ALWAYS_SEARCH_USER_PATHS = NO
DSTROOT = WHATEVER_MAKES_SENSE
EXCLUDED_RECURSIVE_SEARCH_PATH_SUBDIRECTORIES = *.bundle $(inherited)
FRAMEWORK_SEARCH_PATHS = "$(DSTROOT)" "$(CONFIGURATION_BUILD_DIR)" $(inherited)
HEADER_SEARCH_PATHS = "$(DSTROOT)" "$(CONFIGURATION_BUILD_DIR)" $(inherited)
LIBRARY_SEARCH_PATHS = "$(DSTROOT)" "$(CONFIGURATION_BUILD_DIR)" $(inherited)
// :MARK: -Custom Definitions/Macros
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) PSPDFEnableOpenSSLFeatures=1
// :MARK: - Reset Diagnostics:
ENABLE_STRICT_OBJC_MSGSEND = YES
// :MARK: -Warnings
// The iOS platform defaults **explicitly** disable several warnings.
// This defeats the purpose of Clangs `-Weverything`, which we want to use!
// Therefore, we explicitly enable all those warnings here.
// Disabling those we do **not** want then happens elsewhere — always in combination with a reason _why_ we don’t want/need it.
CLANG_WARN_DOCUMENTATION_COMMENTS = YES
CLANG_WARN_EMPTY_BODY = YES
GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES
GCC_WARN_SHADOW = YES
CLANG_WARN_CONSTANT_CONVERSION = YES
GCC_WARN_64_TO_32_BIT_CONVERSION = YES
CLANG_WARN_ENUM_CONVERSION = YES
CLANG_WARN_INT_CONVERSION = YES
CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES
GCC_WARN_ABOUT_MISSING_NEWLINE = YES
CLANG_WARN_ASSIGN_ENUM = YES
GCC_WARN_SIGN_COMPARE = YES
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES
GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE
GCC_WARN_UNKNOWN_PRAGMAS = YES
CLANG_WARN_UNREACHABLE_CODE = YES
GCC_WARN_UNUSED_FUNCTION = YES
GCC_WARN_UNUSED_LABEL = YES
GCC_WARN_UNUSED_PARAMETER = YES
GCC_WARN_UNUSED_VARIABLE = YES
CLANG_WARN__EXIT_TIME_DESTRUCTORS = YES
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES
CLANG_WARN_CXX0X_EXTENSIONS = YES
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES
GCC_WARN_UNDECLARED_SELECTOR = YES
GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = YES
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES
GCC_WARN_STRICT_SELECTOR_MATCH = YES
GCC_WARN_UNDECLARED_SELECTOR = YES
CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES
CLANG_WARN_OBJC_RECEIVER_WEAK = YES
// :MARK: -Static Analysis
// As with the warnings, reset all options that are explicitly disabled by the iOS platform defaults
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES
@steipete
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment