@@ -26,6 +26,18 @@ import MachO
2626
2727@Suite ( . requireXcode16( ) )
2828fileprivate struct MergeableLibrariesBuildOperationTests : CoreBasedTests {
29+
30+ private func linkerSupportsMergeableDebugHook( ) async throws -> Bool {
31+ guard let ldPath = try await ldPath else {
32+ throw StubError . error ( " Could not get path for ld linker. " )
33+ }
34+ let info = try await discoveredLdLinkerInfo ( at: ldPath)
35+ guard let version = info. toolVersion else {
36+ throw StubError . error ( " Could not get version for ld linker at ' \( ldPath. str) . " )
37+ }
38+ return version >= Version ( 1217 )
39+ }
40+
2941 @Test ( . requireSDKs( . iOS) )
3042 func automaticMergedFrameworkCreation( ) async throws {
3143 try await testAutomaticMergedFrameworkCreation ( useAppStoreCodelessFrameworksWorkaround: true )
@@ -164,6 +176,7 @@ fileprivate struct MergeableLibrariesBuildOperationTests: CoreBasedTests {
164176 let tester = try await BuildOperationTester ( getCore ( ) , testWorkspace, simulated: false )
165177 let SRCROOT = testWorkspace. sourceRoot. join ( " aProject " )
166178 let signableTargets : Set < String > = Set ( tester. workspace. projects [ 0 ] . targets. map ( { $0. name } ) )
179+ let supportsMergeableDebugHook = try await linkerSupportsMergeableDebugHook ( )
167180
168181 // Write the source files.
169182 try await tester. fs. writeFileContents ( SRCROOT . join ( " Sources/Application.swift " ) ) { contents in
@@ -216,6 +229,9 @@ fileprivate struct MergeableLibrariesBuildOperationTests: CoreBasedTests {
216229 results. checkTask ( . matchTargetName( targetName) , . matchRuleType( " SwiftCompile " ) ) { _ in }
217230 results. checkTask ( . matchTargetName( targetName) , . matchRuleType( " Ld " ) ) { task in
218231 task. checkCommandLineDoesNotContain ( " -make_mergeable " )
232+ if supportsMergeableDebugHook {
233+ task. checkCommandLineContains ( " -add_mergeable_debug_hook " )
234+ }
219235 task. checkCommandLineContains ( [ " -o " , " \( SYMROOT) /Debug-iphoneos/ \( targetName) .framework/ \( targetName) " ] )
220236 }
221237 results. checkTasks ( . matchTargetName( targetName) , . matchRuleType( " Copy " ) ) { _ in /* likely Swift-related */ }
@@ -234,6 +250,7 @@ fileprivate struct MergeableLibrariesBuildOperationTests: CoreBasedTests {
234250 task. checkCommandLineContains ( [ " -o " , " \( SYMROOT) /Debug-iphoneos/ \( targetName) .framework/ \( targetName) " ] )
235251 task. checkCommandLineDoesNotContain ( " -merge_framework " )
236252 task. checkCommandLineDoesNotContain ( " -make_mergeable " )
253+ task. checkCommandLineDoesNotContain ( " -add_mergeable_debug_hook " )
237254 }
238255 results. checkTask ( . matchTargetName( targetName) , . matchRuleType( " CodeSign " ) , . matchRuleItemBasename( " \( targetName) .framework " ) ) { _ in }
239256 // Check that the mergeable frameworks' binaries were copied in and re-signed.
@@ -396,6 +413,7 @@ fileprivate struct MergeableLibrariesBuildOperationTests: CoreBasedTests {
396413 results. checkTask ( . matchTargetName( targetName) , . matchRuleType( " SwiftCompile " ) ) { _ in }
397414 results. checkTask ( . matchTargetName( targetName) , . matchRuleType( " Ld " ) ) { task in
398415 task. checkCommandLineContains ( " -make_mergeable " )
416+ task. checkCommandLineDoesNotContain ( " -add_mergeable_debug_hook " )
399417 task. checkCommandLineContains ( [ " -o " , " \( OBJROOT) /UninstalledProducts/iphoneos/ \( targetName) .framework/ \( targetName) " ] )
400418 }
401419 results. checkTasks ( . matchTargetName( targetName) , . matchRuleType( " Copy " ) ) { _ in /* likely Swift-related */ }
@@ -415,6 +433,7 @@ fileprivate struct MergeableLibrariesBuildOperationTests: CoreBasedTests {
415433 task. checkCommandLineContains ( [ " -Xlinker " , " -merge_framework " , " -Xlinker " , " FwkTarget2 " ] )
416434 task. checkCommandLineContains ( [ " -o " , " \( OBJROOT) /UninstalledProducts/iphoneos/ \( targetName) .framework/ \( targetName) " ] )
417435 task. checkCommandLineDoesNotContain ( " -make_mergeable " )
436+ task. checkCommandLineDoesNotContain ( " -add_mergeable_debug_hook " )
418437 task. checkCommandLineDoesNotContain ( " -no_merge_framework " )
419438 }
420439 results. checkTask ( . matchTargetName( targetName) , . matchRuleType( " Strip " ) ) { _ in }
@@ -649,6 +668,7 @@ fileprivate struct MergeableLibrariesBuildOperationTests: CoreBasedTests {
649668 let SRCROOT_App = testWorkspace. sourceRoot. join ( " AppProject " )
650669 let SRCROOT_Fwk = testWorkspace. sourceRoot. join ( " FwkProject " )
651670 let signableTargets : Set < String > = Set ( tester. workspace. projects. flatMap ( { $0. targets} ) . map ( { $0. name } ) )
671+ let supportsMergeableDebugHook = try await linkerSupportsMergeableDebugHook ( )
652672
653673 // Write the source files.
654674 try await tester. fs. writeFileContents ( SRCROOT_App . join ( " Sources/Application.swift " ) ) { contents in
@@ -698,6 +718,9 @@ fileprivate struct MergeableLibrariesBuildOperationTests: CoreBasedTests {
698718 results. checkTask ( . matchTargetName( targetName) , . matchRuleType( " SwiftCompile " ) ) { _ in }
699719 results. checkTask ( . matchTargetName( targetName) , . matchRuleType( " Ld " ) ) { task in
700720 task. checkCommandLineDoesNotContain ( " -make_mergeable " )
721+ if supportsMergeableDebugHook {
722+ task. checkCommandLineContains ( " -add_mergeable_debug_hook " )
723+ }
701724 task. checkCommandLineContains ( [ " -o " , " \( SYMROOT) /Config-iphoneos/ \( targetName) .framework/ \( targetName) " ] )
702725 }
703726 results. checkTasks ( . matchTargetName( targetName) , . matchRuleType( " Copy " ) ) { _ in /* likely Swift-related */ }
@@ -855,6 +878,7 @@ fileprivate struct MergeableLibrariesBuildOperationTests: CoreBasedTests {
855878 results. checkTask ( . matchTargetName( targetName) , . matchRuleType( " SwiftCompile " ) ) { _ in }
856879 results. checkTask ( . matchTargetName( targetName) , . matchRuleType( " Ld " ) ) { task in
857880 task. checkCommandLineContains ( " -make_mergeable " )
881+ task. checkCommandLineDoesNotContain ( " -add_mergeable_debug_hook " )
858882 task. checkCommandLineContains ( [ " -o " , " \( OBJROOT) /UninstalledProducts/iphoneos/ \( targetName) .framework/ \( targetName) " ] )
859883 }
860884 results. checkTasks ( . matchTargetName( targetName) , . matchRuleType( " Copy " ) ) { _ in /* likely Swift-related */ }
@@ -876,6 +900,7 @@ fileprivate struct MergeableLibrariesBuildOperationTests: CoreBasedTests {
876900 task. checkCommandLineContains ( [ " -Xlinker " , " -merge_library " , " -Xlinker " , " \( OBJROOT) /UninstalledProducts/iphoneos/ \( fwkTargetName) .framework/ \( fwkTargetName) " ] )
877901 task. checkCommandLineContains ( [ " -o " , " \( DSTROOT) /Applications/ \( targetName) .app/ \( targetName) " ] )
878902 task. checkCommandLineDoesNotContain ( " -make_mergeable " )
903+ task. checkCommandLineDoesNotContain ( " -add_mergeable_debug_hook " )
879904 task. checkCommandLineDoesNotContain ( " -no_merge_framework " )
880905 }
881906 // Check that we're excluding the binary when embedding the mergeable targets, but not the merged target.
@@ -1512,6 +1537,7 @@ fileprivate struct MergeableLibrariesBuildOperationTests: CoreBasedTests {
15121537 task. checkCommandLineContains ( [ " -Xlinker " , " -merge-l \( libBaseName) " ] )
15131538 task. checkCommandLineContains ( [ " -o " , " \( OBJROOT) /UninstalledProducts/iphoneos/ \( targetName) .framework/ \( targetName) " ] )
15141539 task. checkCommandLineDoesNotContain ( " -make_mergeable " )
1540+ task. checkCommandLineDoesNotContain ( " -add_mergeable_debug_hook " )
15151541 task. checkCommandLineDoesNotContain ( " -no_merge_framework " )
15161542 }
15171543 results. checkTasks ( . matchTargetName( targetName) , . matchRuleType( " Copy " ) ) { _ in /* likely Swift-related */ }
0 commit comments