Remove Swift support from native rules

--
MOS_MIGRATED_REVID=140068224
diff --git a/src/main/java/com/google/devtools/build/lib/rules/apple/AppleToolchain.java b/src/main/java/com/google/devtools/build/lib/rules/apple/AppleToolchain.java
index 226ad79..abf6f97 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/apple/AppleToolchain.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/apple/AppleToolchain.java
@@ -139,13 +139,6 @@
     return sdkDir() + relativePath;
   }
 
-  /** Returns swift libraries path. */
-  public static String swiftLibDir(Platform platform) {
-    return DEVELOPER_DIR
-        + "/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/"
-        + platform.getLowerCaseNameInPlist();
-  }
-
   /**
    * Returns a series of xcode build settings which configure compilation warnings to
    * "recommended settings". Without these settings, compilation might result in some spurious
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationArtifacts.java b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationArtifacts.java
index 099541a..aa9eb8d 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationArtifacts.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationArtifacts.java
@@ -15,7 +15,6 @@
 package com.google.devtools.build.lib.rules.objc;
 
 import com.google.common.base.Optional;
-import com.google.common.base.Predicate;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
 import com.google.devtools.build.lib.actions.Artifact;
@@ -114,7 +113,6 @@
   private final Iterable<Artifact> privateHdrs;
   private final Iterable<Artifact> precompiledSrcs;
   private final Optional<Artifact> pchFile;
-  private final boolean hasSwiftSources;
 
   private CompilationArtifacts(
       Iterable<Artifact> srcs,
@@ -131,12 +129,6 @@
     this.precompiledSrcs = Preconditions.checkNotNull(precompiledSrcs);
     this.archive = Preconditions.checkNotNull(archive);
     this.pchFile = Preconditions.checkNotNull(pchFile);
-    this.hasSwiftSources = Iterables.any(this.srcs, new Predicate<Artifact>() {
-      @Override
-      public boolean apply(Artifact artifact) {
-        return ObjcRuleClasses.SWIFT_SOURCES.matches(artifact.getExecPath());
-      }
-    });
   }
 
   public Iterable<Artifact> getSrcs() {
@@ -182,10 +174,4 @@
     return pchFile;
   }
 
-  /**
-   * Returns true if any of this target's srcs are Swift source files.
-   */
-  public boolean hasSwiftSources() {
-    return hasSwiftSources;
-  }
 }
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationAttributes.java b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationAttributes.java
index 3e15538..bbb0493 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationAttributes.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationAttributes.java
@@ -34,7 +34,6 @@
 import com.google.devtools.build.lib.syntax.Type;
 import com.google.devtools.build.lib.util.Pair;
 import com.google.devtools.build.lib.vfs.PathFragment;
