BEGIN_PUBLIC
Add enable_swift_naming parameter to xplat_java_library and j2kt_native_library.
END_PUBLIC

PiperOrigin-RevId: 952465709
diff --git a/translator/src/main/java/com/google/devtools/j2objc/util/NameTable.java b/translator/src/main/java/com/google/devtools/j2objc/util/NameTable.java
index e60804d..053827b 100644
--- a/translator/src/main/java/com/google/devtools/j2objc/util/NameTable.java
+++ b/translator/src/main/java/com/google/devtools/j2objc/util/NameTable.java
@@ -671,6 +671,7 @@
     String functionName = function.getName();
 
     ExecutableElement method = function.getExecutableElement();
+
     if (method == null) {
       return null;
     }
@@ -686,6 +687,12 @@
       return null;
     }
 
+    if (ElementUtil.isStatic(method)) {
+      // Static methods without emitWrapperMethods enabled should not generate NS_SWIFT_NAME
+      // annotations because there is no wrapper method to call.
+      return null;
+    }
+
     String className = getSwiftClassNameFromAnnotation(owner, false);
     if (className == null) {
       // There isn't nice naming so fallback to the normal ObjC class name
diff --git a/translator/src/test/java/com/google/devtools/j2objc/gen/ObjectiveCHeaderGeneratorTest.java b/translator/src/test/java/com/google/devtools/j2objc/gen/ObjectiveCHeaderGeneratorTest.java
index 1ec90eb..f5bb20f4 100644
--- a/translator/src/test/java/com/google/devtools/j2objc/gen/ObjectiveCHeaderGeneratorTest.java
+++ b/translator/src/test/java/com/google/devtools/j2objc/gen/ObjectiveCHeaderGeneratorTest.java
@@ -1690,29 +1690,32 @@
     options.setEmitWrapperMethods(false);
 
     addSourceFile(
-        "@SwiftName "
-            + "package com.foo.bar;"
-            + ""
-            + "import com.google.j2objc.annotations.SwiftName;",
+        """
+        @SwiftName
+        package com.foo.bar;
+
+        import com.google.j2objc.annotations.SwiftName;
+        """,
         "com/foo/bar/package-info.java");
 
     String sourceContent =
-        "  package com.foo.bar;"
-            + ""
-            + "public class FooBar {"
-            + "  FooBar() {}"
-            + "  public static final class NestedBar {}"
-            + "  public void setFooField(String fooField) {"
-            + " "
-            + "  }"
-            + "  public static String builderWithExpectedSize(int expectedSize){ return \"\"; }"
-            + "  public static String builderWithName(String name){ return \"\"; }"
-            + "}";
+        """
+        package com.foo.bar;
+
+        public class FooBar {
+          FooBar() {}
+          public static final class NestedBar {}
+          public void setFooField(String fooField) {}
+          public static String builderWithExpectedSize(int expectedSize){ return ""; }
+          public static String builderWithName(String name){ return ""; }
+        }
+        """;
     String translation = translateSourceFile(sourceContent, "FooBar", "com/foo/bar/FooBar.h");
     assertInTranslation(translation, "NS_SWIFT_NAME(FooBar.init())");
-    assertInTranslation(
-        translation, "NS_SWIFT_NAME(FooBar.builderWithExpectedSize(expectedSize:))");
-    assertInTranslation(translation, "NS_SWIFT_NAME(FooBar.builderWithName(name:))");
+    // We don't expect the static functions to have NS_SWIFT_NAME annotations because
+    // there isn't a wrapper method available because emitWrapperMethods is false.
+    assertNotInTranslation(translation, "NS_SWIFT_NAME(FooBar.builderWithExpectedSize");
+    assertNotInTranslation(translation, "NS_SWIFT_NAME(FooBar.builderWithName");
   }
 
   public void testSwiftNameAnnotationWithStaticFunctionsWithWapperMethods() throws IOException {