Allow export of Obj-C symbols without C++ ones.

This is useful when building the .framework which doesn't need to
export C++ symbols.

Bug: webrtc:12408
Change-Id: Ied775811a72a06b9ad678c9fb549bca286dd7f37
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/227089
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34613}
diff --git a/BUILD.gn b/BUILD.gn
index e28485f..314e7a6 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -121,6 +121,9 @@
   if (rtc_enable_symbol_export || is_component_build) {
     defines = [ "WEBRTC_ENABLE_SYMBOL_EXPORT" ]
   }
+  if (rtc_enable_objc_symbol_export) {
+    defines = [ "WEBRTC_ENABLE_OBJC_SYMBOL_EXPORT" ]
+  }
 
   if (build_with_mozilla) {
     defines += [ "WEBRTC_MOZILLA_BUILD" ]
diff --git a/sdk/objc/base/RTCMacros.h b/sdk/objc/base/RTCMacros.h
index b5a7911..469e3c9 100644
--- a/sdk/objc/base/RTCMacros.h
+++ b/sdk/objc/base/RTCMacros.h
@@ -11,13 +11,13 @@
 #ifndef SDK_OBJC_BASE_RTCMACROS_H_
 #define SDK_OBJC_BASE_RTCMACROS_H_
 
-#ifdef WEBRTC_ENABLE_SYMBOL_EXPORT
+#ifdef WEBRTC_ENABLE_OBJC_SYMBOL_EXPORT
 
 #if defined(WEBRTC_LIBRARY_IMPL)
 #define RTC_OBJC_EXPORT __attribute__((visibility("default")))
 #endif
 
-#endif  // WEBRTC_ENABLE_SYMBOL_EXPORT
+#endif  // WEBRTC_ENABLE_OBJC_SYMBOL_EXPORT
 
 #ifndef RTC_OBJC_EXPORT
 #define RTC_OBJC_EXPORT
diff --git a/tools_webrtc/ios/build_ios_libs.py b/tools_webrtc/ios/build_ios_libs.py
index 3bc8874..9ae1a79 100755
--- a/tools_webrtc/ios/build_ios_libs.py
+++ b/tools_webrtc/ios/build_ios_libs.py
@@ -183,7 +183,7 @@
     gn_args.append('enable_ios_bitcode=' +
                    ('true' if use_bitcode else 'false'))
     gn_args.append('use_goma=' + ('true' if use_goma else 'false'))
-    gn_args.append('rtc_enable_symbol_export=true')
+    gn_args.append('rtc_enable_objc_symbol_export=true')
 
     args_string = ' '.join(gn_args + extra_gn_args)
     logging.info('Building WebRTC with args: %s', args_string)
diff --git a/webrtc.gni b/webrtc.gni
index 184d13d..8b15e89 100644
--- a/webrtc.gni
+++ b/webrtc.gni
@@ -35,10 +35,22 @@
   import("//build/config/mac/rules.gni")
 }
 
+# This declare_args is separated from the next one because args declared
+# in this one, can be read from the next one (args defined in the same
+# declare_args cannot be referenced in that scope).
 declare_args() {
   # Setting this to true will make RTC_EXPORT (see rtc_base/system/rtc_export.h)
   # expand to code that will manage symbols visibility.
   rtc_enable_symbol_export = false
+}
+
+declare_args() {
+  # Setting this to true will make RTC_OBJC_EXPORT expand to code that will
+  # manage symbols visibility. By default, Obj-C/Obj-C++ symbols are exported
+  # if C++ symbols are but setting this arg to true while keeping
+  # rtc_enable_symbol_export=false will only export RTC_OBJC_EXPORT
+  # annotated symbols.
+  rtc_enable_objc_symbol_export = rtc_enable_symbol_export
 
   # Setting this to true will define WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT which
   # will tell the pre-processor to remove the default definition of symbols
@@ -320,9 +332,7 @@
 # It sets defines, include paths and compilation warnings accordingly,
 # both for WebRTC stand-alone builds and for the scenario when WebRTC
 # native code is built as part of Chromium.
-rtc_common_configs = [
-  webrtc_root + ":common_config",
-]
+rtc_common_configs = [ webrtc_root + ":common_config" ]
 
 if (is_mac || is_ios) {
   rtc_common_configs += [ "//build/config/compiler:enable_arc" ]