-
 import java.util.List;
 
 /**
@@ -55,7 +54,6 @@
     private final NestedSetBuilder<SdkFramework> sdkFrameworks = NestedSetBuilder.stableOrder();
     private final NestedSetBuilder<SdkFramework> weakSdkFrameworks = NestedSetBuilder.stableOrder();
     private final NestedSetBuilder<String> sdkDylibs = NestedSetBuilder.stableOrder();
-    private Optional<Artifact> bridgingHeader = Optional.absent();
     private Optional<PathFragment> packageFragment = Optional.absent();
     private boolean enableModules;
 
@@ -156,18 +154,6 @@
     }
 
     /**
-     * Sets the bridging header to be used when compiling Swift sources.
-     */
-    public Builder setBridgingHeader(Artifact bridgingHeader) {
-      Preconditions.checkState(
-          !this.bridgingHeader.isPresent(),
-          "bridgingHeader is already set to %s",
-          this.bridgingHeader);
-      this.bridgingHeader = Optional.of(bridgingHeader);
-      return this;
-    }
-
-    /**
      * Sets the package path from which to base the header search paths.
      */
     public Builder setPackageFragment(PathFragment packageFragment) {
@@ -194,7 +180,6 @@
       return new CompilationAttributes(
           this.hdrs.build(),
           this.textualHdrs.build(),
-          this.bridgingHeader,
           this.includes.build(),
           this.sdkIncludes.build(),
           this.sdkFrameworks.build(),
@@ -220,13 +205,6 @@
         builder.addTextualHdrs(
             PrerequisiteArtifacts.nestedSet(ruleContext, "textual_hdrs", Mode.TARGET));
       }
-
-      if (ruleContext.attributes().has("bridging_header", BuildType.LABEL)) {
-        Artifact header = ruleContext.getPrerequisiteArtifact("bridging_header", Mode.TARGET);
-        if (header != null) {
-          builder.setBridgingHeader(header);
-        }
-      }
     }
 
     private static void addIncludesFromRuleContext(Builder builder, RuleContext ruleContext) {
@@ -329,7 +307,6 @@
 
   private final NestedSet<Artifact> hdrs;
   private final NestedSet<Artifact> textualHdrs;
-  private final Optional<Artifact> bridgingHeader;
   private final NestedSet<PathFragment> includes;
   private final NestedSet<PathFragment> sdkIncludes;
   private final NestedSet<SdkFramework> sdkFrameworks;
@@ -344,7 +321,6 @@
   private CompilationAttributes(
       NestedSet<Artifact> hdrs,
       NestedSet<Artifact> textualHdrs,
-      Optional<Artifact> bridgingHeader,
       NestedSet<PathFragment> includes,
       NestedSet<PathFragment> sdkIncludes,
       NestedSet<SdkFramework> sdkFrameworks,
@@ -357,7 +333,6 @@
       boolean enableModules) {
     this.hdrs = hdrs;
     this.textualHdrs = textualHdrs;
-    this.bridgingHeader = bridgingHeader;
     this.includes = includes;
     this.sdkIncludes = sdkIncludes;
     this.sdkFrameworks = sdkFrameworks;
@@ -385,13 +360,6 @@
   }
 
   /**
-   * Returns the bridging header to be used when compiling Swift sources.
-   */
-  public Optional<Artifact> bridgingHeader() {
-    return this.bridgingHeader;
-  }
-
-  /**
    * Returns the include paths to be made available for compilation.
    */
   public NestedSet<PathFragment> includes() {
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java
index aaa5d80..a09e626 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java
@@ -29,7 +29,6 @@
 import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.NON_ARC_SRCS_TYPE;
 import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.PRECOMPILED_SRCS_TYPE;
 import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.SRCS_TYPE;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.SWIFT_SOURCES;
 import static java.nio.charset.StandardCharsets.ISO_8859_1;
 
 import com.google.common.annotations.VisibleForTesting;
@@ -164,7 +163,6 @@
               FileTypeSet.of(
                   ObjcRuleClasses.NON_CPP_SOURCES,
                   ObjcRuleClasses.CPP_SOURCES,
-                  ObjcRuleClasses.SWIFT_SOURCES,
                   HEADERS))
           .withSourceAttributes("srcs", "non_arc_srcs", "hdrs")
           .withDependencyAttributes("deps", "data", "binary", "xctest_app");
@@ -266,13 +264,13 @@
         .build();
   }
 
-  /** Returns a list of framework search path flags for clang/swift actions. */
+  /** Returns a list of framework search path flags for clang actions. */
   static Iterable<String> commonFrameworkFlags(
       ObjcProvider provider, AppleConfiguration appleConfiguration) {
     return Interspersing.beforeEach("-F", commonFrameworkNames(provider, appleConfiguration));
   }
 
-  /** Returns a list of frameworks for clang/swift actions. */
+  /** Returns a list of frameworks for clang actions. */
   static Iterable<String> commonFrameworkNames(
       ObjcProvider provider, AppleConfiguration appleConfiguration) {
     Platform platform = appleConfiguration.getSingleArchPlatform();
@@ -294,14 +292,6 @@
         .build();
   }
 
-  /** Returns the target string for swift compiler. For example, "x86_64-apple-ios8.2" */
-  @VisibleForTesting
-  static String swiftTarget(AppleConfiguration configuration) {
-    // TODO(bazel-team): Assert the configuration is for an apple platform, or support
-    // other platform types.
-    return configuration.getSingleArchitecture() + "-apple-ios" + configuration.getIosSdkVersion();
-  }
-
   protected final RuleContext ruleContext;
   protected final BuildConfiguration buildConfiguration;
   protected final ObjcConfiguration objcConfiguration;
