From d30112ec604413b6f32faf325551d9a1f16dd156 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Fri, 28 Mar 2025 14:08:57 +1100 Subject: [PATCH 1/3] Made a number of tweaks to make dev a little easier MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Added a mechanism to copy the database file path more easily for devs • Enabled ASAN when compiling libSession • Cleaned up a bunch of per-target project settings (not they are set once at the project level) • Updated the `os.Logger` calls to always be public (only in debug mode) --- Scripts/build_libSession_util.sh | 3 +- Session.xcodeproj/project.pbxproj | 119 +----------------- .../Session_CompileLibSession.xcscheme | 2 + .../Settings/DeveloperSettingsViewModel.swift | 24 ++++ SessionUtilitiesKit/Database/Storage.swift | 2 +- SessionUtilitiesKit/General/Logging.swift | 17 +-- 6 files changed, 45 insertions(+), 122 deletions(-) diff --git a/Scripts/build_libSession_util.sh b/Scripts/build_libSession_util.sh index 3190952e1..a3e2f8f01 100755 --- a/Scripts/build_libSession_util.sh +++ b/Scripts/build_libSession_util.sh @@ -163,6 +163,7 @@ REQUIRES_BUILD=0 if [ "${LIB_SESSION_SOURCE_DIR}" != "${OLD_SOURCE_DIR}" ]; then echo "Build is not up-to-date (source dir change) - removing old build and rebuilding" rm -rf "${COMPILE_DIR}" + mkdir -p "${COMPILE_DIR}" REQUIRES_BUILD=1 elif [ "${NEW_SOURCE_HASH}" != "${OLD_SOURCE_HASH}" ]; then echo "Build is not up-to-date (source change) - creating new build" @@ -234,7 +235,7 @@ if [ "${REQUIRES_BUILD}" == 1 ]; then submodule_check=ON build_type="Release" - if [ "$CONFIGURATION" == "Debug" ]; then + if [ "$CONFIGURATION" == "Debug" ] || [ "$CONFIGURATION" == "Debug_Compile_LibSession" ]; then submodule_check=OFF build_type="Debug" fi diff --git a/Session.xcodeproj/project.pbxproj b/Session.xcodeproj/project.pbxproj index b3fde4fe4..5f988cf92 100644 --- a/Session.xcodeproj/project.pbxproj +++ b/Session.xcodeproj/project.pbxproj @@ -6862,13 +6862,10 @@ 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 = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -6928,8 +6925,6 @@ 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 = SUQ8J2PCT7; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -6987,13 +6982,10 @@ 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 = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", "COCOAPODS=1", @@ -7056,8 +7048,6 @@ 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 = SUQ8J2PCT7; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -7115,8 +7105,6 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; DYLIB_COMPATIBILITY_VERSION = 1; @@ -7124,7 +7112,6 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; INFOPLIST_FILE = SessionUIKit/Meta/Info.plist; @@ -7186,8 +7173,6 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; DYLIB_COMPATIBILITY_VERSION = 1; @@ -7248,8 +7233,6 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; DYLIB_COMPATIBILITY_VERSION = 1; @@ -7257,7 +7240,6 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", "COCOAPODS=1", @@ -7326,8 +7308,6 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; DYLIB_COMPATIBILITY_VERSION = 1; @@ -7395,8 +7375,6 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; DYLIB_COMPATIBILITY_VERSION = 1; @@ -7404,7 +7382,6 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; INFOPLIST_FILE = SessionSnodeKit/Meta/Info.plist; @@ -7472,8 +7449,6 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; DYLIB_COMPATIBILITY_VERSION = 1; @@ -7540,8 +7515,6 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; DYLIB_COMPATIBILITY_VERSION = 1; @@ -7549,7 +7522,6 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; INFOPLIST_FILE = SessionUtilitiesKit/Meta/Info.plist; @@ -7616,8 +7588,6 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; DYLIB_COMPATIBILITY_VERSION = 1; @@ -7684,8 +7654,6 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; DYLIB_COMPATIBILITY_VERSION = 1; @@ -7693,7 +7661,6 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; INFOPLIST_FILE = SessionMessagingKit/Meta/Info.plist; @@ -7761,8 +7728,6 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; DYLIB_COMPATIBILITY_VERSION = 1; @@ -7839,12 +7804,14 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; COMPILE_LIB_SESSION = ""; + COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 563; ENABLE_BITCODE = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; ENABLE_USER_SCRIPT_SANDBOXING = NO; GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", @@ -7883,6 +7850,7 @@ OTHER_CFLAGS = "-Werror=protocol"; OTHER_SWIFT_FLAGS = "-D DEBUG -Xfrontend -warn-long-expression-type-checking=100"; SDKROOT = iphoneos; + STRIP_INSTALLED_PRODUCT = NO; SWIFT_VERSION = 5.0; VALIDATE_PRODUCT = YES; }; @@ -7986,7 +7954,6 @@ "$(inherited)", "$(SRCROOT)", ); - GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", @@ -8017,7 +7984,6 @@ "$(SRCROOT)", ); LLVM_LTO = NO; - OTHER_LDFLAGS = "$(inherited)"; OTHER_SWIFT_FLAGS = "$(inherited)"; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger"; PRODUCT_NAME = Session; @@ -8051,7 +8017,6 @@ "$(inherited)", "$(SRCROOT)", ); - GCC_OPTIMIZATION_LEVEL = 3; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -8082,7 +8047,6 @@ "$(SRCROOT)", ); LLVM_LTO = NO; - OTHER_LDFLAGS = "$(inherited)"; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger"; PRODUCT_NAME = Session; PROVISIONING_PROFILE = ""; @@ -8099,10 +8063,8 @@ FD2272502C32910F004D8A6C /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - COPY_PHASE_STRIP = NO; ENABLE_MODULE_VERIFIER = NO; GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; GENERATE_INFOPLIST_FILE = YES; PRODUCT_BUNDLE_IDENTIFIER = io.oxen.SessionSnodeKitTests; PRODUCT_NAME = SessionSnodeKitTests; @@ -8112,7 +8074,6 @@ FD2272512C32910F004D8A6C /* App_Store_Release */ = { isa = XCBuildConfiguration; buildSettings = { - COPY_PHASE_STRIP = NO; ENABLE_MODULE_VERIFIER = NO; GENERATE_INFOPLIST_FILE = YES; PRODUCT_BUNDLE_IDENTIFIER = io.oxen.SessionSnodeKitTests; @@ -8136,12 +8097,9 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = "$(inherited)"; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_MODULE_VERIFIER = NO; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GENERATE_INFOPLIST_FILE = YES; @@ -8191,8 +8149,6 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_MODULE_VERIFIER = NO; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -8236,12 +8192,9 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = "$(inherited)"; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_MODULE_VERIFIER = NO; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GENERATE_INFOPLIST_FILE = YES; @@ -8290,8 +8243,6 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_MODULE_VERIFIER = NO; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -8321,7 +8272,6 @@ FD860CBF2D6E981900BBE29C /* Debug_Compile_LibSession */ = { isa = XCBuildConfiguration; buildSettings = { - COPY_PHASE_STRIP = NO; PRODUCT_NAME = SessionSnodeKitTests; }; name = Debug_Compile_LibSession; @@ -8329,7 +8279,6 @@ FD860CC02D6E981900BBE29C /* App_Store_Release_Compile_LibSession */ = { isa = XCBuildConfiguration; buildSettings = { - COPY_PHASE_STRIP = NO; PRODUCT_NAME = SessionSnodeKitTests; }; name = App_Store_Release_Compile_LibSession; @@ -8350,12 +8299,9 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = "$(inherited)"; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_MODULE_VERIFIER = NO; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GENERATE_INFOPLIST_FILE = YES; @@ -8404,8 +8350,6 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_MODULE_VERIFIER = NO; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -8461,11 +8405,13 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; COMPILE_LIB_SESSION = YES; + COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 563; ENABLE_BITCODE = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", @@ -8510,6 +8456,7 @@ ); OTHER_SWIFT_FLAGS = "-D DEBUG -Xfrontend -warn-long-expression-type-checking=100"; SDKROOT = iphoneos; + STRIP_INSTALLED_PRODUCT = NO; SWIFT_VERSION = 4.0; VALIDATE_PRODUCT = YES; }; @@ -8535,7 +8482,6 @@ "$(inherited)", "$(SRCROOT)", ); - GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", @@ -8566,7 +8512,6 @@ "$(SRCROOT)", ); LLVM_LTO = NO; - OTHER_LDFLAGS = "$(inherited)"; OTHER_SWIFT_FLAGS = "$(inherited)"; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger"; PRODUCT_NAME = Session; @@ -8601,13 +8546,10 @@ 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 = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -8653,13 +8595,10 @@ 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 = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", "COCOAPODS=1", @@ -8706,8 +8645,6 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; DYLIB_COMPATIBILITY_VERSION = 1; @@ -8716,7 +8653,6 @@ ENABLE_MODULE_VERIFIER = NO; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", "COCOAPODS=1", @@ -8768,8 +8704,6 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; DYLIB_COMPATIBILITY_VERSION = 1; @@ -8778,7 +8712,6 @@ ENABLE_MODULE_VERIFIER = YES; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; INFOPLIST_FILE = SessionUIKit/Meta/Info.plist; @@ -8824,8 +8757,6 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; DYLIB_COMPATIBILITY_VERSION = 1; @@ -8834,7 +8765,6 @@ ENABLE_MODULE_VERIFIER = NO; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; INFOPLIST_FILE = SessionMessagingKit/Meta/Info.plist; @@ -8886,8 +8816,6 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; DYLIB_COMPATIBILITY_VERSION = 1; @@ -8896,7 +8824,6 @@ ENABLE_MODULE_VERIFIER = YES; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; INFOPLIST_FILE = SessionSnodeKit/Meta/Info.plist; @@ -8948,8 +8875,6 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; DYLIB_COMPATIBILITY_VERSION = 1; @@ -8958,7 +8883,6 @@ ENABLE_MODULE_VERIFIER = NO; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; INFOPLIST_FILE = SessionUtilitiesKit/Meta/Info.plist; @@ -9007,11 +8931,8 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = "$(inherited)"; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GENERATE_INFOPLIST_FILE = YES; @@ -9044,11 +8965,8 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = "$(inherited)"; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GENERATE_INFOPLIST_FILE = YES; @@ -9080,11 +8998,8 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = "$(inherited)"; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GENERATE_INFOPLIST_FILE = YES; @@ -9198,7 +9113,6 @@ "$(inherited)", "$(SRCROOT)", ); - GCC_OPTIMIZATION_LEVEL = 3; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -9229,7 +9143,6 @@ "$(SRCROOT)", ); LLVM_LTO = NO; - OTHER_LDFLAGS = "$(inherited)"; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger"; PRODUCT_NAME = Session; PROVISIONING_PROFILE = ""; @@ -9275,8 +9188,6 @@ 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 = SUQ8J2PCT7; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -9351,8 +9262,6 @@ 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 = SUQ8J2PCT7; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -9427,8 +9336,6 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; DYLIB_COMPATIBILITY_VERSION = 1; @@ -9513,8 +9420,6 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; DYLIB_COMPATIBILITY_VERSION = 1; @@ -9592,8 +9497,6 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; DYLIB_COMPATIBILITY_VERSION = 1; @@ -9677,8 +9580,6 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; DYLIB_COMPATIBILITY_VERSION = 1; @@ -9762,8 +9663,6 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; DYLIB_COMPATIBILITY_VERSION = 1; @@ -9845,8 +9744,6 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu11; @@ -9906,8 +9803,6 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu11; @@ -9966,8 +9861,6 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu11; diff --git a/Session.xcodeproj/xcshareddata/xcschemes/Session_CompileLibSession.xcscheme b/Session.xcodeproj/xcshareddata/xcschemes/Session_CompileLibSession.xcscheme index c7eb89197..12590d651 100644 --- a/Session.xcodeproj/xcshareddata/xcschemes/Session_CompileLibSession.xcscheme +++ b/Session.xcodeproj/xcshareddata/xcschemes/Session_CompileLibSession.xcscheme @@ -52,6 +52,8 @@ buildConfiguration = "Debug_Compile_LibSession" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + enableAddressSanitizer = "YES" + enableASanStackUseAfterReturn = "YES" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/Session/Settings/DeveloperSettingsViewModel.swift b/Session/Settings/DeveloperSettingsViewModel.swift index 7fcf4ef3d..97164a5db 100644 --- a/Session/Settings/DeveloperSettingsViewModel.swift +++ b/Session/Settings/DeveloperSettingsViewModel.swift @@ -90,6 +90,7 @@ class DeveloperSettingsViewModel: SessionTableViewModel, NavigatableStateHolder, case updatedGroupsDeleteBeforeNow case updatedGroupsDeleteAttachmentsBeforeNow + case copyDatabasePath case forceSlowDatabaseQueries case exportDatabase case importDatabase @@ -128,6 +129,7 @@ class DeveloperSettingsViewModel: SessionTableViewModel, NavigatableStateHolder, case .updatedGroupsDeleteBeforeNow: return "updatedGroupsDeleteBeforeNow" case .updatedGroupsDeleteAttachmentsBeforeNow: return "updatedGroupsDeleteAttachmentsBeforeNow" + case .copyDatabasePath: return "copyDatabasePath" case .forceSlowDatabaseQueries: return "forceSlowDatabaseQueries" case .exportDatabase: return "exportDatabase" case .importDatabase: return "importDatabase" @@ -170,6 +172,7 @@ class DeveloperSettingsViewModel: SessionTableViewModel, NavigatableStateHolder, case .updatedGroupsDeleteBeforeNow: result.append(.updatedGroupsDeleteBeforeNow); fallthrough case .updatedGroupsDeleteAttachmentsBeforeNow: result.append(.updatedGroupsDeleteAttachmentsBeforeNow); fallthrough + case .copyDatabasePath: result.append(.copyDatabasePath); fallthrough case .forceSlowDatabaseQueries: result.append(.forceSlowDatabaseQueries); fallthrough case .exportDatabase: result.append(.exportDatabase); fallthrough case .importDatabase: result.append(.importDatabase) @@ -723,6 +726,17 @@ class DeveloperSettingsViewModel: SessionTableViewModel, NavigatableStateHolder, let database: SectionModel = SectionModel( model: .database, elements: [ + SessionCell.Info( + id: .copyDatabasePath, + title: "Copy database path", + subtitle: """ + Copies the path to the database file (quick way to access it for the simulator for debugging). + """, + trailingAccessory: .highlightingBackgroundLabel(title: "Copy"), + onTap: { [weak self] in + self?.copyDatabasePath() + } + ), SessionCell.Info( id: .forceSlowDatabaseQueries, title: "Force slow database queries", @@ -794,6 +808,7 @@ class DeveloperSettingsViewModel: SessionTableViewModel, NavigatableStateHolder, case .showStringKeys: updateFlag(for: .showStringKeys, to: nil) case .resetSnodeCache: break // Not a feature + case .copyDatabasePath: break // Not a feature case .exportDatabase: break // Not a feature case .importDatabase: break // Not a feature case .advancedLogging: break // Not a feature @@ -1055,6 +1070,15 @@ class DeveloperSettingsViewModel: SessionTableViewModel, NavigatableStateHolder, ) } + private func copyDatabasePath() { + UIPasteboard.general.string = Storage.sharedDatabaseDirectoryPath + + showToast( + text: "copied".localized(), + backgroundColor: .backgroundSecondary + ) + } + // MARK: - Export and Import private func exportDatabase(_ targetView: UIView?) { diff --git a/SessionUtilitiesKit/Database/Storage.swift b/SessionUtilitiesKit/Database/Storage.swift index 8a2da7c24..6bd11ded3 100644 --- a/SessionUtilitiesKit/Database/Storage.swift +++ b/SessionUtilitiesKit/Database/Storage.swift @@ -58,7 +58,7 @@ open class Storage { /// take a long time then we should probably be handling it asynchronously rather than a synchronous way) private static let transactionDeadlockTimeoutSeconds: Int = 5 - private static var sharedDatabaseDirectoryPath: String { "\(SessionFileManager.nonInjectedAppSharedDataDirectoryPath)/database" } + public static var sharedDatabaseDirectoryPath: String { "\(SessionFileManager.nonInjectedAppSharedDataDirectoryPath)/database" } private static var databasePath: String { "\(Storage.sharedDatabaseDirectoryPath)/\(Storage.dbFileName)" } private static var databasePathShm: String { "\(Storage.sharedDatabaseDirectoryPath)/\(Storage.dbFileName)-shm" } private static var databasePathWal: String { "\(Storage.sharedDatabaseDirectoryPath)/\(Storage.dbFileName)-wal" } diff --git a/SessionUtilitiesKit/General/Logging.swift b/SessionUtilitiesKit/General/Logging.swift index d4d69ac2a..1f28e547a 100644 --- a/SessionUtilitiesKit/General/Logging.swift +++ b/SessionUtilitiesKit/General/Logging.swift @@ -663,18 +663,21 @@ private class SystemLogger: SystemLoggerType { init(category: String) { logger = os.Logger(subsystem: SystemLogger.subsystem, category: category) } - + +#if DEBUG + /// When in debug mode log everything publicly to ensure it comes through both the Xcode debugger and the Console.app public func log(_ level: Log.Level, _ log: String) { switch level { case .off, .default: return - case .verbose: logger.trace("\(log)") - case .debug: logger.debug("\(log)") - case .info: logger.info("\(log)") - case .warn: logger.warning("\(log)") - case .error: logger.error("\(log)") - case .critical: logger.critical("\(log)") + case .verbose: logger.trace("\(log, privacy: .public)") + case .debug: logger.debug("\(log, privacy: .public)") + case .info: logger.info("\(log, privacy: .public)") + case .warn: logger.warning("\(log, privacy: .public)") + case .error: logger.error("\(log, privacy: .public)") + case .critical: logger.critical("\(log, privacy: .public)") } } +#endif } // MARK: - Convenience From b039fbe7b926c47e0a0e8a64596f6a5bc7dbddcd Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Fri, 28 Mar 2025 17:04:00 +1100 Subject: [PATCH 2/3] Fixed a build issue --- SessionUtilitiesKit/General/Logging.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SessionUtilitiesKit/General/Logging.swift b/SessionUtilitiesKit/General/Logging.swift index 1f28e547a..1ea3750cd 100644 --- a/SessionUtilitiesKit/General/Logging.swift +++ b/SessionUtilitiesKit/General/Logging.swift @@ -664,9 +664,9 @@ private class SystemLogger: SystemLoggerType { logger = os.Logger(subsystem: SystemLogger.subsystem, category: category) } -#if DEBUG - /// When in debug mode log everything publicly to ensure it comes through both the Xcode debugger and the Console.app public func log(_ level: Log.Level, _ log: String) { +#if DEBUG + /// When in debug mode log everything publicly to ensure it comes through both the Xcode debugger and the Console.app switch level { case .off, .default: return case .verbose: logger.trace("\(log, privacy: .public)") @@ -676,8 +676,8 @@ private class SystemLogger: SystemLoggerType { case .error: logger.error("\(log, privacy: .public)") case .critical: logger.critical("\(log, privacy: .public)") } - } #endif + } } // MARK: - Convenience From 236d072235f74eee191a4d23e6874e70b5b32a17 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Wed, 2 Apr 2025 13:03:04 +1100 Subject: [PATCH 3/3] Moved the 'LibSession.clearLoggers' call below suspending the network --- Session/Meta/SessionApp.swift | 2 +- Session/Settings/DeveloperSettingsViewModel.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Session/Meta/SessionApp.swift b/Session/Meta/SessionApp.swift index f1cae8bea..bd7808a1a 100644 --- a/Session/Meta/SessionApp.swift +++ b/Session/Meta/SessionApp.swift @@ -139,7 +139,6 @@ public class SessionApp: SessionAppType { public func resetData(onReset: (() -> ())) { homeViewController = nil - LibSession.clearLoggers() dependencies.remove(cache: .libSession) dependencies.mutate(cache: .libSessionNetwork) { $0.clearSnodeCache() @@ -152,6 +151,7 @@ public class SessionApp: SessionAppType { try? dependencies[singleton: .keychain].removeAll() onReset() + LibSession.clearLoggers() Log.info("Data Reset Complete.") Log.flush() diff --git a/Session/Settings/DeveloperSettingsViewModel.swift b/Session/Settings/DeveloperSettingsViewModel.swift index 97164a5db..2c33abf6e 100644 --- a/Session/Settings/DeveloperSettingsViewModel.swift +++ b/Session/Settings/DeveloperSettingsViewModel.swift @@ -1362,12 +1362,12 @@ class DeveloperSettingsViewModel: SessionTableViewModel, NavigatableStateHolder, } /// Need to shut everything down before the swap out the data to prevent crashes - LibSession.clearLoggers() dependencies[singleton: .jobRunner].stopAndClearPendingJobs() dependencies.remove(cache: .libSession) dependencies.mutate(cache: .libSessionNetwork) { $0.suspendNetworkAccess() } dependencies[singleton: .storage].suspendDatabaseAccess() try dependencies[singleton: .storage].closeDatabase() + LibSession.clearLoggers() let deleteEnumerator: FileManager.DirectoryEnumerator? = FileManager.default.enumerator( at: URL(