Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Sources/SWBCore/Settings/BuiltinMacros.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,7 @@ public final class BuiltinMacros {
public static let SWIFT_WARNINGS_AS_WARNINGS_GROUPS = BuiltinMacros.declareStringListMacro("SWIFT_WARNINGS_AS_WARNINGS_GROUPS")
public static let SWIFT_WARNINGS_AS_ERRORS_GROUPS = BuiltinMacros.declareStringListMacro("SWIFT_WARNINGS_AS_ERRORS_GROUPS")
public static let SWIFT_OBJC_BRIDGING_HEADER = BuiltinMacros.declareStringMacro("SWIFT_OBJC_BRIDGING_HEADER")
public static let SWIFT_BRIDGING_HEADER_IS_INTERNAL = BuiltinMacros.declareBooleanMacro("SWIFT_BRIDGING_HEADER_IS_INTERNAL")
public static let SWIFT_OBJC_INTERFACE_HEADER_NAME = BuiltinMacros.declareStringMacro("SWIFT_OBJC_INTERFACE_HEADER_NAME")
public static let SWIFT_OBJC_INTERFACE_HEADER_DIR = BuiltinMacros.declareStringMacro("SWIFT_OBJC_INTERFACE_HEADER_DIR")
public static let SWIFT_OBJC_INTEROP_MODE = BuiltinMacros.declareStringMacro("SWIFT_OBJC_INTEROP_MODE")
Expand Down Expand Up @@ -2271,6 +2272,7 @@ public final class BuiltinMacros {
SWIFT_MODULE_ONLY_TVOS_DEPLOYMENT_TARGET,
SWIFT_MODULE_ONLY_WATCHOS_DEPLOYMENT_TARGET,
SWIFT_OBJC_BRIDGING_HEADER,
SWIFT_BRIDGING_HEADER_IS_INTERNAL,
SWIFT_OBJC_INTERFACE_HEADER_NAME,
SWIFT_OBJC_INTERFACE_HEADER_DIR,
SWIFT_OBJC_INTEROP_MODE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2097,7 +2097,10 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
let objcBridgingHeaderPath = Path(cbc.scope.evaluate(BuiltinMacros.SWIFT_OBJC_BRIDGING_HEADER))
if !objcBridgingHeaderPath.isEmpty {
let objcBridgingHeaderNode = delegate.createNode(objcBridgingHeaderPath)
args += ["-import-objc-header", objcBridgingHeaderNode.path.normalize().str]
let flag = cbc.scope.evaluate(BuiltinMacros.SWIFT_BRIDGING_HEADER_IS_INTERNAL)
? "-internal-import-bridging-header"
: "-import-objc-header"
args += [flag, objcBridgingHeaderNode.path.normalize().str]
extraInputPaths.append(objcBridgingHeaderPath)
let precompsPath = cbc.scope.evaluate(BuiltinMacros.SHARED_PRECOMPS_DIR)
if !precompsPath.isEmpty,
Expand Down Expand Up @@ -3477,6 +3480,8 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
// We want the objc header in XOJIT mode so ignore in dynamic replacement mode
"-import-objc-header",

"-internal-import-bridging-header",

// Old setting only stripped in dynamic replacement mode for backward compatibility
"-clang-build-session-file",
] {
Expand Down
12 changes: 10 additions & 2 deletions Sources/SWBUniversalPlatform/Specs/Swift.xcspec
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,16 @@
Type = String;
DefaultValue = "";
Category = "General";
DisplayName = "Objective-C Bridging Header";
Description = "Path to the header defining the Objective-C interfaces to be exposed in Swift.";
DisplayName = "Bridging Header";
Description = "Path to the header defining the C interfaces to be exposed in Swift.";
},
{
Name = "SWIFT_BRIDGING_HEADER_IS_INTERNAL";
Type = Boolean;
DefaultValue = "NO";
Category = "General";
DisplayName = "Bridging Header is Internal to the Module";
Description = "When there is a bridging header, this setting indicates whether the contents of that bridging header should be imported as-if they came from an internal import. This is necessary when using bridging headers with Swift modules that are imported into other modules.";
},
{
Name = "SWIFT_OBJC_INTERFACE_HEADER_NAME";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1748,8 +1748,9 @@ fileprivate struct SwiftTaskConstructionTests: CoreBasedTests {
}

/// Check handling of Swift bridging header.
@Test(.requireSDKs(.macOS))
func swiftBridgingHeader() async throws {
@Test(.requireSDKs(.macOS), arguments: [false, true])
func swiftBridgingHeader(isInternal: Bool) async throws {
let bridgingHeaderIsInternal = isInternal ? "YES" : "NO"
let testProject = try await TestProject(
"aProject",
groupTree: TestGroup(
Expand All @@ -1773,6 +1774,7 @@ fileprivate struct SwiftTaskConstructionTests: CoreBasedTests {
buildSettings: [
"SDKROOT": "macosx",
"SWIFT_OBJC_BRIDGING_HEADER": "swift-bridge-header.h",
"SWIFT_BRIDGING_HEADER_IS_INTERNAL": bridgingHeaderIsInternal,
"SWIFT_VERSION": swiftVersion,
]),
],
Expand All @@ -1797,8 +1799,9 @@ fileprivate struct SwiftTaskConstructionTests: CoreBasedTests {
results.checkTask(.matchTarget(target), .matchRuleType("SwiftDriver Compilation")) { task in
task.checkRuleInfo(["SwiftDriver Compilation", "FooApp", "normal", "x86_64", "com.apple.xcode.tools.swift.compiler"])

let expectedFlag = isInternal ? "-internal-import-bridging-header" : "-import-objc-header"
task.checkCommandLineContains([
"-import-objc-header", bridgeHeader.str])
expectedFlag, bridgeHeader.str])
task.checkInputs(contain: [.path(bridgeHeader.str)])
}
}
Expand Down
Loading