@@ -505,14 +495,6 @@
         ruleContext.attributeError(
             "srcs", String.format(FILE_IN_SRCS_AND_NON_ARC_SRCS_ERROR_FORMAT, path));
       }
-
-      if (appleConfiguration.disableNativeSwiftRules()) {
-        for (Artifact src : srcsSet) {
-          if (SWIFT_SOURCES.apply(src.getFilename())) {
-            ruleContext.attributeError("srcs", "Swift is not supported in native rules.");
-          }
-        }
-      }
     }
 
     ruleContext.assertNoErrors();
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/CrosstoolCompilationSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/CrosstoolCompilationSupport.java
index ada735b..dcdc6f9 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/CrosstoolCompilationSupport.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/CrosstoolCompilationSupport.java
@@ -293,7 +293,7 @@
                     .getFragment(AppleConfiguration.class)
                     .getBitcodeMode()
                     .getFeatureNames())
-            // We create a module map by default to allow for swift interop.
+            // We create a module map by default to allow for Swift interop.
             .add(CppRuleClasses.MODULE_MAPS)
             .add(CppRuleClasses.COMPILE_ACTION_FLAGS_IN_FLAG_SET)
             .add(CppRuleClasses.DEPENDENCY_FILE)
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/IntermediateArtifacts.java b/src/main/java/com/google/devtools/build/lib/rules/objc/IntermediateArtifacts.java
index e4df72f..42d437f 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/IntermediateArtifacts.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/IntermediateArtifacts.java
@@ -271,27 +271,6 @@
   }
 
   /**
-   * The swift module produced by compiling the {@code source} artifact.
-   */
-  public Artifact swiftModuleFile(Artifact source) {
-    return inUniqueObjsDir(source, ".partial_swiftmodule");
-  }
-
-  /**
-   * Integrated swift module for this target.
-   */
-  public Artifact swiftModule() {
-    return appendExtension(".swiftmodule");
-  }
-
-  /**
-   * Integrated swift header for this target.
-   */
-  public Artifact swiftHeader() {
-    return appendExtension("-Swift.h");
-  }
-
-  /**
    * The artifact for the .gcno file that should be generated when compiling the {@code source}
    * artifact.
    */
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/LegacyCompilationSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/LegacyCompilationSupport.java
index 960afeb..7297563 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/LegacyCompilationSupport.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/LegacyCompilationSupport.java
@@ -18,7 +18,6 @@
 import static com.google.devtools.build.lib.rules.objc.ObjcProvider.DYNAMIC_FRAMEWORK_FILE;
 import static com.google.devtools.build.lib.rules.objc.ObjcProvider.FORCE_LOAD_LIBRARY;
 import static com.google.devtools.build.lib.rules.objc.ObjcProvider.Flag.USES_CPP;
-import static com.google.devtools.build.lib.rules.objc.ObjcProvider.Flag.USES_SWIFT;
 import static com.google.devtools.build.lib.rules.objc.ObjcProvider.HEADER;
 import static com.google.devtools.build.lib.rules.objc.ObjcProvider.IMPORTED_LIBRARY;
 import static com.google.devtools.build.lib.rules.objc.ObjcProvider.INCLUDE;
@@ -36,7 +35,6 @@
 import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.PRECOMPILED_SRCS_TYPE;
 import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.SRCS_TYPE;
 import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.STRIP;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.SWIFT;
 
 import com.google.common.base.Joiner;
 import com.google.common.base.Optional;
