diff --git a/Podfile b/Podfile index c7a904233..09108e238 100644 --- a/Podfile +++ b/Podfile @@ -52,48 +52,9 @@ target 'SignalMessaging' do end post_install do |installer| - # Disable some asserts when building for tests - set_building_for_tests_config(installer, 'SignalServiceKit') - disable_optimizations_for_tests(installer) enable_extension_support_for_purelayout(installer) end -# There are some asserts and debug checks that make testing difficult - e.g. Singleton asserts -def set_building_for_tests_config(installer, target_name) - target = installer.pods_project.targets.detect { |target| target.to_s == target_name } - if target == nil - throw "failed to find target: #{target_name}" - end - - build_config_name = "Test" - build_config = target.build_configurations.detect { |config| config.to_s == build_config_name } - if build_config == nil - throw "failed to find config: #{build_config_name} for target: #{target_name}" - end - - puts "--[!] Disabling singleton enforcement for target: #{target} in config: #{build_config}" - existing_definitions = build_config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] - - if existing_definitions == nil || existing.length == 0 - existing_definitions = "$(inheritied)" - end - build_config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = "#{existing_definitions} POD_CONFIGURATION_TEST=1 COCOAPODS=1 SSK_BUILDING_FOR_TESTS=1" -end - -def disable_optimizations_for_tests(installer) - installer.pods_project.targets.each do | target| - build_config_name = "Test" - build_config = target.build_configurations.detect { |config| config.to_s == build_config_name } - if build_config == nil - throw "failed to find config: #{build_config_name} for target: #{target_name}" - end - - # Allow accurate step-thru debugging while in tests - build_config.build_settings['GCC_OPTIMIZATION_LEVEL'] = '0' - build_config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = '-Onone' - end -end - # PureLayout by default makes use of UIApplication, and must be configured to be built for an extension. def enable_extension_support_for_purelayout(installer) installer.pods_project.targets.each do |target| diff --git a/Podfile.lock b/Podfile.lock index 1bf3842c6..bcbb057b7 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -237,6 +237,6 @@ SPEC CHECKSUMS: YapDatabase: 299a32de9d350d37a9ac5b0532609d87d5d2a5de YYImage: 1e1b62a9997399593e4b9c4ecfbbabbf1d3f3b54 -PODFILE CHECKSUM: 497de356704a8d141a2dd132ab5c7fa4acffe2b6 +PODFILE CHECKSUM: 66640e0d5c06e9fb855faf7f6a8a3e9915eb5b78 COCOAPODS: 1.5.3 diff --git a/Pods b/Pods index a9402f6cc..727e25451 160000 --- a/Pods +++ b/Pods @@ -1 +1 @@ -Subproject commit a9402f6cc03285da65da62e14eeb1efc848267b3 +Subproject commit 727e254519570775e82fc9ae3a2c50e2d1cd45a4 diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index b9d115406..6cd95074f 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -3505,204 +3505,6 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ - 451DA3CC1F152887008E2423 /* Test */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_RECEIVER_WEAK = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__ARC_BRIDGE_CAST_NONARC = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; - ENABLE_BITCODE = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_NO_COMMON_BLOCKS = YES; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - "GCC_PREPROCESSOR_DEFINITIONS[arch=*]" = ( - "DEBUG=1", - "$(inherited)", - "SSK_BUILDING_FOR_TESTS=1", - ); - GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; - GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES; - GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; - GCC_WARN_ABOUT_MISSING_NEWLINE = YES; - GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; - GCC_WARN_ABOUT_POINTER_SIGNEDNESS = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_ALLOW_INCOMPLETE_PROTOCOL = YES; - GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; - GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_MISSING_PARENTHESES = YES; - GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = YES; - GCC_WARN_SHADOW = YES; - GCC_WARN_SIGN_COMPARE = YES; - GCC_WARN_STRICT_SELECTOR_MATCH = YES; - GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; - GCC_WARN_UNKNOWN_PRAGMAS = YES; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_LABEL = YES; - GCC_WARN_UNUSED_VALUE = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ""; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - ONLY_ACTIVE_ARCH = YES; - OTHER_CFLAGS = "-fobjc-arc-exceptions"; - SDKROOT = iphoneos; - SWIFT_VERSION = 4.0; - VALIDATE_PRODUCT = YES; - }; - name = Test; - }; - 451DA3CD1F152887008E2423 /* Test */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 1CE3CD5C23334683BDD3D78C /* Pods-Signal.test.xcconfig */; - buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_ENTITLEMENTS = Signal/Signal.entitlements; - CODE_SIGN_IDENTITY = "iPhone Developer"; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = U68MSDN6DR; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(SRCROOT)", - "$(PROJECT_DIR)/Carthage/Build/iOS", - ); - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "Signal/Signal-Prefix.pch"; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - HAVE_CONFIG_H, - ); - GCC_STRICT_ALIASING = NO; - GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; - GCC_WARN_STRICT_SELECTOR_MATCH = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - "\"${SRCROOT}/RedPhone/lib/ogg/include\"", - "\"${SRCROOT}/RedPhone/lib/debug/include\"", - "\"$(SRCROOT)/libtommath\"", - "\"$(SRCROOT)/libtomcrypt/headers\"", - "\"$(SRCROOT)/MMDrawerController\"", - "\"$(SRCROOT)/Libraries\"/**", - ); - INFOPLIST_FILE = "$(SRCROOT)/Signal/Signal-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(SRCROOT)", - ); - LLVM_LTO = NO; - OTHER_LDFLAGS = "$(inherited)"; - PRODUCT_BUNDLE_IDENTIFIER = org.whispersystems.signal; - PRODUCT_NAME = Signal; - PROVISIONING_PROFILE = ""; - PROVISIONING_PROFILE_SPECIFIER = ""; - SDKROOT = iphoneos; - SWIFT_OBJC_BRIDGING_HEADER = "Signal/src/Signal-Bridging-Header.h"; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_SWIFT3_OBJC_INFERENCE = Off; - SWIFT_VERSION = 4.0; - TEST_AFTER_BUILD = YES; - VALID_ARCHS = "arm64 armv7 armv7s"; - WRAPPER_EXTENSION = app; - }; - name = Test; - }; - 451DA3CE1F152887008E2423 /* Test */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 8981C8F64D94D3C52EB67A2C /* Pods-SignalTests.test.xcconfig */; - buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; - BUNDLE_LOADER = "$(TEST_HOST)"; - CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES; - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEFINES_MODULE = YES; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(SRCROOT)", - "$(PROJECT_DIR)/Carthage/Build/iOS", - ); - GCC_GENERATE_TEST_COVERAGE_FILES = NO; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "Signal/Signal-Prefix.pch"; - GCC_VERSION = ""; - GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; - GCC_WARN_STRICT_SELECTOR_MATCH = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; - HEADER_SEARCH_PATHS = ( - "${PODS_HEADERS_SEARCH_PATHS}", - "$(inherited)", - "\"${SRCROOT}/Signal/lib/speex/include\"", - "\"${SRCROOT}/Signal/lib/ogg/include\"", - "\"${SRCROOT}/Signal/lib/debug/include\"", - "\"$(SRCROOT)/libtommath\"", - "\"$(SRCROOT)/libtomcrypt/headers\"", - "\"$(SRCROOT)/spandsp/spandsp/spandsp\"", - "\"$(SRCROOT)/Libraries\"/**", - "\"$(TARGET_TEMP_DIR)/../$(PROJECT_NAME).build/DerivedSources\"", - ); - INFOPLIST_FILE = "Signal/test/Supporting Files/SignalTests-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(SRCROOT)", - ); - OTHER_LDFLAGS = ( - "-all_load", - "-ObjC", - "$(inherited)", - ); - PRODUCT_BUNDLE_IDENTIFIER = "org.whispersystems.${PRODUCT_NAME:rfc1034identifier}"; - PRODUCT_NAME = SignalTests; - PROVISIONING_PROFILE = ""; - SWIFT_OBJC_BRIDGING_HEADER = "Signal/test/SignalTests-Bridging-Header.h"; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_SWIFT3_OBJC_INFERENCE = Off; - SWIFT_VERSION = 4.0; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Signal.app/Signal"; - VALID_ARCHS = "arm64 armv7s armv7 i386 x86_64"; - }; - name = Test; - }; 453518731FC635DD00210559 /* Debug */ = { isa = XCBuildConfiguration; baseConfigurationReference = 69349DE607F5BA6036C9AC60 /* Pods-SignalShareExtension.debug.xcconfig */; @@ -3752,76 +3554,6 @@ }; name = Debug; }; - 453518741FC635DD00210559 /* Test */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 1C93CF3971B64E8B6C1F9AC1 /* Pods-SignalShareExtension.test.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_ENTITLEMENTS = SignalShareExtension/SignalShareExtension.entitlements; - CODE_SIGN_IDENTITY = "iPhone Developer"; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DEVELOPMENT_TEAM = U68MSDN6DR; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Carthage/Build/iOS", - ); - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "SignalShareExtension/SignalShareExtension-Prefix.pch"; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - INFOPLIST_FILE = SignalShareExtension/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MTL_ENABLE_DEBUG_INFO = NO; - PRODUCT_BUNDLE_IDENTIFIER = org.whispersystems.signal.shareextension; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = iphoneos; - SKIP_INSTALL = YES; - SWIFT_OBJC_BRIDGING_HEADER = "SignalShareExtension/SignalShareExtension-Bridging-Header.h"; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.0; - TARGETED_DEVICE_FAMILY = 1; - VALIDATE_PRODUCT = YES; - }; - name = Test; - }; 453518751FC635DD00210559 /* App Store Release */ = { isa = XCBuildConfiguration; baseConfigurationReference = 435EAC2E5E22D3F087EB3192 /* Pods-SignalShareExtension.app store release.xcconfig */; @@ -3949,85 +3681,6 @@ }; name = Debug; }; - 4535189C1FC63DBF00210559 /* Test */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 948239851C08032C842937CC /* Pods-SignalMessaging.test.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - APPLICATION_EXTENSION_API_ONLY = YES; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = ""; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = U68MSDN6DR; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Carthage/Build/iOS", - ); - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "SignalMessaging/SignalMessaging-Prefix.pch"; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - INFOPLIST_FILE = SignalMessaging/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MTL_ENABLE_DEBUG_INFO = NO; - PRODUCT_BUNDLE_IDENTIFIER = org.whispersystems.signal.SignalMessaging; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - SDKROOT = iphoneos; - SKIP_INSTALL = YES; - SWIFT_OBJC_BRIDGING_HEADER = ""; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_SWIFT3_OBJC_INFERENCE = Off; - SWIFT_VERSION = 4.0; - TARGETED_DEVICE_FAMILY = "1,2"; - VALIDATE_PRODUCT = YES; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Test; - }; 4535189D1FC63DBF00210559 /* App Store Release */ = { isa = XCBuildConfiguration; baseConfigurationReference = 8EEE74B0753448C085B48721 /* Pods-SignalMessaging.app store release.xcconfig */; @@ -4253,7 +3906,13 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ADDRESS_SANITIZER_CONTAINER_OVERFLOW = YES; + CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES; CLANG_ENABLE_MODULES = YES; + CLANG_UNDEFINED_BEHAVIOR_SANITIZER_INTEGER = YES; + CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES; CODE_SIGN_ENTITLEMENTS = Signal/Signal.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -4298,6 +3957,7 @@ PRODUCT_NAME = Signal; PROVISIONING_PROFILE = ""; PROVISIONING_PROFILE_SPECIFIER = ""; + RUN_CLANG_STATIC_ANALYZER = YES; SDKROOT = iphoneos; SWIFT_OBJC_BRIDGING_HEADER = "Signal/src/Signal-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -4315,6 +3975,10 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ADDRESS_SANITIZER_CONTAINER_OVERFLOW = NO; + CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Signal/Signal.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; @@ -4359,6 +4023,7 @@ PRODUCT_BUNDLE_IDENTIFIER = org.whispersystems.signal; PRODUCT_NAME = Signal; PROVISIONING_PROFILE = ""; + RUN_CLANG_STATIC_ANALYZER = YES; SDKROOT = iphoneos; SWIFT_OBJC_BRIDGING_HEADER = "Signal/src/Signal-Bridging-Header.h"; SWIFT_SWIFT3_OBJC_INFERENCE = Off; @@ -4495,7 +4160,6 @@ isa = XCConfigurationList; buildConfigurations = ( 453518731FC635DD00210559 /* Debug */, - 453518741FC635DD00210559 /* Test */, 453518751FC635DD00210559 /* App Store Release */, ); defaultConfigurationIsVisible = 0; @@ -4505,7 +4169,6 @@ isa = XCConfigurationList; buildConfigurations = ( 4535189B1FC63DBF00210559 /* Debug */, - 4535189C1FC63DBF00210559 /* Test */, 4535189D1FC63DBF00210559 /* App Store Release */, ); defaultConfigurationIsVisible = 0; @@ -4515,7 +4178,6 @@ isa = XCConfigurationList; buildConfigurations = ( D221A0BA169C9E5F00537ABF /* Debug */, - 451DA3CC1F152887008E2423 /* Test */, D221A0BB169C9E5F00537ABF /* App Store Release */, ); defaultConfigurationIsVisible = 0; @@ -4525,7 +4187,6 @@ isa = XCConfigurationList; buildConfigurations = ( D221A0BD169C9E5F00537ABF /* Debug */, - 451DA3CD1F152887008E2423 /* Test */, D221A0BE169C9E5F00537ABF /* App Store Release */, ); defaultConfigurationIsVisible = 0; @@ -4535,7 +4196,6 @@ isa = XCConfigurationList; buildConfigurations = ( D221A0C0169C9E5F00537ABF /* Debug */, - 451DA3CE1F152887008E2423 /* Test */, D221A0C1169C9E5F00537ABF /* App Store Release */, ); defaultConfigurationIsVisible = 0; diff --git a/Signal.xcodeproj/xcshareddata/xcschemes/Signal.xcscheme b/Signal.xcodeproj/xcshareddata/xcschemes/Signal.xcscheme index fdde62597..7dd0b1819 100644 --- a/Signal.xcodeproj/xcshareddata/xcschemes/Signal.xcscheme +++ b/Signal.xcodeproj/xcshareddata/xcschemes/Signal.xcscheme @@ -37,7 +37,7 @@ @@ -76,6 +76,9 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + enableAddressSanitizer = "YES" + enableASanStackUseAfterReturn = "YES" + enableUBSanitizer = "YES" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index 083c4b8fb..1b4f31e50 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -278,6 +278,7 @@ static NSTimeInterval launchStartedAt; } OWSBackgroundTask *_Nullable backgroundTask = [OWSBackgroundTask backgroundTaskWithLabelStr:__PRETTY_FUNCTION__]; + SUPPRESS_DEADSTORE_WARNING(backgroundTask); if ([NSFileManager.defaultManager fileExistsAtPath:OWSPrimaryStorage.legacyDatabaseFilePath]) { DDLogInfo(@"%@ Legacy Database file size: %@", @@ -925,7 +926,7 @@ static NSTimeInterval launchStartedAt; - (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification - completionHandler:(void (^)(void))completionHandler + completionHandler:(void (^)())completionHandler { OWSAssertIsOnMainThread(); diff --git a/Signal/src/ViewControllers/AppSettings/AppSettingsViewController.m b/Signal/src/ViewControllers/AppSettings/AppSettingsViewController.m index 225fb3bf1..480673d7f 100644 --- a/Signal/src/ViewControllers/AppSettings/AppSettingsViewController.m +++ b/Signal/src/ViewControllers/AppSettings/AppSettingsViewController.m @@ -204,6 +204,7 @@ // TODO: Always show backup when we go to production. BOOL isBackupEnabled = [OWSBackup.sharedManager isBackupEnabled]; BOOL showBackup = isBackupEnabled; + SUPPRESS_DEADSTORE_WARNING(showBackup); #ifdef DEBUG showBackup = YES; #endif diff --git a/Signal/src/ViewControllers/AppSettings/NotificationSettingsOptionsViewController.m b/Signal/src/ViewControllers/AppSettings/NotificationSettingsOptionsViewController.m index 5944955a0..9c1b736df 100644 --- a/Signal/src/ViewControllers/AppSettings/NotificationSettingsOptionsViewController.m +++ b/Signal/src/ViewControllers/AppSettings/NotificationSettingsOptionsViewController.m @@ -11,6 +11,8 @@ - (void)viewDidLoad { + [super viewDidLoad]; + [self updateTableContents]; } diff --git a/Signal/src/ViewControllers/AppSettings/NotificationSettingsViewController.m b/Signal/src/ViewControllers/AppSettings/NotificationSettingsViewController.m index 62fd0b92c..bfd45930d 100644 --- a/Signal/src/ViewControllers/AppSettings/NotificationSettingsViewController.m +++ b/Signal/src/ViewControllers/AppSettings/NotificationSettingsViewController.m @@ -22,6 +22,8 @@ - (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; + [self updateTableContents]; } diff --git a/Signal/src/ViewControllers/AppSettings/OWSBackupSettingsViewController.m b/Signal/src/ViewControllers/AppSettings/OWSBackupSettingsViewController.m index 9a991967f..68139aa8a 100644 --- a/Signal/src/ViewControllers/AppSettings/OWSBackupSettingsViewController.m +++ b/Signal/src/ViewControllers/AppSettings/OWSBackupSettingsViewController.m @@ -45,6 +45,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; [self updateTableContents]; } diff --git a/Signal/src/ViewControllers/AppSettings/OWSLinkedDevicesTableViewController.m b/Signal/src/ViewControllers/AppSettings/OWSLinkedDevicesTableViewController.m index 928adc51a..9a4878119 100644 --- a/Signal/src/ViewControllers/AppSettings/OWSLinkedDevicesTableViewController.m +++ b/Signal/src/ViewControllers/AppSettings/OWSLinkedDevicesTableViewController.m @@ -312,7 +312,7 @@ int const OWSLinkedDevicesTableViewControllerSectionAddDevice = 1; return cell; } else { DDLogError(@"Unknown section: %@", indexPath); - return nil; + return [UITableViewCell new]; } } diff --git a/Signal/src/ViewControllers/AppSettings/OWSSoundSettingsViewController.m b/Signal/src/ViewControllers/AppSettings/OWSSoundSettingsViewController.m index 1a65c77af..ed1addd87 100644 --- a/Signal/src/ViewControllers/AppSettings/OWSSoundSettingsViewController.m +++ b/Signal/src/ViewControllers/AppSettings/OWSSoundSettingsViewController.m @@ -38,6 +38,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; + [self updateTableContents]; } diff --git a/Signal/src/ViewControllers/AppSettings/PrivacySettingsTableViewController.m b/Signal/src/ViewControllers/AppSettings/PrivacySettingsTableViewController.m index 96cda65f7..0fb95b8ed 100644 --- a/Signal/src/ViewControllers/AppSettings/PrivacySettingsTableViewController.m +++ b/Signal/src/ViewControllers/AppSettings/PrivacySettingsTableViewController.m @@ -30,6 +30,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; + [self updateTableContents]; } diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m index 065d8e2c6..7aff79484 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m @@ -331,7 +331,9 @@ NS_ASSUME_NONNULL_BEGIN OWSAssert(self.quotedTextLabel); UIColor *textColor = self.quotedTextColor; + SUPPRESS_DEADSTORE_WARNING(textColor); UIFont *font = self.quotedTextFont; + SUPPRESS_DEADSTORE_WARNING(font); NSString *text = @""; NSString *_Nullable fileTypeForSnippet = [self fileTypeForSnippet]; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index e8f04599d..8a1f71ab0 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -1413,13 +1413,12 @@ typedef enum : NSUInteger { UIColor *subtitleColor = [UIColor.ows_navbarTitleColor colorWithAlphaComponent:(CGFloat)0.9]; if (self.thread.isMuted) { // Show a "mute" icon before the navigation bar subtitle if this thread is muted. - [subtitleText - appendAttributedString:[[NSAttributedString alloc] - initWithString:@"\ue067 " - attributes:@{ - NSFontAttributeName : [UIFont ows_elegantIconsFont:7.f], - NSForegroundColorAttributeName : subtitleColor - }]]; + [subtitleText appendAttributedString:[[NSAttributedString alloc] + initWithString:LocalizationNotNeeded(@"\ue067 ") + attributes:@{ + NSFontAttributeName : [UIFont ows_elegantIconsFont:7.f], + NSForegroundColorAttributeName : subtitleColor + }]]; } BOOL isVerified = YES; @@ -1432,13 +1431,12 @@ typedef enum : NSUInteger { } if (isVerified) { // Show a "checkmark" icon before the navigation bar subtitle if this thread is verified. - [subtitleText - appendAttributedString:[[NSAttributedString alloc] - initWithString:@"\uf00c " - attributes:@{ - NSFontAttributeName : [UIFont ows_fontAwesomeFont:10.f], - NSForegroundColorAttributeName : subtitleColor, - }]]; + [subtitleText appendAttributedString:[[NSAttributedString alloc] + initWithString:LocalizationNotNeeded(@"\uf00c ") + attributes:@{ + NSFontAttributeName : [UIFont ows_fontAwesomeFont:10.f], + NSForegroundColorAttributeName : subtitleColor, + }]]; } if (self.userLeftGroup) { @@ -1862,20 +1860,24 @@ typedef enum : NSUInteger { [self presentViewController:actionSheetController animated:YES completion:nil]; } -- (void)tappedNonBlockingIdentityChangeForRecipientId:(nullable NSString *)signalId +- (void)tappedNonBlockingIdentityChangeForRecipientId:(nullable NSString *)signalIdParam { - if (signalId == nil) { + if (signalIdParam == nil) { if (self.thread.isGroupThread) { // Before 2.13 we didn't track the recipient id in the identity change error. DDLogWarn(@"%@ Ignoring tap on legacy nonblocking identity change since it has no signal id", self.logTag); + return; + } else { DDLogInfo( @"%@ Assuming tap on legacy nonblocking identity change corresponds to current contact thread: %@", self.logTag, self.thread.contactIdentifier); - signalId = self.thread.contactIdentifier; + signalIdParam = self.thread.contactIdentifier; } } + + NSString *signalId = signalIdParam; [self showFingerprintWithRecipientId:signalId]; } diff --git a/Signal/src/ViewControllers/HomeView/HomeViewCell.m b/Signal/src/ViewControllers/HomeView/HomeViewCell.m index 760f88c6b..f9ecd330c 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewCell.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewCell.m @@ -371,7 +371,7 @@ NS_ASSUME_NONNULL_BEGIN } else { if ([thread isMuted]) { [snippetText appendAttributedString:[[NSAttributedString alloc] - initWithString:@"\ue067 " + initWithString:LocalizationNotNeeded(@"\ue067 ") attributes:@{ NSFontAttributeName : [UIFont ows_elegantIconsFont:9.f], NSForegroundColorAttributeName : diff --git a/Signal/src/ViewControllers/NewContactThreadViewController.m b/Signal/src/ViewControllers/NewContactThreadViewController.m index 43c07c30f..3d10efb7c 100644 --- a/Signal/src/ViewControllers/NewContactThreadViewController.m +++ b/Signal/src/ViewControllers/NewContactThreadViewController.m @@ -907,7 +907,7 @@ NS_ASSUME_NONNULL_BEGIN return result; } -- (NSString *)callingCodeForPossiblePhoneNumber:(NSString *)phoneNumber +- (nullable NSString *)callingCodeForPossiblePhoneNumber:(NSString *)phoneNumber { OWSAssert([phoneNumber hasPrefix:@"+"]); @@ -924,7 +924,7 @@ NS_ASSUME_NONNULL_BEGIN NSString *searchText = self.searchBar.text; if (searchText.length < 8) { - return nil; + return @[]; } NSMutableSet *parsedPhoneNumbers = [NSMutableSet new]; @@ -935,7 +935,7 @@ NS_ASSUME_NONNULL_BEGIN NSString *phoneNumberString = phoneNumber.toE164; // Ignore phone numbers with an unrecognized calling code. - NSString *callingCode = [self callingCodeForPossiblePhoneNumber:phoneNumberString]; + NSString *_Nullable callingCode = [self callingCodeForPossiblePhoneNumber:phoneNumberString]; if (!callingCode) { continue; } diff --git a/Signal/src/ViewControllers/Registration/CodeVerificationViewController.m b/Signal/src/ViewControllers/Registration/CodeVerificationViewController.m index 11750638b..b84aaa510 100644 --- a/Signal/src/ViewControllers/Registration/CodeVerificationViewController.m +++ b/Signal/src/ViewControllers/Registration/CodeVerificationViewController.m @@ -329,7 +329,7 @@ NS_ASSUME_NONNULL_BEGIN [alert addAction:[UIAlertAction actionWithTitle:CommonStrings.dismissButton style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { - [_challengeTextField becomeFirstResponder]; + [self.challengeTextField becomeFirstResponder]; }]]; [self presentViewController:alert animated:YES completion:nil]; diff --git a/Signal/src/ViewControllers/ThreadSettings/FingerprintViewController.m b/Signal/src/ViewControllers/ThreadSettings/FingerprintViewController.m index f202bee29..446e8154b 100644 --- a/Signal/src/ViewControllers/ThreadSettings/FingerprintViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/FingerprintViewController.m @@ -354,7 +354,7 @@ typedef void (^CustomLayoutBlock)(void); // Show a "checkmark" if this user is verified. [labelText appendAttributedString:[[NSAttributedString alloc] - initWithString:@"\uf00c " + initWithString:LocalizationNotNeeded(@"\uf00c ") attributes:@{ NSFontAttributeName : [UIFont ows_fontAwesomeFont:self.verificationStateLabel.font.pointSize], @@ -383,7 +383,7 @@ typedef void (^CustomLayoutBlock)(void); // Show a "checkmark" if this user is not verified. [buttonText appendAttributedString:[[NSAttributedString alloc] - initWithString:@"\uf00c " + initWithString:LocalizationNotNeeded(@"\uf00c ") attributes:@{ NSFontAttributeName : [UIFont ows_fontAwesomeFont:self.verifyUnverifyButtonLabel.font.pointSize], diff --git a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m index 112662c78..33983ab71 100644 --- a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m @@ -786,7 +786,7 @@ const CGFloat kIconViewLength = 24; NSMutableAttributedString *subtitle = [NSMutableAttributedString new]; // "checkmark" [subtitle appendAttributedString:[[NSAttributedString alloc] - initWithString:@"\uf00c " + initWithString:LocalizationNotNeeded(@"\uf00c ") attributes:@{ NSFontAttributeName : [UIFont ows_fontAwesomeFont:kSubtitlePointSize], diff --git a/SignalServiceKit/src/Storage/OWSOrphanedDataCleaner.m b/SignalServiceKit/src/Storage/OWSOrphanedDataCleaner.m index de92950e4..64360c25c 100644 --- a/SignalServiceKit/src/Storage/OWSOrphanedDataCleaner.m +++ b/SignalServiceKit/src/Storage/OWSOrphanedDataCleaner.m @@ -15,14 +15,6 @@ NS_ASSUME_NONNULL_BEGIN -#ifdef SSK_BUILDING_FOR_TESTS -#define CleanupLogDebug NSLog -#define CleanupLogInfo NSLog -#else -#define CleanupLogDebug DDLogDebug -#define CleanupLogInfo DDLogInfo -#endif - @implementation OWSOrphanedDataCleaner + (void)auditAsync @@ -83,20 +75,18 @@ NS_ASSUME_NONNULL_BEGIN }]; }]; - CleanupLogDebug(@"%@ fileCount: %lu", self.logTag, (unsigned long)fileCount); - CleanupLogDebug(@"%@ totalFileSize: %lld", self.logTag, totalFileSize); - CleanupLogDebug(@"%@ attachmentStreams: %d", self.logTag, attachmentStreamCount); - CleanupLogDebug( - @"%@ attachmentStreams with file paths: %lu", self.logTag, (unsigned long)attachmentFilePaths.count); + DDLogDebug(@"%@ fileCount: %lu", self.logTag, (unsigned long)fileCount); + DDLogDebug(@"%@ totalFileSize: %lld", self.logTag, totalFileSize); + DDLogDebug(@"%@ attachmentStreams: %d", self.logTag, attachmentStreamCount); + DDLogDebug(@"%@ attachmentStreams with file paths: %lu", self.logTag, (unsigned long)attachmentFilePaths.count); NSMutableSet *orphanDiskFilePaths = [diskFilePaths mutableCopy]; [orphanDiskFilePaths minusSet:attachmentFilePaths]; NSMutableSet *missingAttachmentFilePaths = [attachmentFilePaths mutableCopy]; [missingAttachmentFilePaths minusSet:diskFilePaths]; - CleanupLogDebug(@"%@ orphan disk file paths: %lu", self.logTag, (unsigned long)orphanDiskFilePaths.count); - CleanupLogDebug( - @"%@ missing attachment file paths: %lu", self.logTag, (unsigned long)missingAttachmentFilePaths.count); + DDLogDebug(@"%@ orphan disk file paths: %lu", self.logTag, (unsigned long)orphanDiskFilePaths.count); + DDLogDebug(@"%@ missing attachment file paths: %lu", self.logTag, (unsigned long)missingAttachmentFilePaths.count); [self printPaths:orphanDiskFilePaths.allObjects label:@"orphan disk file paths"]; [self printPaths:missingAttachmentFilePaths.allObjects label:@"missing attachment file paths"]; @@ -142,12 +132,12 @@ NS_ASSUME_NONNULL_BEGIN }]; }]; - CleanupLogDebug(@"%@ attachmentIds: %lu", self.logTag, (unsigned long)attachmentIds.count); - CleanupLogDebug(@"%@ messageAttachmentIds: %lu", self.logTag, (unsigned long)messageAttachmentIds.count); - CleanupLogDebug(@"%@ quotedReplyThumbnailAttachmentIds: %lu", + DDLogDebug(@"%@ attachmentIds: %lu", self.logTag, (unsigned long)attachmentIds.count); + DDLogDebug(@"%@ messageAttachmentIds: %lu", self.logTag, (unsigned long)messageAttachmentIds.count); + DDLogDebug(@"%@ quotedReplyThumbnailAttachmentIds: %lu", self.logTag, (unsigned long)quotedReplyThumbnailAttachmentIds.count); - CleanupLogDebug( + DDLogDebug( @"%@ contactShareAvatarAttachmentIds: %lu", self.logTag, (unsigned long)contactShareAvatarAttachmentIds.count); NSMutableSet *orphanAttachmentIds = [attachmentIds mutableCopy]; @@ -157,17 +147,14 @@ NS_ASSUME_NONNULL_BEGIN NSMutableSet *missingAttachmentIds = [messageAttachmentIds mutableCopy]; [missingAttachmentIds minusSet:attachmentIds]; - CleanupLogDebug(@"%@ orphan attachmentIds: %lu", self.logTag, (unsigned long)orphanAttachmentIds.count); - CleanupLogDebug(@"%@ missing attachmentIds: %lu", self.logTag, (unsigned long)missingAttachmentIds.count); - CleanupLogDebug(@"%@ orphan interactions: %lu", self.logTag, (unsigned long)orphanInteractionIds.count); + DDLogDebug(@"%@ orphan attachmentIds: %lu", self.logTag, (unsigned long)orphanAttachmentIds.count); + DDLogDebug(@"%@ missing attachmentIds: %lu", self.logTag, (unsigned long)missingAttachmentIds.count); + DDLogDebug(@"%@ orphan interactions: %lu", self.logTag, (unsigned long)orphanInteractionIds.count); // We need to avoid cleaning up new attachments and files that are still in the process of // being created/written, so we don't clean up anything recent. -#ifdef SSK_BUILDING_FOR_TESTS - const NSTimeInterval kMinimumOrphanAge = 0.f; -#else - const NSTimeInterval kMinimumOrphanAge = 15 * kMinuteInterval; -#endif + + const NSTimeInterval kMinimumOrphanAge = CurrentAppContext().isRunningTests ? 0.f : 15 * kMinuteInterval; if (!shouldCleanup) { return; @@ -181,7 +168,7 @@ NS_ASSUME_NONNULL_BEGIN OWSFail(@"%@ Could not load interaction: %@", self.logTag, interactionId); continue; } - CleanupLogInfo(@"%@ Removing orphan message: %@", self.logTag, interaction.uniqueId); + DDLogInfo(@"%@ Removing orphan message: %@", self.logTag, interaction.uniqueId); [interaction removeWithTransaction:transaction]; } for (NSString *attachmentId in orphanAttachmentIds) { @@ -198,11 +185,12 @@ NS_ASSUME_NONNULL_BEGIN TSAttachmentStream *attachmentStream = (TSAttachmentStream *)attachment; // Don't delete attachments which were created in the last N minutes. if (fabs([attachmentStream.creationTimestamp timeIntervalSinceNow]) < kMinimumOrphanAge) { - CleanupLogInfo(@"%@ Skipping orphan attachment due to age: %f", self.logTag, + DDLogInfo(@"%@ Skipping orphan attachment due to age: %f", + self.logTag, fabs([attachmentStream.creationTimestamp timeIntervalSinceNow])); continue; } - CleanupLogInfo(@"%@ Removing orphan attachmentStream from DB: %@", self.logTag, attachmentStream.uniqueId); + DDLogInfo(@"%@ Removing orphan attachmentStream from DB: %@", self.logTag, attachmentStream.uniqueId); [attachmentStream removeWithTransaction:transaction]; } }]; @@ -216,12 +204,13 @@ NS_ASSUME_NONNULL_BEGIN } // Don't delete files which were created in the last N minutes. if (fabs([attributes.fileModificationDate timeIntervalSinceNow]) < kMinimumOrphanAge) { - CleanupLogInfo(@"%@ Skipping orphan attachment file due to age: %f", self.logTag, + DDLogInfo(@"%@ Skipping orphan attachment file due to age: %f", + self.logTag, fabs([attributes.fileModificationDate timeIntervalSinceNow])); continue; } - CleanupLogInfo(@"%@ Deleting orphan attachment file: %@", self.logTag, filePath); + DDLogInfo(@"%@ Deleting orphan attachment file: %@", self.logTag, filePath); [[NSFileManager defaultManager] removeItemAtPath:filePath error:&error]; if (error) { OWSFail(@"%@ Could not remove orphan file at: %@", self.logTag, filePath); @@ -238,14 +227,14 @@ NS_ASSUME_NONNULL_BEGIN + (void)printPaths:(NSArray *)paths label:(NSString *)label { for (NSString *path in [paths sortedArrayUsingSelector:@selector(compare:)]) { - CleanupLogDebug(@"%@ %@: %@", self.logTag, label, path); + DDLogDebug(@"%@ %@: %@", self.logTag, label, path); } } + (NSSet *)filePathsInAttachmentsFolder { NSString *attachmentsFolder = [TSAttachmentStream attachmentsFolder]; - CleanupLogDebug(@"%@ attachmentsFolder: %@", self.logTag, attachmentsFolder); + DDLogDebug(@"%@ attachmentsFolder: %@", self.logTag, attachmentsFolder); return [self filePathsInDirectory:attachmentsFolder]; } diff --git a/SignalServiceKit/src/Util/OWSAsserts.h b/SignalServiceKit/src/Util/OWSAsserts.h index 6752e6eea..db908206a 100755 --- a/SignalServiceKit/src/Util/OWSAsserts.h +++ b/SignalServiceKit/src/Util/OWSAsserts.h @@ -2,6 +2,8 @@ // Copyright (c) 2018 Open Whisper Systems. All rights reserved. // +#import "AppContext.h" + NS_ASSUME_NONNULL_BEGIN #ifndef OWSAssert @@ -89,12 +91,10 @@ NS_ASSUME_NONNULL_BEGIN // 1. Use OWSSingletonAssertFlag() outside the class definition. // 2. Use OWSSingletonAssertInit() in each initializer. -#ifndef SSK_BUILDING_FOR_TESTS #ifdef DEBUG #define ENFORCE_SINGLETONS -#endif #endif #ifdef ENFORCE_SINGLETONS @@ -104,8 +104,10 @@ NS_ASSUME_NONNULL_BEGIN #define OWSSingletonAssertInit() \ @synchronized([self class]) \ { \ - OWSAssert(!_isSingletonCreated); \ - _isSingletonCreated = YES; \ + if (!CurrentAppContext().isRunningTests) { \ + OWSAssert(!_isSingletonCreated); \ + _isSingletonCreated = YES; \ + } \ } #define OWSSingletonAssert() OWSSingletonAssertFlag() OWSSingletonAssertInit() @@ -135,6 +137,19 @@ NS_ASSUME_NONNULL_BEGIN OWSCFail(_messageFormat, ##__VA_ARGS__); \ } + +// Avoids Clang analyzer warning: +// Value stored to 'x' during it's initialization is never read +#define SUPPRESS_DEADSTORE_WARNING(x) \ + do { \ + (void)x; \ + } while (0) + +__attribute__((annotate("returns_localized_nsstring"))) static inline NSString *LocalizationNotNeeded(NSString *s) +{ + return s; +} + // This function is intended for use in Swift. void SwiftAssertIsOnMainThread(NSString *functionName);