Skip to content

Commit 3a979f5

Browse files
committed
Improve comments
1 parent a17273c commit 3a979f5

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

Sources/Basics/VFSOverlay.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public struct VFSOverlay: Encodable {
5757
super.init(name: name, type: "directory")
5858
}
5959

60+
// TODO(ncooke3): Do we need to wrap this in `#if swift(>=5.4)`?
6061
public convenience init(
6162
name: String,
6263
@VFSOverlayBuilder contents: () -> [VFSOverlay.Resource]
@@ -97,7 +98,7 @@ public struct VFSOverlay: Encodable {
9798
}
9899
}
99100

100-
// TOOD(ncooke3): Gate this?
101+
// TODO(ncooke3): Do we need to wrap this in `#if swift(>=5.4)`?
101102
@resultBuilder
102103
public struct VFSOverlayBuilder {
103104
public static func buildBlock(_ components: [VFSOverlay.Resource]...) -> [VFSOverlay.Resource] {

Sources/Build/BuildPlan.swift

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,17 +1436,21 @@ public final class MixedTargetBuildDescription {
14361436
// When the Swift compiler creates the generated interop header for
14371437
// Objective-C compatible Swift API (via `-emit-objc-header`), any
14381438
// Objective-C symbol that cannot be forward declared (e.g. superclass,
1439-
// protocol, etc.) will attempt to be imported via a module import of
1440-
// the module's umbrella header (e.g. `#import <Module/Module.h>`). The
1441-
// Swift compiler assumes (1) the module has the structure of a
1442-
// framework and (2) that an umbrella header exists. However, SwiftPM
1443-
// does not build frameworks (breaking assumption #1) and an umbrella
1444-
// header may not exist (breaking assumption #2). Instead, to guarantee
1445-
// the generated interop header's import can be resolved, the package
1446-
// manager generates an umbrella header if needed and will later use a
1447-
// VFS overlay to make the generated header appear in the proper
1448-
// location so the problematic import in the generated interop header
1449-
// can be resolved during the build.
1439+
// protocol, etc.) will attempt to be imported via a bridging header.
1440+
// Unfortunately, a custom bridging header can not be specified because
1441+
// the target is evaluated as a framework target (as opposed to an app
1442+
// target), and framework target do not support bridging headers. So,
1443+
// the compiler defaults to importing the following in the generated
1444+
// interop header ($(ModuleName)-Swift.h):
1445+
//
1446+
// #import <$(ModuleName)/$(ModuleName).h>
1447+
//
1448+
// The compiler assumes that the above path can be resolved. Instead of
1449+
// forcing package authors to structure their packages around that
1450+
// constraint, the package manager generates an umbrella header if
1451+
// needed and will later use a VFS overlay to make the generated header
1452+
// appear in the proper location so the bridging header import in the
1453+
// generated interop header can be resolved during the build.
14501454
var generatedUmbrellaHeaderPath: AbsolutePath? = nil
14511455
let relativeUmbrellaHeaderPath =
14521456
RelativePath("\(mixedTarget.c99name)/\(mixedTarget.c99name).h")

0 commit comments

Comments
 (0)