@@ -219,29 +217,25 @@
     for (Artifact sourceFile : compilationArtifacts.getSrcs()) {
       Artifact objFile = intermediateArtifacts.objFile(sourceFile);
       objFiles.add(objFile);
-      if (!appleConfiguration.disableNativeSwiftRules()
-          && ObjcRuleClasses.SWIFT_SOURCES.matches(sourceFile.getFilename())) {
-        registerSwiftCompileAction(sourceFile, objFile, objcProvider);
+
+      if (objFile.isTreeArtifact()) {
+        registerCompileActionTemplate(
+            sourceFile,
+            objFile,
+            objcProvider,
+            priorityHeaders,
+            moduleMap,
+            compilationArtifacts,
+            Iterables.concat(extraCompileArgs, ImmutableList.of("-fobjc-arc")));
       } else {
-        if (objFile.isTreeArtifact()) {
-          registerCompileActionTemplate(
-              sourceFile,
-              objFile,
-              objcProvider,
-              priorityHeaders,
-              moduleMap,
-              compilationArtifacts,
-              Iterables.concat(extraCompileArgs, ImmutableList.of("-fobjc-arc")));
-        } else {
-          registerCompileAction(
-              sourceFile,
-              objFile,
-              objcProvider,
-              priorityHeaders,
-              moduleMap,
-              compilationArtifacts,
-              Iterables.concat(extraCompileArgs, ImmutableList.of("-fobjc-arc")));
-        }
+        registerCompileAction(
+            sourceFile,
+            objFile,
+            objcProvider,
+            priorityHeaders,
+            moduleMap,
+            compilationArtifacts,
+            Iterables.concat(extraCompileArgs, ImmutableList.of("-fobjc-arc")));
       }
     }
     for (Artifact nonArcSourceFile : compilationArtifacts.getNonArcSrcs()) {
@@ -270,10 +264,6 @@
 
     objFiles.addAll(compilationArtifacts.getPrecompiledSrcs());
 
-    if (compilationArtifacts.hasSwiftSources()) {
-      registerSwiftModuleMergeAction(compilationArtifacts, objcProvider);
-    }
-
     for (Artifact archive : compilationArtifacts.getArchive().asSet()) {
       registerArchiveActions(objFiles.build(), archive);
     }
@@ -293,12 +283,6 @@
     return commandLine;
   }
 
-  private CustomCommandLine.Builder addSource(String argName, CustomCommandLine.Builder commandLine,
-      Artifact sourceFile) {
-    commandLine.add(argName);
-    return addSource(commandLine, sourceFile);
-  }
-
   private CustomCommandLine compileActionCommandLine(
       Artifact sourceFile,
       Artifact objFile,
@@ -309,8 +293,7 @@
       Optional<Artifact> dotdFile,
       Iterable<String> otherFlags,
       boolean collectCodeCoverage,
-      boolean isCPlusPlusSource,
-      boolean hasSwiftSources) {
+      boolean isCPlusPlusSource) {
     CustomCommandLine.Builder commandLine = new CustomCommandLine.Builder().add(CLANG);
 
     if (isCPlusPlusSource) {
@@ -318,13 +301,6 @@
       commandLine.add("-std=gnu++11");
     }
 
-    if (hasSwiftSources) {
-      // Add the directory that contains merged TargetName-Swift.h header to search path, in case
-      // any of ObjC files use it.
-      commandLine.add("-I");
-      commandLine.addPath(intermediateArtifacts.swiftHeader().getExecPath().getParentDirectory());
-    }
-
     // The linker needs full debug symbol information to perform binary dead-code stripping.
     if (objcConfiguration.shouldStripBinary()) {
       commandLine.add("-g");
@@ -430,7 +406,6 @@
     boolean isCPlusPlusSource = ObjcRuleClasses.CPP_SOURCES.matches(sourceFile.getExecPath());
     boolean runCodeCoverage =
         buildConfiguration.isCodeCoverageEnabled() && ObjcRuleClasses.isInstrumentable(sourceFile);
-    boolean hasSwiftSources = compilationArtifacts.hasSwiftSources();
     DotdFile dotdFile = intermediateArtifacts.dotdFile(sourceFile);
 
     CustomCommandLine commandLine =
@@ -444,19 +419,13 @@
             Optional.of(dotdFile.artifact()),
             otherFlags,
             runCodeCoverage,
-            isCPlusPlusSource,
-            hasSwiftSources);
+            isCPlusPlusSource);
 
     Optional<Artifact> gcnoFile = Optional.absent();
     if (runCodeCoverage && !buildConfiguration.isLLVMCoverageMapFormatEnabled()) {
       gcnoFile = Optional.of(intermediateArtifacts.gcnoFile(sourceFile));
     }
 
-    Optional<Artifact> swiftHeader = Optional.absent();
-    if (hasSwiftSources) {
-      swiftHeader = Optional.of(intermediateArtifacts.swiftHeader());
-    }
-
     NestedSet<Artifact> moduleMapInputs = NestedSetBuilder.emptySet(Order.STABLE_ORDER);
     if (objcConfiguration.moduleMapsEnabled()) {
       moduleMapInputs = objcProvider.get(MODULE_MAP);
@@ -470,7 +439,6 @@
             .setSourceFile(sourceFile)
             .addTransitiveHeaders(objcProvider.get(HEADER))
             .addHeaders(compilationArtifacts.getPrivateHdrs())  
-            .addMandatoryInputs(swiftHeader.asSet())
             .addTransitiveMandatoryInputs(moduleMapInputs)
             .addTransitiveMandatoryInputs(objcProvider.get(STATIC_FRAMEWORK_FILE))
             .addTransitiveMandatoryInputs(objcProvider.get(DYNAMIC_FRAMEWORK_FILE))
@@ -510,7 +478,8 @@
       Optional<CppModuleMap> moduleMap,
       CompilationArtifacts compilationArtifacts,
       Iterable<String> otherFlags) {
-    CustomCommandLine commandLine = compileActionCommandLine(
+    CustomCommandLine commandLine =
+        compileActionCommandLine(
             sourceFiles,
             objFiles,
             objcProvider,
@@ -519,9 +488,8 @@
             compilationArtifacts.getPchFile(),
             Optional.<Artifact>absent(),
             otherFlags,
-            /* runCodeCoverage=*/false,
-            /* isCPlusPlusSource=*/false,
-            /* hasSwiftSources=*/false);
+            /* runCodeCoverage=*/ false,
+            /* isCPlusPlusSource=*/ false);
 
     AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class);
     Platform platform = appleConfiguration.getSingleArchPlatform();
@@ -548,169 +516,6 @@
             .build(ruleContext.getActionOwner()));
   }
 
