Skip to content

Commit

Permalink
add archive_contents_test for xcframework with private_deps(swift_lib…
Browse files Browse the repository at this point in the history
…rary) & implementation_deps(objc_library)
  • Loading branch information
xiemotongye committed Feb 23, 2024
1 parent eb7b9d4 commit 287fcf8
Show file tree
Hide file tree
Showing 2 changed files with 175 additions and 0 deletions.
73 changes: 73 additions & 0 deletions test/starlark_tests/apple_dynamic_xcframework_import_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,24 @@ def apple_dynamic_xcframework_import_test_suite(name):
],
tags = [name],
)
archive_contents_test(
name = "{}_contains_implementation_depending_imported_xcframework_framework_files".format(name),
build_type = "simulator",
target_under_test = "//test/starlark_tests/targets_under_test/ios:app_with_implementation_depending_imported_xcframework",
contains = [
"$BUNDLE_ROOT/Frameworks/generated_dynamic_xcframework_with_headers.framework/Info.plist",
"$BUNDLE_ROOT/Frameworks/generated_dynamic_xcframework_with_headers.framework/generated_dynamic_xcframework_with_headers",
],
not_contains = [
"$BUNDLE_ROOT/Frameworks/generated_dynamic_xcframework_with_headers.framework/Headers/",
"$BUNDLE_ROOT/Frameworks/generated_dynamic_xcframework_with_headers.framework/Modules/",
],
binary_test_file = "$BINARY",
macho_load_commands_contain = [
"name @rpath/generated_dynamic_xcframework_with_headers.framework/generated_dynamic_xcframework_with_headers (offset 24)",
],
tags = [name],
)
archive_contents_test(
name = "{}_swift_contains_imported_xcframework_framework_files".format(name),
build_type = "simulator",
Expand All @@ -82,6 +100,25 @@ def apple_dynamic_xcframework_import_test_suite(name):
],
tags = [name],
)
archive_contents_test(
name = "{}_swift_contains_private_depending_imported_xcframework_framework_files".format(name),
build_type = "simulator",
target_under_test = "//test/starlark_tests/targets_under_test/ios:swift_app_with_private_depending_imported_objc_xcframework",
contains = [
"$BUNDLE_ROOT/Frameworks/generated_dynamic_xcframework_with_headers.framework/Info.plist",
"$BUNDLE_ROOT/Frameworks/generated_dynamic_xcframework_with_headers.framework/generated_dynamic_xcframework_with_headers",
"$BUNDLE_ROOT/Frameworks/libswiftCore.dylib",
],
not_contains = [
"$BUNDLE_ROOT/Frameworks/generated_dynamic_xcframework_with_headers.framework/Headers/",
"$BUNDLE_ROOT/Frameworks/generated_dynamic_xcframework_with_headers.framework/Modules/",
],
binary_test_file = "$BINARY",
macho_load_commands_contain = [
"name @rpath/generated_dynamic_xcframework_with_headers.framework/generated_dynamic_xcframework_with_headers (offset 24)",
],
tags = [name],
)
archive_contents_test(
name = "{}_contains_imported_swift_xcframework_framework_files".format(name),
build_type = "simulator",
Expand All @@ -100,6 +137,24 @@ def apple_dynamic_xcframework_import_test_suite(name):
],
tags = [name],
)
archive_contents_test(
name = "{}_contains_implementation_depending_imported_swift_xcframework_framework_files".format(name),
build_type = "simulator",
target_under_test = "//test/starlark_tests/targets_under_test/ios:app_with_implementation_depending_imported_swift_xcframework",
contains = [
"$BUNDLE_ROOT/Frameworks/Swift3PFmwkWithGenHeader.framework/Info.plist",
"$BUNDLE_ROOT/Frameworks/Swift3PFmwkWithGenHeader.framework/Swift3PFmwkWithGenHeader",
],
not_contains = [
"$BUNDLE_ROOT/Frameworks/Swift3PFmwkWithGenHeader.framework/Headers/",
"$BUNDLE_ROOT/Frameworks/Swift3PFmwkWithGenHeader.framework/Modules/",
],
binary_test_file = "$BINARY",
macho_load_commands_contain = [
"name @rpath/Swift3PFmwkWithGenHeader.framework/Swift3PFmwkWithGenHeader (offset 24)",
],
tags = [name],
)
archive_contents_test(
name = "{}_swift_contains_imported_swift_xcframework_framework_files".format(name),
build_type = "simulator",
Expand All @@ -118,6 +173,24 @@ def apple_dynamic_xcframework_import_test_suite(name):
],
tags = [name],
)
archive_contents_test(
name = "{}_swift_contains_private_depending_imported_swift_xcframework_framework_files".format(name),
build_type = "simulator",
target_under_test = "//test/starlark_tests/targets_under_test/ios:swift_app_with_private_depending_imported_swift_xcframework",
contains = [
"$BUNDLE_ROOT/Frameworks/Swift3PFmwkWithGenHeader.framework/Info.plist",
"$BUNDLE_ROOT/Frameworks/Swift3PFmwkWithGenHeader.framework/Swift3PFmwkWithGenHeader",
],
not_contains = [
"$BUNDLE_ROOT/Frameworks/Swift3PFmwkWithGenHeader.framework/Headers/",
"$BUNDLE_ROOT/Frameworks/Swift3PFmwkWithGenHeader.framework/Modules/",
],
binary_test_file = "$BINARY",
macho_load_commands_contain = [
"name @rpath/Swift3PFmwkWithGenHeader.framework/Swift3PFmwkWithGenHeader (offset 24)",
],
tags = [name],
)

