Skip to content

Commit 23e5b18

Browse files
committed
Merge pull request swiftlang#2815 from abertelrud/eng/warn-about-clang-targets-with-nonmodular-header-layout
Add a warning for cases in which SwiftPM generates a module map for unsupported header layouts (cherry picked from commit b67ac83)
1 parent 47210bd commit 23e5b18

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

Sources/Build/BuildPlan.swift

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,9 +1711,9 @@ public class BuildPlan {
17111711
return nil
17121712
}
17131713

1714-
// Check that it supports macOS.
1714+
// Check that it supports the target platform and architecture.
17151715
guard let library = info.libraries.first(where: {
1716-
$0.platform == "macos" && $0.architectures.contains(Triple.Arch.x86_64.rawValue)
1716+
return $0.platform == buildParameters.triple.os.asXCFrameworkPlatformString && $0.architectures.contains(buildParameters.triple.arch.rawValue)
17171717
}) else {
17181718
diagnostics.emit(error: """
17191719
artifact '\(target.name)' does not support the target platform and architecture \
@@ -1833,3 +1833,15 @@ private func generateResourceInfoPlist(
18331833
try fileSystem.writeIfChanged(path: path, bytes: stream.bytes)
18341834
return true
18351835
}
1836+
1837+
fileprivate extension Triple.OS {
1838+
/// Returns a representation of the receiver that can be compared with platform strings declared in an XCFramework.
1839+
var asXCFrameworkPlatformString: String? {
1840+
switch self {
1841+
case .darwin, .linux, .wasi, .windows:
1842+
return nil // XCFrameworks do not support any of these platforms today.
1843+
case .macOS:
1844+
return "macos"
1845+
}
1846+
}
1847+
}

Sources/Workspace/InitPackage.swift

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ public final class InitPackage {
153153

154154
var param = ".\(platform.manifestName)("
155155
if supportedPlatform.isManifestAPIAvailable {
156-
if platform == .macOS {
157-
param += ".v10_\(version.minor)"
156+
if version.minor > 0 {
157+
param += ".v\(version.major)_\(version.minor)"
158158
} else {
159159
param += ".v\(version.major)"
160160
}
@@ -516,11 +516,11 @@ extension PackageModel.Platform {
516516

517517
extension SupportedPlatform {
518518
var isManifestAPIAvailable: Bool {
519-
if platform == .macOS {
520-
guard self.version.major == 10, self.version.patch == 0 else {
519+
if platform == .macOS && self.version.major == 10 {
520+
guard self.version.patch == 0 else {
521521
return false
522522
}
523-
} else if [Platform.iOS, .watchOS, .tvOS].contains(platform) {
523+
} else if [Platform.macOS, .iOS, .watchOS, .tvOS].contains(platform) {
524524
guard self.version.minor == 0, self.version.patch == 0 else {
525525
return false
526526
}
@@ -529,14 +529,16 @@ extension SupportedPlatform {
529529
}
530530

531531
switch platform {
532-
case .macOS:
532+
case .macOS where version.major == 10:
533533
return (10...15).contains(version.minor)
534+
case .macOS:
535+
return (11...11).contains(version.major)
534536
case .iOS:
535-
return (8...13).contains(version.major)
537+
return (8...14).contains(version.major)
536538
case .tvOS:
537-
return (9...13).contains(version.major)
539+
return (9...14).contains(version.major)
538540
case .watchOS:
539-
return (2...6).contains(version.major)
541+
return (2...7).contains(version.major)
540542

541543
default:
542544
return false

0 commit comments

Comments
 (0)