Skip to content

Commit 76752fe

Browse files
authored
Add swift_clang_module_aspect to apple_static_xcframework_import deps
This is the same fix as #1175 for nested static xcframework imports.
1 parent 74aa76e commit 76752fe

5 files changed

Lines changed: 77 additions & 0 deletions

File tree

apple/internal/apple_xcframework_import.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,7 @@ linked into that target.
726726
[apple_common.Objc, CcInfo],
727727
[apple_common.Objc, CcInfo, AppleFrameworkImportInfo],
728728
],
729+
aspects = [swift_clang_module_aspect],
729730
),
730731
"has_swift": attr.bool(
731732
doc = """

test/starlark_tests/apple_static_xcframework_import_tests.bzl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ def apple_static_xcframework_import_test_suite(name):
2323
name: the base name to be used in things created by this macro
2424
"""
2525

26+
# Verify the dependent app target successfully builds
27+
archive_contents_test(
28+
name = "{}_swift_multi_level_static_xcframework".format(name),
29+
target_under_test = "//test/starlark_tests/targets_under_test/ios:app_with_swift_multi_level_static_xcframework",
30+
contains = ["$ARCHIVE_ROOT/Payload"],
31+
build_type = "simulator",
32+
tags = [name],
33+
)
34+
2635
# Verify ios_application with XCFramework with static library dependency contains symbols and
2736
# does not bundle anything under Frameworks/
2837
archive_contents_test(

test/starlark_tests/targets_under_test/apple/BUILD

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,3 +1264,17 @@ apple_static_xcframework_import(
12641264
visibility = ["//visibility:public"],
12651265
xcframework_imports = ["//test/testdata/xcframeworks:generated_swift_static_xcframework_without_swiftmodule"],
12661266
)
1267+
1268+
apple_static_xcframework_import(
1269+
name = "ios_imported_static_xcframework_base",
1270+
tags = TARGETS_UNDER_TEST_TAGS,
1271+
xcframework_imports = ["//test/testdata/xcframeworks:generated_static_xcframework_base"],
1272+
)
1273+
1274+
apple_static_xcframework_import(
1275+
name = "ios_imported_static_xcframework_depends_on_base",
1276+
tags = TARGETS_UNDER_TEST_TAGS,
1277+
visibility = ["//visibility:public"],
1278+
xcframework_imports = ["//test/testdata/xcframeworks:generated_static_xcframework_depends_on_base"],
1279+
deps = [":ios_imported_static_xcframework_base"],
1280+
)

test/starlark_tests/targets_under_test/ios/BUILD

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2023,6 +2023,34 @@ EOF
20232023
""",
20242024
)
20252025

2026+
swift_library(
2027+
name = "swift_multi_level_static_xcframework",
2028+
srcs = [":swift_multi_level_static_xcframework_src"],
2029+
tags = FIXTURE_TAGS,
2030+
deps = [
2031+
"//test/starlark_tests/targets_under_test/apple:ios_imported_static_xcframework_depends_on_base",
2032+
],
2033+
)
2034+
2035+
genrule(
2036+
name = "swift_multi_level_static_xcframework_src",
2037+
outs = ["SwiftMultiLevelStaticXCFramework.swift"],
2038+
cmd = "echo 'import generated_static_xcframework_depends_on_base' > $(OUTS)",
2039+
)
2040+
2041+
ios_application(
2042+
name = "app_with_swift_multi_level_static_xcframework",
2043+
bundle_id = "com.google.example",
2044+
families = ["iphone"],
2045+
infoplists = ["//test/starlark_tests/resources:Info.plist"],
2046+
minimum_os_version = "11.0",
2047+
tags = FIXTURE_TAGS,
2048+
deps = [
2049+
":swift_multi_level_static_xcframework",
2050+
"//test/starlark_tests/resources:swift_main_lib",
2051+
],
2052+
)
2053+
20262054
# ---------------------------------------------------------------------------------------
20272055

20282056
ios_imessage_application(

test/testdata/xcframeworks/BUILD

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ load("//test/starlark_tests:common.bzl", "FIXTURE_TAGS")
33
load(
44
"//test/testdata/xcframeworks:generate_xcframework.bzl",
55
"generate_dynamic_xcframework",
6+
"generate_static_framework_xcframework",
67
"generate_static_xcframework",
78
)
89
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
@@ -123,6 +124,30 @@ generate_static_xcframework(
123124
tags = FIXTURE_TAGS,
124125
)
125126

127+
generate_static_framework_xcframework(
128+
name = "generated_static_xcframework_base",
129+
srcs = ["//test/testdata/fmwk:objc_source"],
130+
hdrs = ["//test/testdata/fmwk:objc_headers"],
131+
minimum_os_versions = {"ios_simulator": "11.0"},
132+
platforms = {"ios_simulator": ["x86_64"]},
133+
tags = FIXTURE_TAGS,
134+
)
135+
136+
genrule(
137+
name = "generated_static_xcframework_depends_on_base_header",
138+
outs = ["generated_static_xcframework_depends_on_base_header.h"],
139+
cmd = "echo '@import generated_static_xcframework_base;' > $(OUTS)",
140+
)
141+
142+
generate_static_framework_xcframework(
143+
name = "generated_static_xcframework_depends_on_base",
144+
srcs = ["@bazel_tools//tools/objc:objc_dummy.mm"],
145+
hdrs = ["generated_static_xcframework_depends_on_base_header"],
146+
minimum_os_versions = {"ios_simulator": "11.0"},
147+
platforms = {"ios_simulator": ["x86_64"]},
148+
tags = FIXTURE_TAGS,
149+
)
150+
126151
bzl_library(
127152
name = "generate_xcframework_bzl",
128153
srcs = ["generate_xcframework.bzl"],

0 commit comments

Comments
 (0)