# Verify the correct XCFramework library was bundled and sliced for the required architecture.
binary_contents_test(
Expand Down
102 changes: 102 additions & 0 deletions test/starlark_tests/targets_under_test/ios/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2290,6 +2290,32 @@ objc_library(
deps = [":ios_imported_dynamic_xcframework"],
)

ios_application(
name = "app_with_implementation_depending_imported_xcframework",
bundle_id = "com.google.example",
families = [
"iphone",
"ipad",
],
infoplists = [
"//test/starlark_tests/resources:Info.plist",
],
minimum_os_version = common.min_os_ios.baseline,
provisioning_profile = "//test/testdata/provisioning:integration_testing_ios.mobileprovision",
tags = common.fixture_tags,
deps = [
":dynamic_xcframework_implementation_depending_lib",
"//test/starlark_tests/resources:objc_main_lib",
],
)

objc_library(
name = "dynamic_xcframework_implementation_depending_lib",
srcs = [":dynamic_xcframework_depending_lib_file"],
implementation_deps = [":ios_imported_dynamic_xcframework"],
tags = common.fixture_tags,
)

write_file(
name = "dynamic_xcframework_depending_lib_file",
out = "lib_with_imported_objc_xcframework.m",
Expand Down Expand Up @@ -2331,6 +2357,31 @@ swift_library(
deps = [":ios_imported_dynamic_xcframework"],
)

ios_application(
name = "swift_app_with_private_depending_imported_objc_xcframework",
bundle_id = "com.google.example",
families = [
"iphone",
"ipad",
],
infoplists = [
"//test/starlark_tests/resources:Info.plist",
],
minimum_os_version = common.min_os_ios.baseline,
tags = common.fixture_tags,
deps = [
":dynamic_objc_xcframework_private_depending_swift_lib",
"//test/starlark_tests/resources:swift_main_lib",
],
)

swift_library(
name = "dynamic_objc_xcframework_private_depending_swift_lib",
srcs = [":swift_with_framework_src"],
private_deps = [":ios_imported_dynamic_xcframework"],
tags = common.fixture_tags,
)

write_file(
name = "swift_with_framework_src",
out = "SwiftWithObjcFramework.swift",
Expand Down Expand Up @@ -2401,6 +2452,32 @@ objc_library(
deps = [":ios_imported_swift_dynamic_xcframework"],
)

ios_application(
name = "app_with_implementation_depending_imported_swift_xcframework",
bundle_id = "com.google.example",
families = [
"iphone",
"ipad",
],
infoplists = [
"//test/starlark_tests/resources:Info.plist",
],
minimum_os_version = common.min_os_ios.baseline,
provisioning_profile = "//test/testdata/provisioning:integration_testing_ios.mobileprovision",
tags = common.fixture_tags,
deps = [
":dynamic_swift_xcframework_implementation_depending_objc_lib",
"//test/starlark_tests/resources:objc_main_lib",
],
)

objc_library(
name = "dynamic_swift_xcframework_implementation_depending_objc_lib",
srcs = [":objc_with_framework_src"],
implementation_deps = [":ios_imported_swift_dynamic_xcframework"],
tags = common.fixture_tags,
)

write_file(
name = "objc_with_framework_src",
out = "ObjcWithFramework.m",
Expand Down Expand Up @@ -2442,6 +2519,31 @@ swift_library(
deps = [":ios_imported_swift_dynamic_xcframework"],
)

ios_application(
name = "swift_app_with_private_depending_imported_swift_xcframework",
bundle_id = "com.google.example",
families = [
"iphone",
"ipad",
],
infoplists = [
"//test/starlark_tests/resources:Info.plist",
],
minimum_os_version = common.min_os_ios.baseline,
tags = common.fixture_tags,
deps = [
":dynamic_swift_xcframework_private_depending_swift_lib",
"//test/starlark_tests/resources:swift_main_lib",
],
)

swift_library(
name = "dynamic_swift_xcframework_private_depending_swift_lib",
srcs = [":swift_with_dynamic_swift_framework_src"],
private_deps = [":ios_imported_swift_dynamic_xcframework"],
tags = common.fixture_tags,
)

write_file(
name = "swift_with_dynamic_swift_framework_src",
out = "SwiftWithDynamicSwiftFramework.swift",
Expand Down

0 comments on commit 287fcf8

Please sign in to comment.