-  /**
-   * Compiles a single swift file.
-   *
-   * @param sourceFile the artifact to compile
-   * @param objFile the resulting object artifact
-   * @param objcProvider ObjcProvider instance for this invocation
-   */
-  private void registerSwiftCompileAction(
-      Artifact sourceFile,
-      Artifact objFile,
-      ObjcProvider objcProvider) {
-
-    // Compiling a single swift file requires knowledge of all of the other
-    // swift files in the same module. The primary file ({@code sourceFile}) is
-    // compiled to an object file, while the remaining files are used to resolve
-    // symbols (they behave like c/c++ headers in this context).
-    ImmutableSet.Builder<Artifact> otherSwiftSourcesBuilder = ImmutableSet.builder();
-    for (Artifact otherSourceFile : compilationArtifacts(ruleContext).getSrcs()) {
-      if (ObjcRuleClasses.SWIFT_SOURCES.matches(otherSourceFile.getFilename())
-          && !otherSourceFile.equals(sourceFile)) {
-        otherSwiftSourcesBuilder.add(otherSourceFile);
-      }
-    }
-    ImmutableSet<Artifact> otherSwiftSources = otherSwiftSourcesBuilder.build();
-
-    CustomCommandLine.Builder commandLine = new CustomCommandLine.Builder()
-            .add(SWIFT)
-            .add("-frontend")
-            .add("-emit-object")
-            .add("-target").add(swiftTarget(appleConfiguration))
-            .add("-sdk").add(AppleToolchain.sdkDir())
-            .add("-enable-objc-interop")
-            .add(objcConfiguration.getSwiftCoptsForCompilationMode());
-
-    if (objcConfiguration.generateDsym()) {
-      commandLine.add("-g");
-    }
-
-    commandLine
-      .add("-module-name").add(getModuleName())
-      .add("-parse-as-library");
-    addSource("-primary-file", commandLine, sourceFile)
-        .addExecPaths(otherSwiftSources)
-        .addExecPath("-o", objFile)
-        .addExecPath("-emit-module-path", intermediateArtifacts.swiftModuleFile(sourceFile))
-        // The swift compiler will invoke clang itself when compiling module maps. This invocation
-        // does not include the current working directory, causing cwd-relative imports to fail.
-        // Including the current working directory to the header search paths ensures that these
-        // relative imports will work.
-        .add("-Xcc").add("-I.");
-
-    // Using addExecPathBefore here adds unnecessary quotes around '-Xcc -I', which trips the
-    // compiler. Using two add() calls generates a correctly formed command line.
-    for (PathFragment directory : objcProvider.get(INCLUDE).toList()) {
-      commandLine.add("-Xcc").add(String.format("-I%s", directory.toString()));
-    }
-
-    ImmutableList.Builder<Artifact> inputHeaders = ImmutableList.<Artifact>builder()
-            .addAll(attributes.hdrs())
-            .addAll(attributes.textualHdrs());
-
-    Optional<Artifact> bridgingHeader = attributes.bridgingHeader();
-    if (bridgingHeader.isPresent()) {
-      commandLine.addExecPath("-import-objc-header", bridgingHeader.get());
-      inputHeaders.add(bridgingHeader.get());
-    }
-
-    // Import the Objective-C module map.
-    // TODO(bazel-team): Find a way to import the module map directly, instead of the parent
-    // directory?
-    if (objcConfiguration.moduleMapsEnabled()) {
-      PathFragment moduleMapPath = intermediateArtifacts.moduleMap().getArtifact().getExecPath();
-      commandLine.add("-I").add(moduleMapPath.getParentDirectory().toString());
-      commandLine.add("-import-underlying-module");
-
-      inputHeaders.addAll(objcProvider.get(MODULE_MAP));
-    }
-
-    commandLine.add(commonFrameworkFlags(objcProvider, appleConfiguration));
-
-    ruleContext.registerAction(
-        ObjcRuleClasses.spawnAppleEnvActionBuilder(
-                appleConfiguration, appleConfiguration.getSingleArchPlatform())
-            .setMnemonic("SwiftCompile")
-            .setExecutable(xcrunwrapper(ruleContext))
-            .setCommandLine(commandLine.build())
-            .addInput(sourceFile)
-            .addInputs(otherSwiftSources)
-            .addInputs(inputHeaders.build())
-            .addTransitiveInputs(objcProvider.get(HEADER))
-            .addOutput(objFile)
-            .addOutput(intermediateArtifacts.swiftModuleFile(sourceFile))
-            .build(ruleContext));
-  }
-
-  /**
-   * Merges multiple .partial_swiftmodule files together. Also produces a swift header that can be
-   * used by Objective-C code.
-   */
-  private void registerSwiftModuleMergeAction(
-      CompilationArtifacts compilationArtifacts,
-      ObjcProvider objcProvider) {
-    ImmutableList.Builder<Artifact> moduleFiles = new ImmutableList.Builder<>();
-    for (Artifact src : compilationArtifacts.getSrcs()) {
-      if (ObjcRuleClasses.SWIFT_SOURCES.matches(src.getFilename())) {
-        moduleFiles.add(intermediateArtifacts.swiftModuleFile(src));
-      }
-    }
-
-    CustomCommandLine.Builder commandLine = new CustomCommandLine.Builder()
-            .add(SWIFT)
-            .add("-frontend")
-            .add("-emit-module")
-            .add("-sdk").add(AppleToolchain.sdkDir())
-            .add("-target").add(swiftTarget(appleConfiguration))
-            .add(objcConfiguration.getSwiftCoptsForCompilationMode());
-
-    if (objcConfiguration.generateDsym()) {
-      commandLine.add("-g");
-    }
-
-    commandLine
-        .add("-module-name").add(getModuleName())
-        .add("-parse-as-library")
-        .addExecPaths(moduleFiles.build())
-        .addExecPath("-o", intermediateArtifacts.swiftModule())
-        .addExecPath("-emit-objc-header-path", intermediateArtifacts.swiftHeader())
-        // The swift compiler will invoke clang itself when compiling module maps. This invocation
-        // does not include the current working directory, causing cwd-relative imports to fail.
-        // Including the current working directory to the header search paths ensures that these
-        // relative imports will work.
-        .add("-Xcc").add("-I.");
-
-
-    // Using addExecPathBefore here adds unnecessary quotes around '-Xcc -I', which trips the
-    // compiler. Using two add() calls generates a correctly formed command line.
-    for (PathFragment directory : objcProvider.get(INCLUDE).toList()) {
-      commandLine.add("-Xcc").add(String.format("-I%s", directory.toString()));
-    }
-
-    // Import the Objective-C module map.
-    // TODO(bazel-team): Find a way to import the module map directly, instead of the parent
-    // directory?
-    if (objcConfiguration.moduleMapsEnabled()) {
-      PathFragment moduleMapPath = intermediateArtifacts.moduleMap().getArtifact().getExecPath();
-      commandLine.add("-I").add(moduleMapPath.getParentDirectory().toString());
-    }
-
-    commandLine.add(commonFrameworkFlags(objcProvider, appleConfiguration));
-
-    ruleContext.registerAction(ObjcRuleClasses.spawnAppleEnvActionBuilder(
-                appleConfiguration, appleConfiguration.getSingleArchPlatform())
-            .setMnemonic("SwiftModuleMerge")
-            .setExecutable(xcrunwrapper(ruleContext))
-            .setCommandLine(commandLine.build())
-            .addInputs(moduleFiles.build())
-            .addTransitiveInputs(objcProvider.get(HEADER))
-            .addTransitiveInputs(objcProvider.get(MODULE_MAP))
-            .addOutput(intermediateArtifacts.swiftModule())
-            .addOutput(intermediateArtifacts.swiftHeader())
-            .build(ruleContext));
-  }
-
   private void registerArchiveActions(List<Artifact> objFiles, Artifact archive) {
     Artifact objList = intermediateArtifacts.archiveObjList();
     registerObjFilelistAction(objFiles, objList);
@@ -974,25 +779,6 @@
       }
     }
 
