Skip to content

xtool dev fails on macOS with packages using platform-conditional target dependencies (e.g. swift-crypto) #433

In review

Description

@caquant

Summary

On macOS, xtool dev build fails at the packing step for any app that depends on swift-crypto's Crypto product. SwiftPM builds successfully, then xtool tries to copy a resource bundle that was never built:

Build complete! (22.01s)
Error: The file “swift-crypto_CryptoBoringWrapper.bundle” couldn’t be opened because there is no such file.

Steps to reproduce

Package.swift:

// swift-tools-version: 6.0
import PackageDescription

let package = Package(
    name: "repro",
    platforms: [.iOS(.v17), .macOS(.v14)],
    products: [.library(name: "repro", targets: ["repro"])],
    dependencies: [
        .package(url: "https://github.com/apple/swift-crypto", exact: "3.15.1"),
    ],
    targets: [
        .target(name: "repro", dependencies: [.product(name: "Crypto", package: "swift-crypto")]),
    ]
)

xtool.yml:

version: 1
bundleID: com.example.repro

Sources/repro/App.swift:

import Crypto
import SwiftUI

@main
struct ReproApp: App {
    var body: some Scene {
        WindowGroup { Text(SHA256.hash(data: Data()).description) }
    }
}

Then run xtool dev build.

Expected: the app is packed, containing only the bundles SwiftPM built.

Actual: the build succeeds, packing fails with the error above, and swift-crypto_Crypto.bundle is the only bundle in .build/arm64-apple-ios/debug/.

Cause

swift-crypto declares the BoringSSL targets as dependencies of Crypto only on non-Apple platforms:

.target(name: "CryptoBoringWrapper", condition: .when(platforms: platforms)),

So SwiftPM correctly doesn't build those targets or their bundles for iOS. However, swift package describe lists these dependencies without their conditions:

Crypto ['CCryptoBoringSSL', 'CCryptoBoringSSLShims', 'CryptoBoringWrapper']

Planner.swift follows that list and plans a bundle for every target with resources. Packer.swift then copies each planned bundle unconditionally, which fails for swift-crypto_CCryptoBoringSSL, swift-crypto_CCryptoBoringSSLShims, and swift-crypto_CryptoBoringWrapper.

This appears to be specific to macOS hosts, because swift-crypto declares these resources only under #if canImport(Darwin). I haven't tested on Linux.

Possible fixes

I haven't tried either of these:

  1. Have the planner evaluate platform conditions, for example from swift package dump-package, so that excluded targets are never walked. This also avoids following their dependencies.
  2. Have the packer skip planned bundles that don't exist. This is smaller, but it could hide a bundle that is genuinely missing.

Workaround

After a failed build, copy each target's PrivacyInfo.xcprivacy into the bundle path SwiftPM would have used, then rerun. This has to be repeated whenever .build is deleted.

for t in CCryptoBoringSSL CCryptoBoringSSLShims CryptoBoringWrapper; do
  d=.build/arm64-apple-ios/debug/swift-crypto_$t.bundle
  mkdir -p "$d" && cp ".build/checkouts/swift-crypto/Sources/$t/PrivacyInfo.xcprivacy" "$d/"
done

Environment

  • xtool 1.24.0
  • Xcode 26.5, Swift 6.3.2
  • macOS 26, Intel host
  • swift-crypto 3.15.1

Activity

  1. kabiroberai commented on Nov 16, 2026

    @kabiroberai
    Member

    This should be resolved by v2.0.0-beta.1. Please check and let me know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions