# Copyright 2026 The Chromium Authors. All rights resAerved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/apple/swift_source_set.gni")

if (enable_swift_cxx_interop) {
  source_set("tests") {
    testonly = true
    configs += [ "//build/config/ios:xctest_config" ]

    # TODO(crbug.com/456806155): Find a better solution to suppress errors from
    # chromium clang on headers that come from the iOS SDK. Ideally, we'd want a
    # suppression that is inherited implicitly from swift_source_set
    # dependencies. Unfortunately, the gn language does not allow child targets
    # to do things like `invoker.configs -= [...]`. Also, we'd ideally want a
    # suppression that is scoped to just the SDK headers rather than the entire
    # target that includes the headers. We can't use the
    # "build/config/compiler:no_chromium_code" config to solve this problem
    # because we don't have any build targets that have the SDK headers as
    # direct sources.
    if (is_clang) {
      configs -= [ "//build/config/clang:find_bad_constructs" ]
    }

    sources = [ "objc_xctest.mm" ]
    deps = [
      ":swift_api",
      "//base",
    ]
    frameworks = [ "Foundation.framework" ]
  }

  swift_source_set("swift_api") {
    testonly = true
    module_name = "SwiftAPI"
    configs += [ "//build/config/ios:swift_cxx_interop" ]
    sources = [ "swift_api.swift" ]
  }
}
