Skip to content

Commit b194745

Browse files
fix: Ignore invalid xcframework paths (#1440)
The rules should ignore invalid `.xcframework` paths like SPM does ([see here](https://github.com/swiftlang/swift-package-manager/blob/c26c12f54357fb7246c0bdbe3483105389f056b8/Sources/Workspace/Workspace%2BBinaryArtifacts.swift#L771-L780)). Unlike SPM however, in Starlark we do not have a readily available `.plist` decoder so we will simply ensure that an `Info.plist` file exists and let the build rules handle potential issues. This fixes cases where I was getting warnings because our .zip file contains a `__MACOSX` directory that contains a `.xcframework` directory (this is used for metadata by macOS). All the files are prefixed with `._` so the Info.plist check here fixes including these bad paths in our search. ``` DEBUG: /private/var/tmp/_bazel_lpadron/9ae9416857eb79bb978de35a53d54970/external/rules_swift_package_manager~/swiftpkg/internal/repo_rules.bzl:156:14: WARNING: Found multiple XCFramework binary artifacts in the downloaded artifact: ["remote/archive/AppsFlyerLib-Dynamic.xcframework.zip/__MACOSX/AppsFlyerLib.xcframework", "remote/archive/AppsFlyerLib-Dynamic.xcframework.zip/AppsFlyerLib.xcframework"], using the last one. ``` Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 9fc5882 commit b194745

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

swiftpkg/internal/repo_rules.bzl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,17 @@ def _artifact_infos_from_path(repository_ctx, path):
139139
by_name = "*.xcframework",
140140
)
141141

142+
# NOTE: SPM validates the `.xcframework` paths by decoding the `Info.plist` file.
143+
# This would be more involved to do in Starlark, so instead we'll assume
144+
# that a `.xcframework` dir is a potential candidate if it contains a
145+
# `Info.plist` file without checking the file contents.
146+
# See: https://github.com/swiftlang/swift-package-manager/blob/c26c12f54357fb7246c0bdbe3483105389f056b8/Sources/Workspace/Workspace%2BBinaryArtifacts.swift#L771-L780
147+
xcframework_dirs = [
148+
xf
149+
for xf in xcframework_dirs
150+
if repository_files.path_exists(repository_ctx, paths.join(xf, "Info.plist"))
151+
]
152+
142153
# If multiple found, use the last one which is what SPM currently does:
143154
# https://github.com/swiftlang/swift-package-manager/blob/c26c12f54357fb7246c0bdbe3483105389f056b8/Sources/Workspace/Workspace%2BBinaryArtifacts.swift#L699-L723
144155
if len(xcframework_dirs) > 1:

0 commit comments

Comments
 (0)