From 488aea4878489075d9f7d4a17de376ca0de38a5f Mon Sep 17 00:00:00 2001
From: John Flanagan <91548783+jflan-dd@users.noreply.github.com>
Date: Mon, 22 Apr 2024 16:53:05 -0500
Subject: [PATCH] fix: follow symlinks when searching for xcframework
directories (#983)
One of the packages we depend on puts its XCFramework behind a symlink
for some reason. Without this change rspm doesn't follow the symlink to
find the contents of the actual framework.
mimic behavior of
[_list_files_under](https://github.com/cgrindel/rules_swift_package_manager/blob/85a704df7fb25d861ba8e54a584c08e07a7de748/swiftpkg/internal/repository_files.bzl#L44-L45)
---
.bazelrc | 4 +-
.github/workflows/ci.yml | 2 +
examples/example_infos.bzl | 1 +
examples/symlink_example/.bazelrc | 8 +
examples/symlink_example/BUILD.bazel | 37 +++++
examples/symlink_example/MODULE.bazel | 54 +++++++
examples/symlink_example/Package.swift | 10 ++
examples/symlink_example/README.md | 4 +
.../Sources/ImportFramework/BUILD.bazel | 9 ++
.../Sources/ImportFramework/Import.swift | 3 +
.../Tests/ImportFrameworkTests/BUILD.bazel | 17 +++
.../ImportFrameworkTests.swift | 8 +
examples/symlink_example/WORKSPACE | 1 +
examples/symlink_example/WORKSPACE.bzlmod | 2 +
examples/symlink_example/do_test | 16 ++
.../symlink_example/swift_deps_index.json | 34 +++++
.../EmptyFramework.xcframework | 1 +
.../EmptyFramework.xcframework/Info.plist | 59 ++++++++
.../EmptyFramework.framework/EmptyFramework | Bin 0 -> 51744 bytes
.../Headers/EmptyFramework.h | 18 +++
.../EmptyFramework.framework/Info.plist | Bin 0 -> 755 bytes
.../Modules/module.modulemap | 6 +
.../_CodeSignature/CodeResources | 124 +++++++++++++++
.../EmptyFramework.framework/EmptyFramework | Bin 0 -> 100576 bytes
.../Headers/EmptyFramework.h | 18 +++
.../EmptyFramework.framework/Info.plist | Bin 0 -> 735 bytes
.../Modules/module.modulemap | 6 +
.../_CodeSignature/CodeResources | 124 +++++++++++++++
.../EmptyFramework.framework/EmptyFramework | Bin 0 -> 100768 bytes
.../Headers/EmptyFramework.h | 18 +++
.../Modules/module.modulemap | 6 +
.../Resources/Info.plist | 46 ++++++
.../Versions/A/EmptyFramework | Bin 0 -> 100768 bytes
.../Versions/A/Headers/EmptyFramework.h | 18 +++
.../Versions/A/Modules/module.modulemap | 6 +
.../Versions/A/Resources/Info.plist | 46 ++++++
.../Versions/A/_CodeSignature/CodeResources | 142 ++++++++++++++++++
.../Versions/Current/EmptyFramework | Bin 0 -> 100768 bytes
.../Versions/Current/Headers/EmptyFramework.h | 18 +++
.../Versions/Current/Modules/module.modulemap | 6 +
.../Versions/Current/Resources/Info.plist | 46 ++++++
.../Current/_CodeSignature/CodeResources | 142 ++++++++++++++++++
.../third_party/empty_framework/Package.swift | 13 ++
swiftpkg/internal/repository_files.bzl | 4 +-
44 files changed, 1074 insertions(+), 3 deletions(-)
create mode 100644 examples/symlink_example/.bazelrc
create mode 100644 examples/symlink_example/BUILD.bazel
create mode 100644 examples/symlink_example/MODULE.bazel
create mode 100644 examples/symlink_example/Package.swift
create mode 100644 examples/symlink_example/README.md
create mode 100644 examples/symlink_example/Sources/ImportFramework/BUILD.bazel
create mode 100644 examples/symlink_example/Sources/ImportFramework/Import.swift
create mode 100644 examples/symlink_example/Tests/ImportFrameworkTests/BUILD.bazel
create mode 100644 examples/symlink_example/Tests/ImportFrameworkTests/ImportFrameworkTests.swift
create mode 100644 examples/symlink_example/WORKSPACE
create mode 100644 examples/symlink_example/WORKSPACE.bzlmod
create mode 100755 examples/symlink_example/do_test
create mode 100644 examples/symlink_example/swift_deps_index.json
create mode 120000 examples/symlink_example/third_party/empty_framework/EmptyFramework.xcframework
create mode 100644 examples/symlink_example/third_party/empty_framework/Framework/EmptyFramework.xcframework/Info.plist
create mode 100755 examples/symlink_example/third_party/empty_framework/Framework/EmptyFramework.xcframework/ios-arm64/EmptyFramework.framework/EmptyFramework
create mode 100644 examples/symlink_example/third_party/empty_framework/Framework/EmptyFramework.xcframework/ios-arm64/EmptyFramework.framework/Headers/EmptyFramework.h
create mode 100644 examples/symlink_example/third_party/empty_framework/Framework/EmptyFramework.xcframework/ios-arm64/EmptyFramework.framework/Info.plist
create mode 100644 examples/symlink_example/third_party/empty_framework/Framework/EmptyFramework.xcframework/ios-arm64/EmptyFramework.framework/Modules/module.modulemap
create mode 100644 examples/symlink_example/third_party/empty_framework/Framework/EmptyFramework.xcframework/ios-arm64/EmptyFramework.framework/_CodeSignature/CodeResources
create mode 100755 examples/symlink_example/third_party/empty_framework/Framework/EmptyFramework.xcframework/ios-arm64_x86_64-simulator/EmptyFramework.framework/EmptyFramework
create mode 100644 examples/symlink_example/third_party/empty_framework/Framework/EmptyFramework.xcframework/ios-arm64_x86_64-simulator/EmptyFramework.framework/Headers/EmptyFramework.h
create mode 100644 examples/symlink_example/third_party/empty_framework/Framework/EmptyFramework.xcframework/ios-arm64_x86_64-simulator/EmptyFramework.framework/Info.plist
create mode 100644 examples/symlink_example/third_party/empty_framework/Framework/EmptyFramework.xcframework/ios-arm64_x86_64-simulator/EmptyFramework.framework/Modules/module.modulemap
create mode 100644 examples/symlink_example/third_party/empty_framework/Framework/EmptyFramework.xcframework/ios-arm64_x86_64-simulator/EmptyFramework.framework/_CodeSignature/CodeResources
create mode 100755 examples/symlink_example/third_party/empty_framework/Framework/EmptyFramework.xcframework/macos-arm64_x86_64/EmptyFramework.framework/EmptyFramework
create mode 100644 examples/symlink_example/third_party/empty_framework/Framework/EmptyFramework.xcframework/macos-arm64_x86_64/EmptyFramework.framework/Headers/EmptyFramework.h
create mode 100644 examples/symlink_example/third_party/empty_framework/Framework/EmptyFramework.xcframework/macos-arm64_x86_64/EmptyFramework.framework/Modules/module.modulemap
create mode 100644 examples/symlink_example/third_party/empty_framework/Framework/EmptyFramework.xcframework/macos-arm64_x86_64/EmptyFramework.framework/Resources/Info.plist
create mode 100755 examples/symlink_example/third_party/empty_framework/Framework/EmptyFramework.xcframework/macos-arm64_x86_64/EmptyFramework.framework/Versions/A/EmptyFramework
create mode 100644 examples/symlink_example/third_party/empty_framework/Framework/EmptyFramework.xcframework/macos-arm64_x86_64/EmptyFramework.framework/Versions/A/Headers/EmptyFramework.h
create mode 100644 examples/symlink_example/third_party/empty_framework/Framework/EmptyFramework.xcframework/macos-arm64_x86_64/EmptyFramework.framework/Versions/A/Modules/module.modulemap
create mode 100644 examples/symlink_example/third_party/empty_framework/Framework/EmptyFramework.xcframework/macos-arm64_x86_64/EmptyFramework.framework/Versions/A/Resources/Info.plist
create mode 100644 examples/symlink_example/third_party/empty_framework/Framework/EmptyFramework.xcframework/macos-arm64_x86_64/EmptyFramework.framework/Versions/A/_CodeSignature/CodeResources
create mode 100755 examples/symlink_example/third_party/empty_framework/Framework/EmptyFramework.xcframework/macos-arm64_x86_64/EmptyFramework.framework/Versions/Current/EmptyFramework
create mode 100644 examples/symlink_example/third_party/empty_framework/Framework/EmptyFramework.xcframework/macos-arm64_x86_64/EmptyFramework.framework/Versions/Current/Headers/EmptyFramework.h
create mode 100644 examples/symlink_example/third_party/empty_framework/Framework/EmptyFramework.xcframework/macos-arm64_x86_64/EmptyFramework.framework/Versions/Current/Modules/module.modulemap
create mode 100644 examples/symlink_example/third_party/empty_framework/Framework/EmptyFramework.xcframework/macos-arm64_x86_64/EmptyFramework.framework/Versions/Current/Resources/Info.plist
create mode 100644 examples/symlink_example/third_party/empty_framework/Framework/EmptyFramework.xcframework/macos-arm64_x86_64/EmptyFramework.framework/Versions/Current/_CodeSignature/CodeResources
create mode 100644 examples/symlink_example/third_party/empty_framework/Package.swift
diff --git a/.bazelrc b/.bazelrc
index 4331f29ca..6a4e3408a 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -1,7 +1,7 @@
# To update these lines, execute
# `bazel run @rules_bazel_integration_test//tools:update_deleted_packages`
-build --deleted_packages=bzlmod/workspace,bzlmod/workspace/Sources/MyExecutable,bzlmod/workspace/Sources/MyLibrary,bzlmod/workspace/Sources/System,bzlmod/workspace/Tests/MyLibraryTests,examples/firebase_example,examples/firebase_example/abtesting,examples/firebase_example/abtesting/SharedApp,examples/firebase_example/analytics/AnalyticsExample,examples/firebase_example/appdistribution,examples/firebase_example/appdistribution/AppDistributionExample,examples/firebase_example/appdistribution/AppDistributionTests,examples/firebase_example/crashlytics,examples/grpc_example,examples/grpc_example/aaa_test,examples/grpc_example/protos,examples/grpc_example/protos/echo_service,examples/grpc_example/protos/echo_service/requests,examples/grpc_example/protos/echo_service/responses,examples/grpc_example/sources,examples/grpc_example/sources/client,examples/grpc_example/sources/server,examples/grpc_example/sources/test,examples/grpc_package_example,examples/grpc_package_example/aaa_test,examples/grpc_package_example/protos,examples/grpc_package_example/protos/echo_service,examples/grpc_package_example/sources,examples/grpc_package_example/sources/client,examples/grpc_package_example/sources/server,examples/grpc_package_example/sources/test,examples/http_archive_ext_deps,examples/http_archive_ext_deps/Sources/MyDequeModule,examples/http_archive_ext_deps/Sources/PrintStuff,examples/http_archive_ext_deps/Tests/MyDequeModuleTests,examples/http_archive_ext_deps/third_party,examples/interesting_deps,examples/ios_sim,examples/ios_sim/Sources/Foo,examples/ios_sim/Tests/FooTests,examples/ios_sim/third-party/swift-cmark,examples/lottie_ios_example,examples/lottie_ios_example/LottieExample,examples/lottie_ios_example/LottieExampleUITest,examples/messagekit_example,examples/messagekit_example/Sources,examples/messagekit_example/UITests,examples/nimble_example,examples/nimble_example/Sources/NimbleExample,examples/objc_code,examples/phone_number_kit,examples/phone_number_kit/Tests/PhoneNumberKitTests,examples/pkg_manifest_minimal,examples/pkg_manifest_minimal/Sources/MyExecutable,examples/pkg_manifest_minimal/Sources/MyLibrary,examples/pkg_manifest_minimal/Tests/MyLibraryTests,examples/pkg_manifest_minimal/third_party,examples/resources_example,examples/resources_example/Sources/MyApp,examples/resources_example/Tests/MyAppTests,examples/resources_example/Tests/MyAppUITests,examples/resources_example/third_party,examples/shake_ios_example,examples/shake_ios_example/ShakeIOSExample,examples/shake_ios_example/ShakeIOSExampleUITests,examples/snapkit_example,examples/soto_example,examples/soto_example/Tests/SotoTests,examples/stripe_example,examples/stripe_example/PaymentSheet/PaymentSheetExample,examples/stripe_example/PaymentSheet/PaymentSheetUITest,examples/tca_example,examples/tca_example/Sources,examples/tca_example/Tests,examples/vapor_example,examples/vapor_example/Sources/App,examples/vapor_example/Sources/Run,examples/vapor_example/Tests/AppTests,examples/vapor_example/swift,examples/xcmetrics_example
-query --deleted_packages=bzlmod/workspace,bzlmod/workspace/Sources/MyExecutable,bzlmod/workspace/Sources/MyLibrary,bzlmod/workspace/Sources/System,bzlmod/workspace/Tests/MyLibraryTests,examples/firebase_example,examples/firebase_example/abtesting,examples/firebase_example/abtesting/SharedApp,examples/firebase_example/analytics/AnalyticsExample,examples/firebase_example/appdistribution,examples/firebase_example/appdistribution/AppDistributionExample,examples/firebase_example/appdistribution/AppDistributionTests,examples/firebase_example/crashlytics,examples/grpc_example,examples/grpc_example/aaa_test,examples/grpc_example/protos,examples/grpc_example/protos/echo_service,examples/grpc_example/protos/echo_service/requests,examples/grpc_example/protos/echo_service/responses,examples/grpc_example/sources,examples/grpc_example/sources/client,examples/grpc_example/sources/server,examples/grpc_example/sources/test,examples/grpc_package_example,examples/grpc_package_example/aaa_test,examples/grpc_package_example/protos,examples/grpc_package_example/protos/echo_service,examples/grpc_package_example/sources,examples/grpc_package_example/sources/client,examples/grpc_package_example/sources/server,examples/grpc_package_example/sources/test,examples/http_archive_ext_deps,examples/http_archive_ext_deps/Sources/MyDequeModule,examples/http_archive_ext_deps/Sources/PrintStuff,examples/http_archive_ext_deps/Tests/MyDequeModuleTests,examples/http_archive_ext_deps/third_party,examples/interesting_deps,examples/ios_sim,examples/ios_sim/Sources/Foo,examples/ios_sim/Tests/FooTests,examples/ios_sim/third-party/swift-cmark,examples/lottie_ios_example,examples/lottie_ios_example/LottieExample,examples/lottie_ios_example/LottieExampleUITest,examples/messagekit_example,examples/messagekit_example/Sources,examples/messagekit_example/UITests,examples/nimble_example,examples/nimble_example/Sources/NimbleExample,examples/objc_code,examples/phone_number_kit,examples/phone_number_kit/Tests/PhoneNumberKitTests,examples/pkg_manifest_minimal,examples/pkg_manifest_minimal/Sources/MyExecutable,examples/pkg_manifest_minimal/Sources/MyLibrary,examples/pkg_manifest_minimal/Tests/MyLibraryTests,examples/pkg_manifest_minimal/third_party,examples/resources_example,examples/resources_example/Sources/MyApp,examples/resources_example/Tests/MyAppTests,examples/resources_example/Tests/MyAppUITests,examples/resources_example/third_party,examples/shake_ios_example,examples/shake_ios_example/ShakeIOSExample,examples/shake_ios_example/ShakeIOSExampleUITests,examples/snapkit_example,examples/soto_example,examples/soto_example/Tests/SotoTests,examples/stripe_example,examples/stripe_example/PaymentSheet/PaymentSheetExample,examples/stripe_example/PaymentSheet/PaymentSheetUITest,examples/tca_example,examples/tca_example/Sources,examples/tca_example/Tests,examples/vapor_example,examples/vapor_example/Sources/App,examples/vapor_example/Sources/Run,examples/vapor_example/Tests/AppTests,examples/vapor_example/swift,examples/xcmetrics_example
+build --deleted_packages=bzlmod/workspace,bzlmod/workspace/Sources/MyExecutable,bzlmod/workspace/Sources/MyLibrary,bzlmod/workspace/Sources/System,bzlmod/workspace/Tests/MyLibraryTests,examples/firebase_example,examples/firebase_example/abtesting,examples/firebase_example/abtesting/SharedApp,examples/firebase_example/analytics/AnalyticsExample,examples/firebase_example/appdistribution,examples/firebase_example/appdistribution/AppDistributionExample,examples/firebase_example/appdistribution/AppDistributionTests,examples/firebase_example/crashlytics,examples/grpc_example,examples/grpc_example/aaa_test,examples/grpc_example/protos,examples/grpc_example/protos/echo_service,examples/grpc_example/protos/echo_service/requests,examples/grpc_example/protos/echo_service/responses,examples/grpc_example/sources,examples/grpc_example/sources/client,examples/grpc_example/sources/server,examples/grpc_example/sources/test,examples/grpc_package_example,examples/grpc_package_example/aaa_test,examples/grpc_package_example/protos,examples/grpc_package_example/protos/echo_service,examples/grpc_package_example/sources,examples/grpc_package_example/sources/client,examples/grpc_package_example/sources/server,examples/grpc_package_example/sources/test,examples/http_archive_ext_deps,examples/http_archive_ext_deps/Sources/MyDequeModule,examples/http_archive_ext_deps/Sources/PrintStuff,examples/http_archive_ext_deps/Tests/MyDequeModuleTests,examples/http_archive_ext_deps/third_party,examples/interesting_deps,examples/ios_sim,examples/ios_sim/Sources/Foo,examples/ios_sim/Tests/FooTests,examples/ios_sim/third-party/swift-cmark,examples/lottie_ios_example,examples/lottie_ios_example/LottieExample,examples/lottie_ios_example/LottieExampleUITest,examples/messagekit_example,examples/messagekit_example/Sources,examples/messagekit_example/UITests,examples/nimble_example,examples/nimble_example/Sources/NimbleExample,examples/objc_code,examples/phone_number_kit,examples/phone_number_kit/Tests/PhoneNumberKitTests,examples/pkg_manifest_minimal,examples/pkg_manifest_minimal/Sources/MyExecutable,examples/pkg_manifest_minimal/Sources/MyLibrary,examples/pkg_manifest_minimal/Tests/MyLibraryTests,examples/pkg_manifest_minimal/third_party,examples/resources_example,examples/resources_example/Sources/MyApp,examples/resources_example/Tests/MyAppTests,examples/resources_example/Tests/MyAppUITests,examples/resources_example/third_party,examples/shake_ios_example,examples/shake_ios_example/ShakeIOSExample,examples/shake_ios_example/ShakeIOSExampleUITests,examples/snapkit_example,examples/soto_example,examples/soto_example/Tests/SotoTests,examples/stripe_example,examples/stripe_example/PaymentSheet/PaymentSheetExample,examples/stripe_example/PaymentSheet/PaymentSheetUITest,examples/symlink_example,examples/symlink_example/Sources/ImportFramework,examples/symlink_example/Tests/ImportFrameworkTests,examples/tca_example,examples/tca_example/Sources,examples/tca_example/Tests,examples/vapor_example,examples/vapor_example/Sources/App,examples/vapor_example/Sources/Run,examples/vapor_example/Tests/AppTests,examples/vapor_example/swift,examples/xcmetrics_example
+query --deleted_packages=bzlmod/workspace,bzlmod/workspace/Sources/MyExecutable,bzlmod/workspace/Sources/MyLibrary,bzlmod/workspace/Sources/System,bzlmod/workspace/Tests/MyLibraryTests,examples/firebase_example,examples/firebase_example/abtesting,examples/firebase_example/abtesting/SharedApp,examples/firebase_example/analytics/AnalyticsExample,examples/firebase_example/appdistribution,examples/firebase_example/appdistribution/AppDistributionExample,examples/firebase_example/appdistribution/AppDistributionTests,examples/firebase_example/crashlytics,examples/grpc_example,examples/grpc_example/aaa_test,examples/grpc_example/protos,examples/grpc_example/protos/echo_service,examples/grpc_example/protos/echo_service/requests,examples/grpc_example/protos/echo_service/responses,examples/grpc_example/sources,examples/grpc_example/sources/client,examples/grpc_example/sources/server,examples/grpc_example/sources/test,examples/grpc_package_example,examples/grpc_package_example/aaa_test,examples/grpc_package_example/protos,examples/grpc_package_example/protos/echo_service,examples/grpc_package_example/sources,examples/grpc_package_example/sources/client,examples/grpc_package_example/sources/server,examples/grpc_package_example/sources/test,examples/http_archive_ext_deps,examples/http_archive_ext_deps/Sources/MyDequeModule,examples/http_archive_ext_deps/Sources/PrintStuff,examples/http_archive_ext_deps/Tests/MyDequeModuleTests,examples/http_archive_ext_deps/third_party,examples/interesting_deps,examples/ios_sim,examples/ios_sim/Sources/Foo,examples/ios_sim/Tests/FooTests,examples/ios_sim/third-party/swift-cmark,examples/lottie_ios_example,examples/lottie_ios_example/LottieExample,examples/lottie_ios_example/LottieExampleUITest,examples/messagekit_example,examples/messagekit_example/Sources,examples/messagekit_example/UITests,examples/nimble_example,examples/nimble_example/Sources/NimbleExample,examples/objc_code,examples/phone_number_kit,examples/phone_number_kit/Tests/PhoneNumberKitTests,examples/pkg_manifest_minimal,examples/pkg_manifest_minimal/Sources/MyExecutable,examples/pkg_manifest_minimal/Sources/MyLibrary,examples/pkg_manifest_minimal/Tests/MyLibraryTests,examples/pkg_manifest_minimal/third_party,examples/resources_example,examples/resources_example/Sources/MyApp,examples/resources_example/Tests/MyAppTests,examples/resources_example/Tests/MyAppUITests,examples/resources_example/third_party,examples/shake_ios_example,examples/shake_ios_example/ShakeIOSExample,examples/shake_ios_example/ShakeIOSExampleUITests,examples/snapkit_example,examples/soto_example,examples/soto_example/Tests/SotoTests,examples/stripe_example,examples/stripe_example/PaymentSheet/PaymentSheetExample,examples/stripe_example/PaymentSheet/PaymentSheetUITest,examples/symlink_example,examples/symlink_example/Sources/ImportFramework,examples/symlink_example/Tests/ImportFrameworkTests,examples/tca_example,examples/tca_example/Sources,examples/tca_example/Tests,examples/vapor_example,examples/vapor_example/Sources/App,examples/vapor_example/Sources/Run,examples/vapor_example/Tests/AppTests,examples/vapor_example/swift,examples/xcmetrics_example
# Import Shared settings
import %workspace%/shared.bazelrc
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 9624ad383..8a57d30ce 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -75,6 +75,8 @@ jobs:
runner: macos-13
- test: '@@//examples:stripe_example_test_bazel_.bazelversion'
runner: macos-13
+ - test: '@@//examples:symlink_example_test_bazel_.bazelversion'
+ runner: macos-13
- test: '@@//examples:tca_example_test_bazel_.bazelversion'
runner: macos-13
- test: '@@//examples:vapor_example_legacy_test_bazel_.bazelversion'
diff --git a/examples/example_infos.bzl b/examples/example_infos.bzl
index dfedba5dc..58d23c67e 100644
--- a/examples/example_infos.bzl
+++ b/examples/example_infos.bzl
@@ -154,6 +154,7 @@ _macos_single_bazel_version_test_examples = [
"stripe_example",
"xcmetrics_example",
"tca_example",
+ "symlink_example",
]
_linux_single_bazel_version_test_examples = []
diff --git a/examples/symlink_example/.bazelrc b/examples/symlink_example/.bazelrc
new file mode 100644
index 000000000..e9769fc7b
--- /dev/null
+++ b/examples/symlink_example/.bazelrc
@@ -0,0 +1,8 @@
+# Import Shared settings
+import %workspace%/../../shared.bazelrc
+
+# Import CI settings.
+import %workspace%/../../ci.bazelrc
+
+# Try to import a local.rc file; typically, written by CI
+try-import %workspace%/../../local.bazelrc
diff --git a/examples/symlink_example/BUILD.bazel b/examples/symlink_example/BUILD.bazel
new file mode 100644
index 000000000..d922d26bd
--- /dev/null
+++ b/examples/symlink_example/BUILD.bazel
@@ -0,0 +1,37 @@
+load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
+load("@cgrindel_bazel_starlib//bzltidy:defs.bzl", "tidy")
+load("@rules_swift_package_manager//swiftpkg:defs.bzl", "swift_update_packages")
+
+tidy(
+ name = "tidy",
+ targets = [
+ ":swift_update_pkgs",
+ ":update_build_files",
+ ],
+)
+
+# MARK: - Gazelle
+
+# Ignore the Swift build folder
+# gazelle:exclude .build
+
+gazelle_binary(
+ name = "gazelle_bin",
+ languages = [
+ "@bazel_skylib_gazelle_plugin//bzl",
+ "@rules_swift_package_manager//gazelle",
+ ],
+)
+
+gazelle(
+ name = "update_build_files",
+ gazelle = ":gazelle_bin",
+)
+
+swift_update_packages(
+ name = "swift_update_pkgs",
+ gazelle = ":gazelle_bin",
+ generate_swift_deps_for_workspace = False,
+ package_manifest = "Package.swift",
+ update_bzlmod_stanzas = True,
+)
diff --git a/examples/symlink_example/MODULE.bazel b/examples/symlink_example/MODULE.bazel
new file mode 100644
index 000000000..6448b9b83
--- /dev/null
+++ b/examples/symlink_example/MODULE.bazel
@@ -0,0 +1,54 @@
+bazel_dep(
+ name = "rules_swift_package_manager",
+ version = "0.0.0",
+)
+local_path_override(
+ module_name = "rules_swift_package_manager",
+ path = "../..",
+)
+
+bazel_dep(name = "cgrindel_bazel_starlib", version = "0.20.2")
+bazel_dep(name = "bazel_skylib", version = "1.5.0")
+bazel_dep(name = "apple_support", version = "1.15.1")
+bazel_dep(
+ name = "rules_swift",
+ version = "1.17.0",
+ repo_name = "build_bazel_rules_swift",
+)
+bazel_dep(
+ name = "rules_apple",
+ version = "3.4.0",
+ repo_name = "build_bazel_rules_apple",
+)
+
+bazel_dep(
+ name = "bazel_skylib_gazelle_plugin",
+ version = "1.5.0",
+ dev_dependency = True,
+)
+bazel_dep(
+ name = "gazelle",
+ version = "0.36.0",
+ dev_dependency = True,
+ repo_name = "bazel_gazelle",
+)
+
+apple_cc_configure = use_extension(
+ "@apple_support//crosstool:setup.bzl",
+ "apple_cc_configure_extension",
+)
+use_repo(apple_cc_configure, "local_config_apple_cc")
+
+# swift_deps START
+swift_deps = use_extension(
+ "@rules_swift_package_manager//:extensions.bzl",
+ "swift_deps",
+)
+swift_deps.from_file(
+ deps_index = "//:swift_deps_index.json",
+)
+use_repo(
+ swift_deps,
+ "swiftpkg_empty_framework",
+)
+# swift_deps END
diff --git a/examples/symlink_example/Package.swift b/examples/symlink_example/Package.swift
new file mode 100644
index 000000000..da92484fa
--- /dev/null
+++ b/examples/symlink_example/Package.swift
@@ -0,0 +1,10 @@
+// swift-tools-version: 5.7
+
+import PackageDescription
+
+let package = Package(
+ name: "symlink_example",
+ dependencies: [
+ .package(path: "third_party/empty_framework"),
+ ]
+)
diff --git a/examples/symlink_example/README.md b/examples/symlink_example/README.md
new file mode 100644
index 000000000..4f5877801
--- /dev/null
+++ b/examples/symlink_example/README.md
@@ -0,0 +1,4 @@
+# Symlink to XCFramework
+
+This example demonstrates using an external package that contains an XCFramework that is
+dependended on through a symlink.
diff --git a/examples/symlink_example/Sources/ImportFramework/BUILD.bazel b/examples/symlink_example/Sources/ImportFramework/BUILD.bazel
new file mode 100644
index 000000000..99203452e
--- /dev/null
+++ b/examples/symlink_example/Sources/ImportFramework/BUILD.bazel
@@ -0,0 +1,9 @@
+load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
+
+swift_library(
+ name = "ImportFramework",
+ srcs = ["Import.swift"],
+ module_name = "ImportFramework",
+ visibility = ["//visibility:public"],
+ deps = ["@swiftpkg_empty_framework//:EmptyFramework"],
+)
diff --git a/examples/symlink_example/Sources/ImportFramework/Import.swift b/examples/symlink_example/Sources/ImportFramework/Import.swift
new file mode 100644
index 000000000..919d3cdd7
--- /dev/null
+++ b/examples/symlink_example/Sources/ImportFramework/Import.swift
@@ -0,0 +1,3 @@
+import EmptyFramework
+
+func getFrameworkVersion() -> Double { EmptyFrameworkVersionNumber }
diff --git a/examples/symlink_example/Tests/ImportFrameworkTests/BUILD.bazel b/examples/symlink_example/Tests/ImportFrameworkTests/BUILD.bazel
new file mode 100644
index 000000000..204638c56
--- /dev/null
+++ b/examples/symlink_example/Tests/ImportFrameworkTests/BUILD.bazel
@@ -0,0 +1,17 @@
+load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test")
+load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
+
+swift_library(
+ name = "ImportFrameworkTestsLib",
+ testonly = True,
+ srcs = ["ImportFrameworkTests.swift"],
+ module_name = "ImportFrameworkTests",
+ tags = ["manual"],
+ deps = ["//Sources/ImportFramework"],
+)
+
+ios_unit_test(
+ name = "ImportFrameworkTests",
+ minimum_os_version = "15.0",
+ deps = [":ImportFrameworkTestsLib"],
+)
diff --git a/examples/symlink_example/Tests/ImportFrameworkTests/ImportFrameworkTests.swift b/examples/symlink_example/Tests/ImportFrameworkTests/ImportFrameworkTests.swift
new file mode 100644
index 000000000..71ff49af9
--- /dev/null
+++ b/examples/symlink_example/Tests/ImportFrameworkTests/ImportFrameworkTests.swift
@@ -0,0 +1,8 @@
+import XCTest
+@testable import ImportFramework
+
+final class ImportFrameworkTests: XCTestCase {
+ func testVersionNumber() throws {
+ XCTAssertEqual(getFrameworkVersion(), 1.0)
+ }
+}
diff --git a/examples/symlink_example/WORKSPACE b/examples/symlink_example/WORKSPACE
new file mode 100644
index 000000000..d251ab7ba
--- /dev/null
+++ b/examples/symlink_example/WORKSPACE
@@ -0,0 +1 @@
+# Intentionally blank: Using bzlmod
diff --git a/examples/symlink_example/WORKSPACE.bzlmod b/examples/symlink_example/WORKSPACE.bzlmod
new file mode 100644
index 000000000..8cf89c330
--- /dev/null
+++ b/examples/symlink_example/WORKSPACE.bzlmod
@@ -0,0 +1,2 @@
+# Intentionally blank
+# This exists to force Bazel in bzlmod mode to be strict.
diff --git a/examples/symlink_example/do_test b/examples/symlink_example/do_test
new file mode 100755
index 000000000..204191a89
--- /dev/null
+++ b/examples/symlink_example/do_test
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+
+set -o errexit -o nounset -o pipefail
+
+script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd)"
+
+# Use the Bazel binary specified by the integration test. Otherise, fall back
+# to bazel.
+bazel="${BIT_BAZEL_BINARY:-bazel}"
+
+# Generate Swift external deps and update build files
+"${bazel}" run //:tidy
+"${bazel}" run //:swift_update_pkgs
+
+# Ensure that it builds and tests pass
+"${bazel}" test //...
diff --git a/examples/symlink_example/swift_deps_index.json b/examples/symlink_example/swift_deps_index.json
new file mode 100644
index 000000000..9f3ccad5b
--- /dev/null
+++ b/examples/symlink_example/swift_deps_index.json
@@ -0,0 +1,34 @@
+{
+ "direct_dep_identities": [
+ "empty_framework"
+ ],
+ "modules": [
+ {
+ "name": "EmptyFramework",
+ "c99name": "EmptyFramework",
+ "src_type": "binary",
+ "label": "@swiftpkg_empty_framework//:EmptyFramework.rspm",
+ "package_identity": "empty_framework",
+ "product_memberships": [
+ "EmptyFramework"
+ ]
+ }
+ ],
+ "products": [
+ {
+ "identity": "empty_framework",
+ "name": "EmptyFramework",
+ "type": "library",
+ "label": "@swiftpkg_empty_framework//:EmptyFramework"
+ }
+ ],
+ "packages": [
+ {
+ "name": "swiftpkg_empty_framework",
+ "identity": "empty_framework",
+ "local": {
+ "path": "third_party/empty_framework"
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/examples/symlink_example/third_party/empty_framework/EmptyFramework.xcframework b/examples/symlink_example/third_party/empty_framework/EmptyFramework.xcframework
new file mode 120000
index 000000000..48d9b2b63
--- /dev/null
+++ b/examples/symlink_example/third_party/empty_framework/EmptyFramework.xcframework
@@ -0,0 +1 @@
+Framework/EmptyFramework.xcframework
\ No newline at end of file
diff --git a/examples/symlink_example/third_party/empty_framework/Framework/EmptyFramework.xcframework/Info.plist b/examples/symlink_example/third_party/empty_framework/Framework/EmptyFramework.xcframework/Info.plist
new file mode 100644
index 000000000..e81d49e4b
--- /dev/null
+++ b/examples/symlink_example/third_party/empty_framework/Framework/EmptyFramework.xcframework/Info.plist
@@ -0,0 +1,59 @@
+
+
+
+
+ AvailableLibraries
+
+
+ BinaryPath
+ EmptyFramework.framework/EmptyFramework
+ LibraryIdentifier
+ ios-arm64
+ LibraryPath
+ EmptyFramework.framework
+ SupportedArchitectures
+
+ arm64
+
+ SupportedPlatform
+ ios
+
+
+ BinaryPath
+ EmptyFramework.framework/Versions/A/EmptyFramework
+ LibraryIdentifier
+ macos-arm64_x86_64
+ LibraryPath
+ EmptyFramework.framework
+ SupportedArchitectures
+
+ arm64
+ x86_64
+
+ SupportedPlatform
+ macos
+
+
+ BinaryPath
+ EmptyFramework.framework/EmptyFramework
+ LibraryIdentifier
+ ios-arm64_x86_64-simulator
+ LibraryPath
+ EmptyFramework.framework
+ SupportedArchitectures
+
+ arm64
+ x86_64
+
+ SupportedPlatform
+ ios
+ SupportedPlatformVariant
+ simulator
+
+
+ CFBundlePackageType
+ XFWK
+ XCFrameworkFormatVersion
+ 1.0
+
+
diff --git a/examples/symlink_example/third_party/empty_framework/Framework/EmptyFramework.xcframework/ios-arm64/EmptyFramework.framework/EmptyFramework b/examples/symlink_example/third_party/empty_framework/Framework/EmptyFramework.xcframework/ios-arm64/EmptyFramework.framework/EmptyFramework
new file mode 100755
index 0000000000000000000000000000000000000000..d37196f42667670042539130579f144c2be9b339
GIT binary patch
literal 51744
zcmeI52~-o;yTE6X01^UW6BI;76hwt&!oG0<0LO`(g-}heM`Tx&5=ey_JnfrbB-tW%+&D`&P
zlXGCsy>07cVHl2~q>i#4$^+;awh+^$RMzkUc$Q~yXrb;rUvSdztcj==F
z40FJ+T;(0e#V{9S%U&hBAeoP3iYqlnZf;k36FT#etc7wY%DofSmdgK|WQsab-HYihelo!dT3S9|3
zd&>Dyb(AgK(*->?IL6J8%eX0taa0b^mMbKwoUt5nHj=vf4MJ15Mn$SWUy>yeWhjJk
zDUui^f00e*l5C8%|00;m9AOHk_01yBIKmZ5;0U!Vb
zfB+Bx0zd!=00AHX1b_e#00KY&2mk>f00e*l5C8%|00;m9AOHk_!2dA;zV*-%pf00e*l5C8%|00;m9AOHk_01yBI
zKmZ5;0U!VbfB+Bx0zd!=00AHX1b_e#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