@@ -195,12 +195,11 @@ public struct Destination: Encodable, Equatable {
195195 var extraCCFlags : [ String ] = [ ]
196196 var extraSwiftCFlags : [ String ] = [ ]
197197#if os(macOS)
198- if let sdkPaths = try Destination . sdkPlatformFrameworkPaths ( environment: environment) {
199- extraCCFlags += [ " -F " , sdkPaths. fwk. pathString]
200- extraSwiftCFlags += [ " -F " , sdkPaths. fwk. pathString]
201- extraSwiftCFlags += [ " -I " , sdkPaths. lib. pathString]
202- extraSwiftCFlags += [ " -L " , sdkPaths. lib. pathString]
203- }
198+ let sdkPaths = try Destination . sdkPlatformFrameworkPaths ( environment: environment)
199+ extraCCFlags += [ " -F " , sdkPaths. fwk. pathString]
200+ extraSwiftCFlags += [ " -F " , sdkPaths. fwk. pathString]
201+ extraSwiftCFlags += [ " -I " , sdkPaths. lib. pathString]
202+ extraSwiftCFlags += [ " -L " , sdkPaths. lib. pathString]
204203#endif
205204
206205#if !os(Windows)
@@ -217,26 +216,29 @@ public struct Destination: Encodable, Equatable {
217216 /// Returns macosx sdk platform framework path.
218217 public static func sdkPlatformFrameworkPaths(
219218 environment: EnvironmentVariables = . process( )
220- ) throws -> ( fwk: AbsolutePath , lib: AbsolutePath ) ? {
219+ ) throws -> ( fwk: AbsolutePath , lib: AbsolutePath ) {
221220 if let path = _sdkPlatformFrameworkPath {
222221 return path
223222 }
224- let platformPath = try ? TSCBasic . Process. checkNonZeroExit (
223+ let platformPath = try TSCBasic . Process. checkNonZeroExit (
225224 arguments: [ " /usr/bin/xcrun " , " --sdk " , " macosx " , " --show-sdk-platform-path " ] ,
226225 environment: environment) . spm_chomp ( )
227226
228- if let platformPath = platformPath, !platformPath. isEmpty {
229- // For XCTest framework.
230- let fwk = try AbsolutePath ( validating: platformPath) . appending (
231- components: " Developer " , " Library " , " Frameworks " )
227+ guard !platformPath. isEmpty else {
228+ throw StringError ( " could not determine SDK platform path " )
229+ }
230+
231+ // For XCTest framework.
232+ let fwk = try AbsolutePath ( validating: platformPath) . appending (
233+ components: " Developer " , " Library " , " Frameworks " )
232234
233- // For XCTest Swift library.
234- let lib = try AbsolutePath ( validating: platformPath) . appending (
235- components: " Developer " , " usr " , " lib " )
235+ // For XCTest Swift library.
236+ let lib = try AbsolutePath ( validating: platformPath) . appending (
237+ components: " Developer " , " usr " , " lib " )
236238
237- _sdkPlatformFrameworkPath = ( fwk, lib)
238- }
239- return _sdkPlatformFrameworkPath
239+ let sdkPlatformFrameworkPath = ( fwk, lib)
240+ _sdkPlatformFrameworkPath = sdkPlatformFrameworkPath
241+ return sdkPlatformFrameworkPath
240242 }
241243
242244 /// Cache storage for sdk platform path.
0 commit comments