swift-package-manager: SwiftPM can't properly download a binary dependency

Description

When adding https://bitbucket.org/usercentricscode/usercentrics-spm-sdk (a dependency that itself declares a zipped binary target), SwiftPM is unable to download the archive completely, reporting

Fetching https://bitbucket.org/usercentricscode/usercentrics-spm-sdk from cache
Fetched https://bitbucket.org/usercentricscode/usercentrics-spm-sdk (0.66s)
Computing version for https://bitbucket.org/usercentricscode/usercentrics-spm-sdk
Computed https://bitbucket.org/usercentricscode/usercentrics-spm-sdk at 2.8.1 (0.87s)
Creating working copy for https://bitbucket.org/usercentricscode/usercentrics-spm-sdk
Working copy of https://bitbucket.org/usercentricscode/usercentrics-spm-sdk resolved at 2.8.1
Downloading binary artifact https://bitbucket.org/usercentricscode/usercentrics-spm-sdk/downloads/Usercentrics-2.8.1.xcframework.zip
error: invalid archive returned from 'https://bitbucket.org/usercentricscode/usercentrics-spm-sdk/downloads/Usercentrics-2.8.1.xcframework.zip' which is required by binary target 'Usercentrics'

When investigating .build/artifacts/usercentrics-spm-sdk/Usercentrics, the Usercentrics-2.8.1.xcframework.zip file is not loaded completely (or correctly): wc reports only 6720 bytes, whereas the full archive is 12.4 MB.

unzip doesn’t work on it as a result with:

End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.

Downloading the archive by opening the link in a browser or by curl -L -O-ing the link loads the full archive, and unzip-ing it succeeds.

Expected behavior

The package loads, the archive unzips and the primary target compiles with no errors.

Actual behavior

See description.

Steps to reproduce

  1. Create an empty Swift executable and add
        .package(url: "https://bitbucket.org/usercentricscode/usercentrics-spm-sdk", from: "2.0.0")

to dependencies.

  1. Run swift build.

Swift Package Manager version/commit hash

Swift Package Manager - Swift 5.8.0

Swift & OS version (output of swift --version ; uname -a)

swift-driver version: 1.75.2 Apple Swift version 5.8 (swiftlang-5.8.0.124.2 clang-1403.0.22.11.100) Target: arm64-apple-macosx13.0 Darwin *** 22.5.0 Darwin Kernel Version 22.5.0: Mon Apr 24 20:53:44 PDT 2023; root:xnu-8796.121.2~5/RELEASE_ARM64_T8103 arm64

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 1
  • Comments: 17 (1 by maintainers)

Most upvoted comments

I also just faced the same issue on Xcode 15.3. but with a different dependency. Never encountered it on Xcode 15.2. or before.

Running

rm -rf $HOME/Library/Caches/org.swift.swiftpm/
rm -rf $HOME/Library/org.swift.swiftpm

and reloading the packages worked for me.

Can’t reproduce this issue.

Xcode Version 15.0 beta 4 (15A5195m)

swift-driver version: 1.85 Apple Swift version 5.9 (swiftlang-5.9.0.120.7 clang-1500.0.34.3)
Target: arm64-apple-macosx14.0

Maybe there is something wrong with your network connection or the cache.

You can remove all the cache by the following commands if you are on macOS.

rm -rf $HOME/Library/Caches/org.swift.swiftpm/
rm -rf $HOME/Library/org.swift.swiftpm
rm -rf $HOME/Library/Developer/Xcode/DerivedData

I had the same issue. I solved it by removing my bitbucket username/password from keychain.