Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-14459] swift compiler (swift build) reports erroneous error about missing -Swift.h file when missing a dependency in Package.swift #56815

Open
heckj opened this issue Apr 8, 2021 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@heckj
Copy link
Contributor

heckj commented Apr 8, 2021

Previous ID SR-14459
Radar rdar://problem/76455247
Original Reporter @heckj
Type Bug
Environment

Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28).

Additional Detail from JIRA
Votes 0
Component/s
Labels Bug
Assignee None
Priority Medium

md5: 911215588387a3376ea0fef86affbc0e

Issue Description:

While working through replicating some example code from swift-collections-benchmark, I was creating my own Package.swift and missed including a dependency.

The error that `swift build` reported was:

```
/Users/heckj/src/swift-collections-benchmark/Documentation/.build/x86_64-apple-macosx/debug/Collections.build/module.modulemap:2:12: error: header '/Users/heckj/src/swift-collections-benchmark/Documentation/.build/x86_64-apple-macosx/debug/Collections.build/Collections-Swift.h' not found
header "/Users/heckj/src/swift-collections-benchmark/Documentation/.build/x86_64-apple-macosx/debug/Collections.build/Collections-Swift.h"
^
/Users/heckj/src/swift-collections-benchmark/Documentation/Sources/Kalimba/Kalimba.swift:18:8: error: could not build Objective-C module 'Collections'
import Collections
^
[1/57] Compiling OrderedCollections _HashTable+Bucket.swift
```

When the actual issue was that I neglected to include "Collections" in the dependency for the library.

I wasn't entirely clear why the error message was appearing, but I think if we can report that the dependency couldn't be found as a first step, that would probably be a better error than sending someone down the path of trying to understand what's expecting a header file.

I set up a sample project to make this easier to reproduce:

1. `git clone https://github.com/heckj/swift-collections-benchmark.git -b buildMissingDependency`
2. `cd swift-collections-benchmark/Documentation`
3. `swift build -c release`:

```
Fetching https://github.com/apple/swift-collections-benchmark
Fetching https://github.com/apple/swift-collections
Fetching https://github.com/apple/swift-argument-parser
Fetching https://github.com/apple/swift-system
Cloning https://github.com/apple/swift-system
Resolving https://github.com/apple/swift-system at 0.0.1
Cloning https://github.com/apple/swift-collections
Resolving https://github.com/apple/swift-collections at 0.0.1
Cloning https://github.com/apple/swift-collections-benchmark
Resolving https://github.com/apple/swift-collections-benchmark at 0.0.1
Cloning https://github.com/apple/swift-argument-parser
Resolving https://github.com/apple/swift-argument-parser at 0.4.1
/Users/heckj/src/swift-collections-benchmark/Documentation/.build/x86_64-apple-macosx/release/Collections.build/module.modulemap:2:12: error: header '/Users/heckj/src/swift-collections-benchmark/Documentation/.build/x86_64-apple-macosx/release/Collections.build/Collections-Swift.h' not found
header "/Users/heckj/src/swift-collections-benchmark/Documentation/.build/x86_64-apple-macosx/release/Collections.build/Collections-Swift.h"
^
/Users/heckj/src/swift-collections-benchmark/Documentation/Sources/Kalimba/Kalimba.swift:18:8: error: could not build Objective-C module 'Collections'
import Collections
^
```

Within the Package.swift that's inside the Documentation directory, there's a commented out dependency. Remove the comment and recompile, and it's quite happy.

@typesanitizer
Copy link

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Projects
None yet
Development

No branches or pull requests

2 participants