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.43k stars 151 forks source link

Build issue beginning in v3.4.0 potentially related to added build target #241

Closed reedshea closed 2 weeks ago

reedshea commented 2 weeks ago

New Issue Checklist

Expected behavior

I am using a library that has a dependency on swift-crypto. xcodebuild started failing in CI/CD after an automatic dependency update to swift-crypto v3.4.0. Expected behavior: the build should succeed. πŸ˜ƒ This looks like it may be the same issue as #235 but I'm not sure.

Actual behavior

The app builds locally. In CI/CD with GitHub Actions publishing to TestFlight, there is a build error:

error: Signing for "swift-crypto_Crypto" requires a development team. Select a development team in the Signing & Capabilities editor. (in target 'swift-crypto_Crypto' from project 'swift-crypto')

Steps to reproduce

In a brand-new Xcode project, add swift-crypto as a dependency, specifying v3.3.0. Then, run xcodebuild build.

Using `swift-crypto v3.3.0:

Target 'Crypto' in project 'swift-crypto'
        ➜ Explicit dependency on target 'Crypto' in project 'swift-crypto'

Using swift-crypto v3.4.0:

Target 'Crypto' in project 'swift-crypto'
        ➜ Explicit dependency on target 'Crypto' in project 'swift-crypto'
        ➜ Explicit dependency on target 'swift-crypto_Crypto' in project 'swift-crypto'

Details

Terminal output from xcodebuild build using swift-crypto v3.3.0:

Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild build

User defaults from command line:
    IDEPackageSupportUseBuiltinSCM = YES

Resolve Package Graph

Resolved source packages:
  swift-crypto: https://github.com/apple/swift-crypto.git @ 3.3.0

ComputeTargetDependencyGraph
note: Building targets in dependency order
note: Target dependency graph (8 targets)
    Target 'build-issue' in project 'build-issue'
        ➜ Explicit dependency on target '_CryptoExtras' in project 'swift-crypto'
        ➜ Explicit dependency on target 'Crypto' in project 'swift-crypto'
    Target 'Crypto' in project 'swift-crypto'
        ➜ Explicit dependency on target 'Crypto' in project 'swift-crypto'
    Target '_CryptoExtras' in project 'swift-crypto'
        ➜ Explicit dependency on target '_CryptoExtras' in project 'swift-crypto'
        ➜ Explicit dependency on target 'CCryptoBoringSSL' in project 'swift-crypto'
        ➜ Explicit dependency on target 'CCryptoBoringSSLShims' in project 'swift-crypto'
        ➜ Explicit dependency on target 'CryptoBoringWrapper' in project 'swift-crypto'
        ➜ Explicit dependency on target 'Crypto' in project 'swift-crypto'
    Target '_CryptoExtras' in project 'swift-crypto'
        ➜ Explicit dependency on target 'CCryptoBoringSSL' in project 'swift-crypto'
        ➜ Explicit dependency on target 'CCryptoBoringSSLShims' in project 'swift-crypto'
        ➜ Explicit dependency on target 'CryptoBoringWrapper' in project 'swift-crypto'
        ➜ Explicit dependency on target 'Crypto' in project 'swift-crypto'
    Target 'Crypto' in project 'swift-crypto' (no dependencies)
    Target 'CryptoBoringWrapper' in project 'swift-crypto'
        ➜ Explicit dependency on target 'CCryptoBoringSSL' in project 'swift-crypto'
        ➜ Explicit dependency on target 'CCryptoBoringSSLShims' in project 'swift-crypto'
    Target 'CCryptoBoringSSLShims' in project 'swift-crypto'
        ➜ Explicit dependency on target 'CCryptoBoringSSL' in project 'swift-crypto'
    Target 'CCryptoBoringSSL' in project 'swift-crypto' (no dependencies)
GatherProvisioningInputs
[...]

Terminal output from xcodebuild build using swift-crypto v3.4.0:

Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild build

User defaults from command line:
    IDEPackageSupportUseBuiltinSCM = YES

Resolve Package Graph

Resolved source packages:
  swift-crypto: https://github.com/apple/swift-crypto.git @ 3.4.0

ComputeTargetDependencyGraph
note: Building targets in dependency order
note: Target dependency graph (13 targets)
    Target 'build-issue' in project 'build-issue'
        ➜ Explicit dependency on target '_CryptoExtras' in project 'swift-crypto'
        ➜ Explicit dependency on target 'Crypto' in project 'swift-crypto'
    Target 'Crypto' in project 'swift-crypto'
        ➜ Explicit dependency on target 'Crypto' in project 'swift-crypto'
        ➜ Explicit dependency on target 'swift-crypto_Crypto' in project 'swift-crypto'
    Target '_CryptoExtras' in project 'swift-crypto'
        ➜ Explicit dependency on target '_CryptoExtras' in project 'swift-crypto'
        ➜ Explicit dependency on target 'swift-crypto__CryptoExtras' in project 'swift-crypto'
        ➜ Explicit dependency on target 'CCryptoBoringSSL' in project 'swift-crypto'
        ➜ Explicit dependency on target 'CCryptoBoringSSLShims' in project 'swift-crypto'
        ➜ Explicit dependency on target 'CryptoBoringWrapper' in project 'swift-crypto'
        ➜ Explicit dependency on target 'Crypto' in project 'swift-crypto'
    Target '_CryptoExtras' in project 'swift-crypto'
        ➜ Explicit dependency on target 'swift-crypto__CryptoExtras' in project 'swift-crypto'
        ➜ Explicit dependency on target 'CCryptoBoringSSL' in project 'swift-crypto'
        ➜ Explicit dependency on target 'CCryptoBoringSSLShims' in project 'swift-crypto'
        ➜ Explicit dependency on target 'CryptoBoringWrapper' in project 'swift-crypto'
        ➜ Explicit dependency on target 'Crypto' in project 'swift-crypto'
    Target 'Crypto' in project 'swift-crypto'
        ➜ Explicit dependency on target 'swift-crypto_Crypto' in project 'swift-crypto'
    Target 'swift-crypto_Crypto' in project 'swift-crypto' (no dependencies)
    Target 'CryptoBoringWrapper' in project 'swift-crypto'
        ➜ Explicit dependency on target 'swift-crypto_CryptoBoringWrapper' in project 'swift-crypto'
        ➜ Explicit dependency on target 'CCryptoBoringSSL' in project 'swift-crypto'
        ➜ Explicit dependency on target 'CCryptoBoringSSLShims' in project 'swift-crypto'
    Target 'swift-crypto_CryptoBoringWrapper' in project 'swift-crypto' (no dependencies)
    Target 'CCryptoBoringSSLShims' in project 'swift-crypto'
        ➜ Explicit dependency on target 'swift-crypto_CCryptoBoringSSLShims' in project 'swift-crypto'
        ➜ Explicit dependency on target 'CCryptoBoringSSL' in project 'swift-crypto'
    Target 'swift-crypto_CCryptoBoringSSLShims' in project 'swift-crypto' (no dependencies)
    Target 'CCryptoBoringSSL' in project 'swift-crypto'
        ➜ Explicit dependency on target 'swift-crypto_CCryptoBoringSSL' in project 'swift-crypto'
    Target 'swift-crypto_CCryptoBoringSSL' in project 'swift-crypto' (no dependencies)
    Target 'swift-crypto__CryptoExtras' in project 'swift-crypto' (no dependencies)
[...]
GatherProvisioningInputs
reedshea commented 2 weeks ago

Deleting the .PrivacyInfo.xcprivacy file in the local build SourcePackages and re-running xcodebuild build resulted in the removal of the Explicit dependency on target 'swift-crypto_Crypto' in project 'swift-crypto' line.

https://github.com/apple/swift-crypto/commit/2adec617e6a5d82f69bf738b2d203f5fa319f183

Lukasa commented 2 weeks ago

This looks a lot like #231. Do you mind reading through it?

reedshea commented 2 weeks ago

It does look like it's the same issue. In my case, I'm using GitHub Actions to build and deploy to TestFlight, using a provisioning profile stored as a GitHub Actions variable.

Adding a privacy manifest file to my app, as described here, had no effect.

Adding DEVELOPMENT_TEAM="<id>" to the GitHub Actions workflow, as suggested by the error message and that issue #231, led to a different issue:

error: swift-crypto_Crypto does not support provisioning profiles. swift-crypto_Crypto does not support provisioning profiles, but provisioning profile [profile name] has been manually specified. Set the provisioning profile value to "Automatic" in the build settings editor. (in target 'swift-crypto_Crypto' from project 'swift-crypto')

Trying to set the provisioning profile to "Automatic" wasn't successful.

I haven't been very successful at trying to pin to v3.3.0 as a workaround; the xcodebuild -disableAutomaticPackageResolution flag doesn't seem to be respected in my setup, although I expected it to (possible issue mentioned here).

Thanks in advance for any help & suggestions!

Lukasa commented 2 weeks ago

I'm going to suggest that you take this to the Apple Developer Forums. This appears to be an issue with the way Xcode handles packages with resources, but we do require them here.

reedshea commented 2 weeks ago

No luck tracking down the root of the problem. But for posterity, in case someone runs into this or a similar issue in the future, the issue seems to be in using GitHub Actions to build, archive, sign, and push to TestFlight.

The previous setup followed the documented GitHub Actions Xcode setup: https://docs.github.com/en/actions/deployment/deploying-xcode-applications/installing-an-apple-certificate-on-macos-runners-for-xcode-development

Eliminating GitHub Actions in favor of Xcode Cloud allowed Xcode to be set to Automatically manage signing, which resolved this problem. The xcodebuild logs still show the extra line➜ Explicit dependency on target 'swift-crypto_Crypto' in project 'swift-crypto' but the build works.