apple / swift-crypto

Open-source implementation of a substantial portion of the API of Apple CryptoKit suitable for use on Linux platforms.
https://apple.github.io/swift-crypto
Apache License 2.0
1.47k stars 166 forks source link

Failed to build with Swift 6 on Linux due to PrivacyInfo #256

Closed StefanCosminR closed 2 months ago

StefanCosminR commented 2 months ago

New Issue Checklist

Expected behavior

I expect a project that uses swift-crypto as a dependency to build under Linux and Swift 6

Actual behavior

The build fails when trying to Copy PrivacyInfo.xcprivacy file

Steps to reproduce

  1. Create an empty project under Ubuntu 22.04
  2. Add swift-crypto as a dependency
  3. run swift build

If possible, minimal yet complete reproducer code (or URL to code)

Building for debugging...
[0/386] Copying PrivacyInfo.xcprivacyerror: Error Domain=NSCocoaErrorDomain Code=512 "(null)"UserInfo={NSUserStringVariant=["Copy"], NSSourceFilePathErrorKey=/media/psf/MyApp/LinuxFileTesting/.build/checkouts/swift-crypto/Sources/CryptoBoringWrapper/PrivacyInfo.xcprivacy, NSDestinationFilePath=/media/psf/MyApp/LinuxFileTesting/.build/aarch64-unknown-linux-gnu/debug/swift-crypto_CryptoBoringWrapper.resources/PrivacyInfo.xcprivacy, NSURL=file:///media/psf/MyApp/LinuxFileTesting/.build/checkouts/swift-crypto/Sources/CryptoBoringWrapper/PrivacyInfo.xcprivacy, NSUnderlyingError=Error Domain=NSPOSIXErrorDomain Code=22 "Invalid argument", NSFilePath=/media/psf/MyApp/LinuxFileTesting/.build/checkouts/swift-crypto/Sources/CryptoBoringWrapper/PrivacyInfo.xcprivacy}
[0/386] Write swift-version--38D8FF7DA9A2BDDA.txt

Swift Crypto version/commit hash

81bee98e706aee68d39ed5996db069ef2b313d62

glbrntt commented 2 months ago

I couldn't reproduce this, and https://github.com/apple/swift-crypto/blob/main/Sources/CryptoBoringWrapper/PrivacyInfo.xcprivacy exists, so this is a bit odd.

We don't actually need the privacy manifests on Linux so we can exclude them from the package manifest (and we should do this) but I'd like to figure out why you're getting this error in case there's some other underlying issue.

Create an empty project under Ubuntu 22.04

How are you building this exactly, in a docker container using swift package manager? Or something else?

StefanCosminR commented 2 months ago

Maybe this is a SPM issue uncovered by my weird setup, or something I don't understand about linux. I have Ubuntu running in Parallels with a shared folder between the two (so Ubuntu sees this folder as a mounted drive). If I move the project to a local folder inside Ubuntu, it compiles fine, however it fails on the mounted drive. Maybe it's a general issue with the copy command of SPM

glbrntt commented 2 months ago

Yeah, this sounds very much like SwiftPM doesn't like your setup here. It should be possible to reproduce this quite easily without swift-crypto here. Would you be able to open an issue against https://github.com/swiftlang/swift-package-manager?

As a workaround I'll update the package manifest so that these resources aren't added on Linux.

StefanCosminR commented 2 months ago

Great, thank you!