diff --git a/cmake/build_shared.cmake b/cmake/build_shared.cmake index 52c83b11..fd5bd5c3 100644 --- a/cmake/build_shared.cmake +++ b/cmake/build_shared.cmake @@ -115,7 +115,25 @@ function(build_firebase_shared LIBRARY_NAME ARTIFACT_NAME OUTPUT_NAME) "lib${OUTPUT_NAME}.so" COMMENT "Strip debug symbols done on final binary. lib${OUTPUT_NAME}.so") endif() - + + # Strip the debug symbols from the Mac build to reduce sizes + if(APPLE AND NOT FIREBASE_IOS_BUILD AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug") + target_link_options(${shared_target} PRIVATE "-Wl,-dead_strip") + + add_custom_command(TARGET ${shared_target} POST_BUILD + COMMAND "${CMAKE_STRIP}" -x "$" + COMMENT "Stripping symbols from Mac bundle" + ) + endif() + + # Strip the debug symbols from the Linux build to reduce size + if(UNIX AND NOT APPLE AND NOT ANDROID AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug") + add_custom_command(TARGET ${shared_target} POST_BUILD + COMMAND "${CMAKE_STRIP}" --strip-unneeded "$" + COMMENT "Stripping symbols from Linux shared object" + ) + endif() + unity_pack_native(${shared_target}) if(ANDROID) diff --git a/cmake/build_universal.cmake b/cmake/build_universal.cmake index f161150d..38d40c11 100644 --- a/cmake/build_universal.cmake +++ b/cmake/build_universal.cmake @@ -96,6 +96,24 @@ function(build_uni TARGET_LINK_LIB_NAMES PROJECT_LIST_HEADER_VARIABLE) COMMENT "Strip debug symbols done on final binary. lib${FIREBASE_APP_UNI_VERSIONED}.so") endif() + # Strip the debug symbols from the Mac build to reduce size + if(APPLE AND NOT FIREBASE_IOS_BUILD AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug") + target_link_options(firebase_app_uni PRIVATE "-Wl,-dead_strip") + + add_custom_command(TARGET firebase_app_uni POST_BUILD + COMMAND "${CMAKE_STRIP}" -x "$" + COMMENT "Stripping symbols from Mac bundle" + ) + endif() + + # Strip the debug symbols from the Linux build to reduce size + if(UNIX AND NOT APPLE AND NOT ANDROID AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug") + add_custom_command(TARGET firebase_app_uni POST_BUILD + COMMAND "${CMAKE_STRIP}" --strip-unneeded "$" + COMMENT "Stripping symbols from Linux shared object" + ) + endif() + unity_pack_native(firebase_app_uni) set_property(TARGET firebase_app_uni diff --git a/docs/readme.md b/docs/readme.md index 76ba720c..9453692e 100644 --- a/docs/readme.md +++ b/docs/readme.md @@ -111,6 +111,7 @@ Release Notes ------------- ### Upcoming - Changes + - General: Strip debug symbols from Mac and Linux libraries, to reduce library size. - General (iOS): Improve initialization to address intermittent crashes on iOS 26. ([#1436](https://github.com/firebase/firebase-unity-sdk/issues/1436)). - Firebase AI: Add support for Grounding with Google Maps.