@@ -6739,4 +6739,108 @@ final class BuildPlanTests: XCTestCase {
67396739 )
67406740 }
67416741 }
6742+
6743+ func testProductWithBinaryArtifactDependency( ) async throws {
6744+ #if !os(macOS)
6745+ try XCTSkipIf ( true , " Test is only supported on macOS " )
6746+ #endif
6747+
6748+ let fs = InMemoryFileSystem (
6749+ emptyFiles:
6750+ " /testpackage/Sources/SwiftLib/lib.swift " ,
6751+ " /testpackage/Sources/CLib/include/lib.h " ,
6752+ " /testpackage/Sources/CLib/lib.c "
6753+ )
6754+
6755+ try fs. createDirectory ( " /testpackagedep/SomeArtifact.xcframework " , recursive: true )
6756+ try fs. writeFileContents (
6757+ " /testpackagedep/SomeArtifact.xcframework/Info.plist " ,
6758+ string: """
6759+ <?xml version= " 1.0 " encoding= " UTF-8 " ?>
6760+ <!DOCTYPE plist PUBLIC " -//Apple//DTD PLIST 1.0//EN " " http://www.apple.com/DTDs/PropertyList-1.0.dtd " >
6761+ <plist version= " 1.0 " >
6762+ <dict>
6763+ <key>AvailableLibraries</key>
6764+ <array>
6765+ <dict>
6766+ <key>LibraryIdentifier</key>
6767+ <string>macos</string>
6768+ <key>HeadersPath</key>
6769+ <string>Headers</string>
6770+ <key>LibraryPath</key>
6771+ <string>libSomeArtifact.a</string>
6772+ <key>SupportedArchitectures</key>
6773+ <array>
6774+ <string>arm64</string>
6775+ <string>x86_64</string>
6776+ </array>
6777+ <key>SupportedPlatform</key>
6778+ <string>macos</string>
6779+ </dict>
6780+ </array>
6781+ <key>CFBundlePackageType</key>
6782+ <string>XFWK</string>
6783+ <key>XCFrameworkFormatVersion</key>
6784+ <string>1.0</string>
6785+ </dict>
6786+ </plist>
6787+ """
6788+ )
6789+
6790+ let observability = ObservabilitySystem . makeForTesting ( )
6791+ let graph = try loadModulesGraph (
6792+ fileSystem: fs,
6793+ manifests: [
6794+ Manifest . createFileSystemManifest (
6795+ displayName: " testpackagedep " ,
6796+ path: " /testpackagedep " ,
6797+ products: [
6798+ ProductDescription ( name: " SomeArtifact " , type: . library( . static) , targets: [ " SomeArtifact " ] ) ,
6799+ ] ,
6800+ targets: [
6801+ TargetDescription ( name: " SomeArtifact " , path: " SomeArtifact.xcframework " , type: . binary) ,
6802+ ]
6803+ ) ,
6804+ Manifest . createRootManifest (
6805+ displayName: " testpackage " ,
6806+ path: " /testpackage " ,
6807+ dependencies: [
6808+ . localSourceControl( path: " /testpackagedep " , requirement: . upToNextMajor( from: " 1.0.0 " ) ) ,
6809+ ] ,
6810+ products: [
6811+ ProductDescription ( name: " SwiftLib " , type: . library( . static) , targets: [ " SwiftLib " ] ) ,
6812+ ProductDescription ( name: " CLib " , type: . library( . static) , targets: [ " CLib " ] ) ,
6813+ ] ,
6814+ targets: [
6815+ TargetDescription ( name: " SwiftLib " , dependencies: [ " SomeArtifact " ] ) ,
6816+ TargetDescription ( name: " CLib " , dependencies: [ " SomeArtifact " ] )
6817+ ]
6818+ ) ,
6819+ ] ,
6820+ binaryArtifacts: [
6821+ . plain( " testpackagedep " ) : [
6822+ " SomeArtifact " : . init( kind: . xcframework, originURL: nil , path: " /testpackagedep/SomeArtifact.xcframework " ) ,
6823+ ] ,
6824+ ] ,
6825+ observabilityScope: observability. topScope
6826+ )
6827+ XCTAssertNoDiagnostics ( observability. diagnostics)
6828+
6829+ let plan = try await mockBuildPlan (
6830+ graph: graph,
6831+ fileSystem: fs,
6832+ observabilityScope: observability. topScope
6833+ )
6834+
6835+ let llbuild = LLBuildManifestBuilder (
6836+ plan,
6837+ fileSystem: fs,
6838+ observabilityScope: observability. topScope
6839+ )
6840+ try llbuild. generateManifest ( at: " /manifest.yaml " )
6841+ let contents : String = try fs. readFileContents ( " /manifest.yaml " )
6842+
6843+ XCTAssertMatch ( contents, . regex( #"args: \[.*"-I","/testpackagedep/SomeArtifact.xcframework/macos/Headers".*,"/testpackage/Sources/CLib/lib.c".*]"# ) )
6844+ XCTAssertMatch ( contents, . regex( #"args: \[.*"-module-name","SwiftLib",.*"-I","/testpackagedep/SomeArtifact.xcframework/macos/Headers".*]"# ) )
6845+ }
67426846}
0 commit comments