diff --git a/Sources/Commands/Utilities/TestingSupport.swift b/Sources/Commands/Utilities/TestingSupport.swift index 81b32961376..2d6d12bebf8 100644 --- a/Sources/Commands/Utilities/TestingSupport.swift +++ b/Sources/Commands/Utilities/TestingSupport.swift @@ -242,10 +242,10 @@ enum TestingSupport { // Since XCTestHelper targets macOS, we need the macOS platform paths here. if let sdkPlatformPaths = try? SwiftSDK.sdkPlatformPaths(for: .macOS) { // appending since we prefer the user setting (if set) to the one we inject - for frameworkPath in sdkPlatformPaths.frameworks { + for frameworkPath in sdkPlatformPaths.runtimeFrameworkSearchPaths { env.appendPath(key: "DYLD_FRAMEWORK_PATH", value: frameworkPath.pathString) } - for libraryPath in sdkPlatformPaths.libraries { + for libraryPath in sdkPlatformPaths.runtimeLibrarySearchPaths { env.appendPath(key: "DYLD_LIBRARY_PATH", value: libraryPath.pathString) } } diff --git a/Sources/PackageModel/SwiftSDKs/SwiftSDK.swift b/Sources/PackageModel/SwiftSDKs/SwiftSDK.swift index bef655063af..5e5b95908cf 100644 --- a/Sources/PackageModel/SwiftSDKs/SwiftSDK.swift +++ b/Sources/PackageModel/SwiftSDKs/SwiftSDK.swift @@ -593,10 +593,10 @@ public struct SwiftSDK: Equatable { #if os(macOS) do { let sdkPaths = try SwiftSDK.sdkPlatformPaths(for: darwinPlatform, environment: environment) - extraCCFlags.append(contentsOf: sdkPaths.frameworks.flatMap { ["-F", $0.pathString] }) - extraSwiftCFlags.append(contentsOf: sdkPaths.frameworks.flatMap { ["-F", $0.pathString] }) - extraSwiftCFlags.append(contentsOf: sdkPaths.libraries.flatMap { ["-I", $0.pathString] }) - extraSwiftCFlags.append(contentsOf: sdkPaths.libraries.flatMap { ["-L", $0.pathString] }) + extraCCFlags.append(contentsOf: sdkPaths.buildTimeFrameworkSearchPaths.flatMap { ["-F", $0.pathString] }) + extraSwiftCFlags.append(contentsOf: sdkPaths.buildTimeFrameworkSearchPaths.flatMap { ["-F", $0.pathString] }) + extraSwiftCFlags.append(contentsOf: sdkPaths.buildTimeLibrarySearchPaths.flatMap { ["-I", $0.pathString] }) + extraSwiftCFlags.append(contentsOf: sdkPaths.buildTimeLibrarySearchPaths.flatMap { ["-L", $0.pathString] }) xctestSupport = .supported } catch { xctestSupport = .unsupported(reason: String(describing: error)) @@ -628,11 +628,21 @@ public struct SwiftSDK: Equatable { /// /// - SeeAlso: ``sdkPlatformPaths(for:environment:)`` public struct PlatformPaths { - /// Paths of directories containing auxiliary platform frameworks. - public var frameworks: [Basics.AbsolutePath] + /// Paths of directories containing auxiliary platform frameworks which + /// should be included as framework search paths at build time. + public var buildTimeFrameworkSearchPaths: [Basics.AbsolutePath] - /// Paths of directories containing auxiliary platform libraries. - public var libraries: [Basics.AbsolutePath] + /// Paths of directories containing auxiliary platform libraries which + /// should be included as library search paths at build time. + public var buildTimeLibrarySearchPaths: [Basics.AbsolutePath] + + /// Paths of directories containing auxiliary platform frameworks which + /// should be included as framework search paths at runtime. + public var runtimeFrameworkSearchPaths: [Basics.AbsolutePath] + + /// Paths of directories containing auxiliary platform libraries which + /// should be included as library search paths at runtime. + public var runtimeLibrarySearchPaths: [Basics.AbsolutePath] } /// Returns `macosx` sdk platform framework path. @@ -641,10 +651,10 @@ public struct SwiftSDK: Equatable { environment: Environment = .current ) throws -> (fwk: Basics.AbsolutePath, lib: Basics.AbsolutePath) { let paths = try sdkPlatformPaths(for: .macOS, environment: environment) - guard let frameworkPath = paths.frameworks.first else { + guard let frameworkPath = paths.buildTimeFrameworkSearchPaths.first else { throw StringError("could not determine SDK platform framework path") } - guard let libraryPath = paths.libraries.first else { + guard let libraryPath = paths.buildTimeLibrarySearchPaths.first else { throw StringError("could not determine SDK platform library path") } return (fwk: frameworkPath, lib: libraryPath) @@ -682,7 +692,12 @@ public struct SwiftSDK: Equatable { components: "Developer", "usr", "lib" ) - let sdkPlatformFrameworkPath = PlatformPaths(frameworks: [frameworksPath, privateFrameworksPath], libraries: [librariesPath]) + let sdkPlatformFrameworkPath = PlatformPaths( + buildTimeFrameworkSearchPaths: [frameworksPath /* omit privateFrameworksPath */], + buildTimeLibrarySearchPaths: [librariesPath], + runtimeFrameworkSearchPaths: [frameworksPath, privateFrameworksPath], + runtimeLibrarySearchPaths: [librariesPath] + ) _sdkPlatformFrameworkPath[darwinPlatform] = sdkPlatformFrameworkPath return sdkPlatformFrameworkPath }