Skip to content

Commit 94abd81

Browse files
committed
Improve handling of Span back-deployment library bundling
A couple of related fixes: * Use 26.0 as the fallback version number when SDKSettings doesn't include SwiftSpanMinimumDeploymentTarget * Update tests to expect `--back-deploy-swift-span` and check when it shouldn't be there
1 parent 20966fc commit 94abd81

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

Sources/SWBCore/PlatformRegistry.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public final class Platform: Sendable {
7676
/// Minimum OS version for Swift concurrency (Swift 5.5). If this is `nil`, the platform does not support Swift concurrency at all.
7777
fileprivate(set) var minimumOSForSwiftConcurrency: Version? = nil
7878

79-
/// Minimum OS version for Span in the standard library (Swift 6.2). If this is `nil`, the platform does not support Swift concurrency at all.
79+
/// Minimum OS version for Span in the standard library (Swift 6.2). If this is `nil`, Span, MutableSpan, and related types are not available.
8080
fileprivate(set) var minimumOSForSwiftSpan: Version? = nil
8181

8282
/// The canonical name of the public SDK for this platform.
@@ -296,7 +296,7 @@ extension Platform {
296296
return version >= minimumSwiftConcurrencyVersion
297297
}
298298

299-
/// Determines if the platform natively supports Swift 6.2's Span type. If `false`, then the Swift Span back-compat concurrency libs needs to be copied into the app/framework's bundle.
299+
/// Determines if the platform natively supports Swift 6.2's Span type. If `false`, then the Swift Span back-compat lib needs to be copied into the app/framework's bundle.
300300
public func supportsSwiftSpanNatively(_ scope: MacroEvaluationScope, forceNextMajorVersion: Bool = false, considerTargetDeviceOSVersion: Bool = true) -> Bool? {
301301
guard let deploymentTarget = self.deploymentTargetMacro else { return false }
302302

Sources/SWBCore/SDKRegistry.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,9 +452,9 @@ public final class SDKVariant: PlatformInfoProvider, Sendable {
452452
private static func fallbackSwiftVersions(variantName name: String) -> (os: String?, concurrency: String?, span: String?) {
453453
switch name {
454454
case "macos", "macosx":
455-
return ("10.14.4", "12.0", nil)
455+
return ("10.14.4", "12.0", "26.0")
456456
default:
457-
return (nil, nil, nil)
457+
return (nil, nil, "26.0")
458458
}
459459
}
460460

Tests/SWBTaskConstructionTests/SwiftTaskConstructionTests.swift

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,35 +71,40 @@ fileprivate struct SwiftTaskConstructionTests: CoreBasedTests {
7171

7272
@Test(.requireSDKs(.macOS))
7373
func swiftAppBasics_preSwiftOS() async throws {
74-
try await _testSwiftAppBasics(deploymentTargetVersion: "10.14.0", shouldEmitSwiftRPath: true, shouldFilterSwiftLibs: false, shouldBackDeploySwiftConcurrency: true)
74+
try await _testSwiftAppBasics(deploymentTargetVersion: "10.14.0", shouldEmitSwiftRPath: true, shouldFilterSwiftLibs: false, shouldBackDeploySwiftConcurrency: true, shouldBackDeploySwiftSpan: true)
7575
}
7676

7777
@Test(.requireSDKs(.macOS))
7878
func swiftAppBasics_postSwiftOS() async throws {
79-
try await _testSwiftAppBasics(deploymentTargetVersion: "12.0", shouldEmitSwiftRPath: false, shouldFilterSwiftLibs: true, shouldBackDeploySwiftConcurrency: false)
79+
try await _testSwiftAppBasics(deploymentTargetVersion: "12.0", shouldEmitSwiftRPath: false, shouldFilterSwiftLibs: true, shouldBackDeploySwiftConcurrency: false, shouldBackDeploySwiftSpan: true)
80+
}
81+
82+
@Test(.requireSDKs(.macOS))
83+
func swiftAppBasics_postSwiftSpan() async throws {
84+
try await _testSwiftAppBasics(deploymentTargetVersion: "26.0", shouldEmitSwiftRPath: false, shouldFilterSwiftLibs: true, shouldBackDeploySwiftConcurrency: false, shouldBackDeploySwiftSpan: false)
8085
}
8186

8287
@Test(.requireSDKs(.macOS))
8388
func swiftAppBasics_preSwiftOSDeploymentTarget_postSwiftOSTargetDevice() async throws {
84-
try await _testSwiftAppBasics(deploymentTargetVersion: "10.14.0", targetDeviceOSVersion: "11.0", targetDevicePlatformName: "macosx", shouldEmitSwiftRPath: true, shouldFilterSwiftLibs: true, shouldBackDeploySwiftConcurrency: true)
89+
try await _testSwiftAppBasics(deploymentTargetVersion: "10.14.0", targetDeviceOSVersion: "11.0", targetDevicePlatformName: "macosx", shouldEmitSwiftRPath: true, shouldFilterSwiftLibs: true, shouldBackDeploySwiftConcurrency: true, shouldBackDeploySwiftSpan: true)
8590
}
8691

8792
@Test(.requireSDKs(.macOS))
8893
func swiftAppBasics_preSwiftOSDeploymentTarget_postSwiftOSTargetDevice_mixedPlatform() async throws {
89-
try await _testSwiftAppBasics(deploymentTargetVersion: "10.14.0", targetDeviceOSVersion: "14.0", targetDevicePlatformName: "iphoneos", shouldEmitSwiftRPath: true, shouldFilterSwiftLibs: false, shouldBackDeploySwiftConcurrency: true)
94+
try await _testSwiftAppBasics(deploymentTargetVersion: "10.14.0", targetDeviceOSVersion: "14.0", targetDevicePlatformName: "iphoneos", shouldEmitSwiftRPath: true, shouldFilterSwiftLibs: false, shouldBackDeploySwiftConcurrency: true, shouldBackDeploySwiftSpan: true)
9095
}
9196

9297
@Test(.requireSDKs(.macOS))
9398
func swiftAppBasics_postSwiftOSDeploymentTarget_preSwiftConcurrencySupportedNatively() async throws {
94-
try await _testSwiftAppBasics(deploymentTargetVersion: "11.0", shouldEmitSwiftRPath: true, shouldFilterSwiftLibs: true, shouldBackDeploySwiftConcurrency: true)
99+
try await _testSwiftAppBasics(deploymentTargetVersion: "11.0", shouldEmitSwiftRPath: true, shouldFilterSwiftLibs: true, shouldBackDeploySwiftConcurrency: true, shouldBackDeploySwiftSpan: true)
95100
}
96101

97102
@Test(.requireSDKs(.macOS), .userDefaults(["AllowRuntimeSearchPathAdditionForSwiftConcurrency": "0"]))
98103
func swiftAppBasics_postSwiftOSDeploymentTarget_preSwiftConcurrencySupportedNatively_DisallowRpathInjection() async throws {
99-
try await _testSwiftAppBasics(deploymentTargetVersion: "11.0", shouldEmitSwiftRPath:false, shouldFilterSwiftLibs: true, shouldBackDeploySwiftConcurrency: true)
104+
try await _testSwiftAppBasics(deploymentTargetVersion: "11.0", shouldEmitSwiftRPath:false, shouldFilterSwiftLibs: true, shouldBackDeploySwiftConcurrency: true, shouldBackDeploySwiftSpan: true)
100105
}
101106

102-
func _testSwiftAppBasics(deploymentTargetVersion: String, targetDeviceOSVersion: String? = nil, targetDevicePlatformName: String? = nil, toolchain toolchainIdentifier: String = "default", shouldEmitSwiftRPath: Bool, shouldFilterSwiftLibs: Bool, shouldBackDeploySwiftConcurrency: Bool) async throws {
107+
func _testSwiftAppBasics(deploymentTargetVersion: String, targetDeviceOSVersion: String? = nil, targetDevicePlatformName: String? = nil, toolchain toolchainIdentifier: String = "default", shouldEmitSwiftRPath: Bool, shouldFilterSwiftLibs: Bool, shouldBackDeploySwiftConcurrency: Bool, shouldBackDeploySwiftSpan: Bool) async throws {
103108
let swiftCompilerPath = try await self.swiftCompilerPath
104109
let swiftVersion = try await self.swiftVersion
105110
let swiftFeatures = try await self.swiftFeatures
@@ -412,7 +417,7 @@ fileprivate struct SwiftTaskConstructionTests: CoreBasedTests {
412417
// There should be a 'CopySwiftLibs' task.
413418
results.checkTask(.matchTarget(target), .matchRuleType("CopySwiftLibs")) { task -> Void in
414419
task.checkRuleInfo(["CopySwiftLibs", "\(SRCROOT)/build/Debug/AppTarget.app"])
415-
task.checkCommandLine(([["builtin-swiftStdLibTool", "--copy", "--verbose", "--scan-executable", "\(SRCROOT)/build/Debug/AppTarget.app/Contents/MacOS/AppTarget", "--scan-folder", "\(SRCROOT)/build/Debug/AppTarget.app/Contents/Frameworks", "--scan-folder", "\(SRCROOT)/build/Debug/AppTarget.app/Contents/PlugIns", "--scan-folder", "\(SRCROOT)/build/Debug/AppTarget.app/Contents/Library/SystemExtensions", "--scan-folder", "\(SRCROOT)/build/Debug/AppTarget.app/Contents/Extensions", "--scan-folder", "\(SRCROOT)/build/Debug/FwkTarget.framework", "--platform", "macosx", "--toolchain", effectiveToolchain.path.str], (toolchainIdentifier == "default" ? [] : ["--toolchain", defaultToolchain.path.str]), ["--destination", "\(SRCROOT)/build/Debug/AppTarget.app/Contents/Frameworks", "--strip-bitcode", "--strip-bitcode-tool", "\(effectiveToolchain.path.str)/usr/bin/bitcode_strip", "--emit-dependency-info", "\(SRCROOT)/build/aProject.build/Debug/AppTarget.build/SwiftStdLibToolInputDependencies.dep"], shouldFilterSwiftLibs ? ["--filter-for-swift-os"] : [], shouldBackDeploySwiftConcurrency ? ["--back-deploy-swift-concurrency"] : []] as [[String]]).reduce([], +))
420+
task.checkCommandLine(([["builtin-swiftStdLibTool", "--copy", "--verbose", "--scan-executable", "\(SRCROOT)/build/Debug/AppTarget.app/Contents/MacOS/AppTarget", "--scan-folder", "\(SRCROOT)/build/Debug/AppTarget.app/Contents/Frameworks", "--scan-folder", "\(SRCROOT)/build/Debug/AppTarget.app/Contents/PlugIns", "--scan-folder", "\(SRCROOT)/build/Debug/AppTarget.app/Contents/Library/SystemExtensions", "--scan-folder", "\(SRCROOT)/build/Debug/AppTarget.app/Contents/Extensions", "--scan-folder", "\(SRCROOT)/build/Debug/FwkTarget.framework", "--platform", "macosx", "--toolchain", effectiveToolchain.path.str], (toolchainIdentifier == "default" ? [] : ["--toolchain", defaultToolchain.path.str]), ["--destination", "\(SRCROOT)/build/Debug/AppTarget.app/Contents/Frameworks", "--strip-bitcode", "--strip-bitcode-tool", "\(effectiveToolchain.path.str)/usr/bin/bitcode_strip", "--emit-dependency-info", "\(SRCROOT)/build/aProject.build/Debug/AppTarget.build/SwiftStdLibToolInputDependencies.dep"], shouldFilterSwiftLibs ? ["--filter-for-swift-os"] : [], shouldBackDeploySwiftConcurrency ? ["--back-deploy-swift-concurrency"] : [], shouldBackDeploySwiftSpan ? ["--back-deploy-swift-span"] : []] as [[String]]).reduce([], +))
416421

417422
task.checkInputs([
418423
.path("\(SRCROOT)/build/Debug/AppTarget.app/Contents/MacOS/AppTarget"),

Tests/SWBTaskConstructionTests/UnitTestTaskConstructionTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3138,7 +3138,7 @@ fileprivate struct UnitTestTaskConstructionTests: CoreBasedTests {
31383138
// There should be a 'CopySwiftLibs' task that includes a reference to the libXCTestSwiftSupport.dylib executable.
31393139
results.checkTask(.matchTarget(target), .matchRuleType("CopySwiftLibs")) { task in
31403140
task.checkRuleInfo(["CopySwiftLibs", "\(SRCROOT)/build/Debug-iphoneos/UITestTarget-Runner.app/PlugIns/UITestTarget.xctest"])
3141-
task.checkCommandLine(["builtin-swiftStdLibTool", "--copy", "--verbose", "--sign", "105DE4E702E4", "--scan-executable", "\(SRCROOT)/build/Debug-iphoneos/UITestTarget-Runner.app/PlugIns/UITestTarget.xctest/UITestTarget", "--scan-folder", "\(SRCROOT)/build/Debug-iphoneos/UITestTarget-Runner.app/PlugIns/UITestTarget.xctest/Frameworks", "--scan-folder", "\(SRCROOT)/build/Debug-iphoneos/UITestTarget-Runner.app/PlugIns/UITestTarget.xctest/PlugIns", "--scan-folder", "\(SRCROOT)/build/Debug-iphoneos/UITestTarget-Runner.app/PlugIns/UITestTarget.xctest/SystemExtensions", "--scan-folder", "\(SRCROOT)/build/Debug-iphoneos/UITestTarget-Runner.app/PlugIns/UITestTarget.xctest/Extensions", "--platform", "iphoneos", "--toolchain", "\(core.developerPath.path.str)/Toolchains/XcodeDefault.xctoolchain", "--destination", "\(SRCROOT)/build/Debug-iphoneos/UITestTarget-Runner.app/PlugIns/UITestTarget.xctest/Frameworks", "--strip-bitcode", "--scan-executable", "\(core.developerPath.path.str)/Platforms/iPhoneOS.platform/Developer/usr/lib/libXCTestSwiftSupport.dylib", "--strip-bitcode-tool", "\(defaultToolchain.path.str)/usr/bin/bitcode_strip", "--emit-dependency-info", "\(SRCROOT)/build/aProject.build/Debug-iphoneos/UITestTarget.build/SwiftStdLibToolInputDependencies.dep", "--back-deploy-swift-concurrency"])
3141+
task.checkCommandLine(["builtin-swiftStdLibTool", "--copy", "--verbose", "--sign", "105DE4E702E4", "--scan-executable", "\(SRCROOT)/build/Debug-iphoneos/UITestTarget-Runner.app/PlugIns/UITestTarget.xctest/UITestTarget", "--scan-folder", "\(SRCROOT)/build/Debug-iphoneos/UITestTarget-Runner.app/PlugIns/UITestTarget.xctest/Frameworks", "--scan-folder", "\(SRCROOT)/build/Debug-iphoneos/UITestTarget-Runner.app/PlugIns/UITestTarget.xctest/PlugIns", "--scan-folder", "\(SRCROOT)/build/Debug-iphoneos/UITestTarget-Runner.app/PlugIns/UITestTarget.xctest/SystemExtensions", "--scan-folder", "\(SRCROOT)/build/Debug-iphoneos/UITestTarget-Runner.app/PlugIns/UITestTarget.xctest/Extensions", "--platform", "iphoneos", "--toolchain", "\(core.developerPath.path.str)/Toolchains/XcodeDefault.xctoolchain", "--destination", "\(SRCROOT)/build/Debug-iphoneos/UITestTarget-Runner.app/PlugIns/UITestTarget.xctest/Frameworks", "--strip-bitcode", "--scan-executable", "\(core.developerPath.path.str)/Platforms/iPhoneOS.platform/Developer/usr/lib/libXCTestSwiftSupport.dylib", "--strip-bitcode-tool", "\(defaultToolchain.path.str)/usr/bin/bitcode_strip", "--emit-dependency-info", "\(SRCROOT)/build/aProject.build/Debug-iphoneos/UITestTarget.build/SwiftStdLibToolInputDependencies.dep", "--back-deploy-swift-concurrency", "--back-deploy-swift-span"])
31423142
}
31433143
}
31443144

0 commit comments

Comments
 (0)