diff --git a/tests/ios/frameworks/genrule-inputs/App/main.swift b/tests/ios/frameworks/genrule-inputs/App/main.swift new file mode 100644 index 000000000..e69de29bb diff --git a/tests/ios/frameworks/genrule-inputs/BUILD.bazel b/tests/ios/frameworks/genrule-inputs/BUILD.bazel new file mode 100644 index 000000000..553718498 --- /dev/null +++ b/tests/ios/frameworks/genrule-inputs/BUILD.bazel @@ -0,0 +1,12 @@ +load("//rules:app.bzl", "ios_application") + +ios_application( + name = "App", + srcs = ["App/main.swift"], + bundle_id = "com.example.app", + minimum_os_version = "10.0", + visibility = ["//visibility:public"], + deps = [ + "//tests/ios/frameworks/genrule-inputs/a", + ], +) diff --git a/tests/ios/frameworks/genrule-inputs/a/BUILD.bazel b/tests/ios/frameworks/genrule-inputs/a/BUILD.bazel new file mode 100644 index 000000000..aeff8ff52 --- /dev/null +++ b/tests/ios/frameworks/genrule-inputs/a/BUILD.bazel @@ -0,0 +1,10 @@ +load("//rules:framework.bzl", "apple_framework") + +apple_framework( + name = "a", + srcs = glob(["*.swift"]), + infoplists = ["//rules/test_host_app:Info.plist"], + platforms = {"ios": "10.0"}, + visibility = ["//visibility:public"], + deps = ["//tests/ios/frameworks/genrule-inputs/b"], +) diff --git a/tests/ios/frameworks/genrule-inputs/a/lib.swift b/tests/ios/frameworks/genrule-inputs/a/lib.swift new file mode 100644 index 000000000..fcc959fbf --- /dev/null +++ b/tests/ios/frameworks/genrule-inputs/a/lib.swift @@ -0,0 +1,5 @@ +import b + +struct A { + public static func run() { B.run() } +} diff --git a/tests/ios/frameworks/genrule-inputs/b/BUILD.bazel b/tests/ios/frameworks/genrule-inputs/b/BUILD.bazel new file mode 100644 index 000000000..d4bcea001 --- /dev/null +++ b/tests/ios/frameworks/genrule-inputs/b/BUILD.bazel @@ -0,0 +1,9 @@ +load("//rules:framework.bzl", "apple_framework") + +apple_framework( + name = "b", + srcs = glob(["*.swift"]), + platforms = {"ios": "10.0"}, + visibility = ["//visibility:public"], + deps = ["//tests/ios/frameworks/genrule-inputs/c"], +) diff --git a/tests/ios/frameworks/genrule-inputs/b/lib.swift b/tests/ios/frameworks/genrule-inputs/b/lib.swift new file mode 100644 index 000000000..b3ccdebb8 --- /dev/null +++ b/tests/ios/frameworks/genrule-inputs/b/lib.swift @@ -0,0 +1,10 @@ +import c + +public struct B { + public static func run() { + C.run() + guard LibC != "B" else { + fatalError() + } + } +} diff --git a/tests/ios/frameworks/genrule-inputs/c/BUILD.bazel b/tests/ios/frameworks/genrule-inputs/c/BUILD.bazel new file mode 100644 index 000000000..d207fb6b6 --- /dev/null +++ b/tests/ios/frameworks/genrule-inputs/c/BUILD.bazel @@ -0,0 +1,39 @@ +load("//rules:framework.bzl", "apple_framework") + +genrule( + name="lib-src.swift", + cmd = """ +cat > $(OUTS) <<-EOF +public struct C { + + public static func run() { + print("runs here") + guard LibC == "LibC" else { + fatalError() + } + } +} +EOF + """, + outs = ["lib.swift"] +) + +genrule( + name="lib-src.h", + cmd = """ +cat > $(OUTS) <<-EOF + @import Foundation; + static NSString *const LibC = @"LibC"; +EOF + """, + outs = ["lib-src.h"] +) + +apple_framework( + name = "c", + # Note: supplying a hader file, e.g. `lib-src.h` named `:lib-src.h` + # string will cause the umbrella header rule to break. + srcs = [":lib-src.swift", "lib-src.h"], + platforms = {"ios": "10.0"}, + visibility = ["//visibility:public"], +) diff --git a/tests/ios/unit-test/test-imports-app/BUILD.bazel b/tests/ios/unit-test/test-imports-app/BUILD.bazel index 275f53e38..ae78f5191 100644 --- a/tests/ios/unit-test/test-imports-app/BUILD.bazel +++ b/tests/ios/unit-test/test-imports-app/BUILD.bazel @@ -76,5 +76,10 @@ ios_unit_test( visibility = ["//visibility:public"], deps = [ ":TestImports-App_framework_unlinked", - ], + ] + select({ + # Note: without using apple_framework, it won't set enable_framework_vfs + # imported it won't actually be seen + "@build_bazel_rules_ios//:virtualize_frameworks": [":SomeFramework"], + "//conditions:default": [], + }), )