From 6c6a5d2d39270606043f283916f0d327f6f8fa7f Mon Sep 17 00:00:00 2001 From: Reinhard Huang Date: Wed, 21 Feb 2024 16:56:37 +0800 Subject: [PATCH 1/2] fix dynamic framework loss in implementation_deps --- apple/internal/aspects/framework_provider_aspect.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apple/internal/aspects/framework_provider_aspect.bzl b/apple/internal/aspects/framework_provider_aspect.bzl index e8c5846de6..26acc384ed 100644 --- a/apple/internal/aspects/framework_provider_aspect.bzl +++ b/apple/internal/aspects/framework_provider_aspect.bzl @@ -29,7 +29,7 @@ load( # these are supported by `objc_library` for frameworks that should be present in the bundle, but not # linked against. # TODO(b/120205406): Remove `runtime_deps` support to use objc_library/swift_library `data` instead. -_FRAMEWORK_PROVIDERS_ASPECT_ATTRS = ["deps", "frameworks", "private_deps", "runtime_deps", "data"] +_FRAMEWORK_PROVIDERS_ASPECT_ATTRS = ["deps", "frameworks", "private_deps", "implementation_deps", "runtime_deps", "data"] def _framework_provider_aspect_impl(target, ctx): """Implementation of the framework provider propagation aspect.""" From f8a87d4d371286aa88097c592461a4c766a03c10 Mon Sep 17 00:00:00 2001 From: Reinhard Huang Date: Thu, 22 Feb 2024 16:47:50 +0800 Subject: [PATCH 2/2] add archive_contents_test for xcframework with private_deps(swift_library) & implementation_deps(objc_library) --- ...apple_dynamic_xcframework_import_tests.bzl | 73 +++++++++++++ .../targets_under_test/ios/BUILD | 102 ++++++++++++++++++ 2 files changed, 175 insertions(+) diff --git a/test/starlark_tests/apple_dynamic_xcframework_import_tests.bzl b/test/starlark_tests/apple_dynamic_xcframework_import_tests.bzl index 72fa31b4c5..8a65068507 100644 --- a/test/starlark_tests/apple_dynamic_xcframework_import_tests.bzl +++ b/test/starlark_tests/apple_dynamic_xcframework_import_tests.bzl @@ -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", @@ -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", @@ -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", @@ -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( diff --git a/test/starlark_tests/targets_under_test/ios/BUILD b/test/starlark_tests/targets_under_test/ios/BUILD index f397b2615b..21993a1afb 100644 --- a/test/starlark_tests/targets_under_test/ios/BUILD +++ b/test/starlark_tests/targets_under_test/ios/BUILD @@ -2307,6 +2307,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", @@ -2348,6 +2374,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", @@ -2418,6 +2469,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", @@ -2459,6 +2536,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",