-    if (objcProvider.is(USES_SWIFT)) {
-      // Check if there's a swift library path already. If that's not the case - fall back to
-      // the default one. This is for backwards compatibility with Swift native rules.
-      // TODO(b/30281236): Remove when native Swift is deprecated.
-      boolean swiftLibDirSet = false;
-      for (String arg : objcProvider.get(ObjcProvider.LINKOPT)) {
-        if (arg.startsWith("-L") && arg.contains("usr/lib/swift")) {
-          swiftLibDirSet = true;
-          break;
-        }
-      }
-
-      if (!swiftLibDirSet) {
-        commandLine
-            .add("-L")
-            .add(AppleToolchain.swiftLibDir(appleConfiguration.getSingleArchPlatform()));
-      }
-    }
-
     for (String linkopt : attributes.linkopts()) {
       commandLine.add("-Wl," + linkopt);
     }
@@ -1094,19 +880,6 @@
     return path.replaceName(name.substring(0, name.length() - suffix.length()));
   }
 
-  /**
-   * Returns the name of Swift module for this target.
-   */
-  private String getModuleName() {
-    // If we have module maps support, we need to use the generated module name, this way
-    // clang can properly load objc part of the module via -import-underlying-module command.
-    if (objcConfiguration.moduleMapsEnabled()) {
-      return intermediateArtifacts.moduleMap().getName();
-    }
-    // Otherwise, just use target name, it doesn't matter.
-    return ruleContext.getLabel().getName();
-  }
-
   /** Returns a list of clang flags used for all link and compile actions executed through clang. */
   private List<String> commonLinkAndCompileFlagsForClang(
       ObjcProvider provider, ObjcConfiguration objcConfiguration,
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java
index 0a9e3a3..bbf79b6 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java
@@ -29,7 +29,6 @@
 import static com.google.devtools.build.lib.rules.objc.ObjcProvider.FORCE_LOAD_LIBRARY;
 import static com.google.devtools.build.lib.rules.objc.ObjcProvider.FRAMEWORK_DIR;
 import static com.google.devtools.build.lib.rules.objc.ObjcProvider.Flag.USES_CPP;
-import static com.google.devtools.build.lib.rules.objc.ObjcProvider.Flag.USES_SWIFT;
 import static com.google.devtools.build.lib.rules.objc.ObjcProvider.GENERAL_RESOURCE_DIR;
 import static com.google.devtools.build.lib.rules.objc.ObjcProvider.GENERAL_RESOURCE_FILE;
 import static com.google.devtools.build.lib.rules.objc.ObjcProvider.HEADER;
@@ -78,7 +77,6 @@
 import com.google.devtools.build.lib.util.FileType;
 import com.google.devtools.build.lib.util.Preconditions;
 import com.google.devtools.build.lib.vfs.PathFragment;
-
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -524,20 +522,14 @@
         }
 
         boolean usesCpp = false;
