swiftlang/swift-package-manager

Compilation Error: `Unable to resolve build file: ...' in Swift Packages during Universal Build

CrazyFanFan opened this issue · 3 comments

Is it reproducible with SwiftPM command-line tools: swift build, swift test, swift package etc?

  • Confirmed reproduction steps with SwiftPM CLI.

Description

A compilation error occurs when package access level modifiers are used in a dependent Swift Package while simultaneously building arm64 and x86_64 architectures.

Specifically, swift build, swift build --arch arm64, and swift build --arch x86_64 commands successfully compile individually without any errors. However, the command swift build --arch arm64 --arch x86_64 gives an error.
Consider the error message:

Unable to resolve build file: BuildFile<PACKAGE-PRODUCT:SemVerMacros::BUILDPHASE_0::6> (The workspace has a reference to a missing target with GUID 'PACKAGE-TARGET:SemVerMacrosPlugin@11')
Unable to resolve build file: BuildFile<PACKAGE-PRODUCT:SemVerMacros::BUILDPHASE_0::6> (The workspace has a reference to a missing target with GUID 'PACKAGE-TARGET:SemVerMacrosPlugin@11')

Expected behavior

Build succeeded and generated a universal binary.

Actual behavior

Build cancelled

Steps to reproduce

Download Foo.zip, then unzip it and change your current directory (cd) into the Foo directory.
Run the command swift build --arch arm64 --arch x86_64.

Swift Package Manager version/commit hash

5.10

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

swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0
Darwin Foo 23.5.0 Darwin Kernel Version 23.5.0: Tue Mar 26 20:55:54 PDT 2024; root:xnu-10063.120.88.501.3~2/RELEASE_ARM64_T6030 arm64

This looks like a duplicate of #7405. Is this issue reproducible for you with latest development snapshots (swift-DEVELOPMENT-SNAPSHOT-2024-04-13-a or swift-6.0-DEVELOPMENT-SNAPSHOT-2024-04-15-a and later)?

Although it appears to be very similar, this issue is still a separate new problem. I tested it with the latest swift-6.0-DEVELOPMENT-SNAPSHOT-2024-04-15-a, and I can still reproduce the issue in the demo I provided.

I apologize, I accidentally closed this issue. It can still be reproduced in swift-6.0-DEVELOPMENT-SNAPSHOT-2024-05-14-a.