-        boolean usesSwift = false;
         for (Artifact sourceFile :
             Iterables.concat(artifacts.getSrcs(), artifacts.getNonArcSrcs())) {
           usesCpp = usesCpp || ObjcRuleClasses.CPP_SOURCES.matches(sourceFile.getExecPath());
-          usesSwift = usesSwift || ObjcRuleClasses.SWIFT_SOURCES.matches(sourceFile.getExecPath());
         }
 
         if (usesCpp) {
           objcProvider.add(FLAG, USES_CPP);
         }
-
-        if (usesSwift) {
-          objcProvider.add(FLAG, USES_SWIFT);
-        }
       }
 
       if (alwayslink) {
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfiguration.java
index d01a8f4..4d730fb 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfiguration.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfiguration.java
@@ -219,24 +219,6 @@
   }
 
   /**
-   * Returns the default set of swiftc options for the current compilation mode.
-   */
-  @SkylarkCallable(name = "swift_copts_for_current_compilation_mode", structField = true,
-      doc = "Returns a list of default options to use for compiling Swift in the current mode.")
-  public ImmutableList<String> getSwiftCoptsForCompilationMode() {
-    switch (compilationMode) {
-      case DBG:
-        return ImmutableList.of("-Onone", "-DDEBUG=1", "-g");
-      case FASTBUILD:
-        return ImmutableList.of("-Onone", "-DDEBUG=1");
-      case OPT:
-        return ImmutableList.of("-O", "-DNDEBUG=1");
-      default:
-        throw new AssertionError();
-    }
-  }
-
-  /**
    * Returns options passed to (Apple) clang when compiling Objective C. These options should be
    * applied after any default options but before options specified in the attributes of the rule.
    */
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProvider.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProvider.java
index f1a8d08..667753d7 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProvider.java
@@ -355,10 +355,7 @@
      */
     USES_CPP,
 
-    /**
-     * Indicates that Swift source files are present. This affects bundling, compiling and linking
-     * actions.
-     */
+    /** Indicates that Swift dependencies are present. This affects bundling actions. */
     USES_SWIFT,
 
     /**
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java
index 749d653..af000294 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java
@@ -73,7 +73,6 @@
 
   static final String CLANG = "clang";
   static final String CLANG_PLUSPLUS = "clang++";
-  static final String SWIFT = "swift";
   static final String DSYMUTIL = "dsymutil";
   static final String LIPO = "lipo";
   static final String STRIP = "strip";
@@ -371,8 +370,6 @@
   static final FileType ASSEMBLY_SOURCES = FileType.of(".s", ".S", ".asm");
 
   static final FileType OBJECT_FILE_SOURCES = FileType.of(".o");
-  
-  static final FileType SWIFT_SOURCES = FileType.of(".swift");
 
   /**
    * Header files, which are not compiled directly, but may be included/imported from source files.
@@ -388,14 +385,11 @@
           CPP_SOURCES,
           ASSEMBLY_SOURCES,
           OBJECT_FILE_SOURCES,
-          SWIFT_SOURCES,
           HEADERS);
 
-  /**
-   * Files that should actually be compiled.
-   */
-  static final FileTypeSet COMPILABLE_SRCS_TYPE = FileTypeSet.of(NON_CPP_SOURCES, CPP_SOURCES,
-      ASSEMBLY_SOURCES, SWIFT_SOURCES);
+  /** Files that should actually be compiled. */
+  static final FileTypeSet COMPILABLE_SRCS_TYPE =
+      FileTypeSet.of(NON_CPP_SOURCES, CPP_SOURCES, ASSEMBLY_SOURCES);
 
   /**
    * Files that are already compiled.
@@ -633,12 +627,6 @@
           .add(attr("textual_hdrs", LABEL_LIST)
               .direct_compile_time_input()
               .allowedFileTypes(HDRS_TYPE))
-          /* <!-- #BLAZE_RULE($objc_compile_dependency_rule).ATTRIBUTE(bridging_header) -->
-          A header defining the Objective-C interfaces to be exposed in Swift.
-          <!-- #END_BLAZE_RULE.ATTRIBUTE -->*/
-          .add(attr("bridging_header", BuildType.LABEL)
-              .direct_compile_time_input()
-              .allowedFileTypes(HDRS_TYPE))
           /* <!-- #BLAZE_RULE($objc_compile_dependency_rule).ATTRIBUTE(includes) -->
           List of <code>#include/#import</code> search paths to add to this target
           and all depending targets.