@@ -26,6 +26,18 @@ import MachO
26
26
27
27
@Suite ( . requireXcode16( ) )
28
28
fileprivate 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
+
29
41
@Test ( . requireSDKs( . iOS) )
30
42
func automaticMergedFrameworkCreation( ) async throws {
31
43
try await testAutomaticMergedFrameworkCreation ( useAppStoreCodelessFrameworksWorkaround: true )
@@ -164,6 +176,7 @@ fileprivate struct MergeableLibrariesBuildOperationTests: CoreBasedTests {
164
176
let tester = try await BuildOperationTester ( getCore ( ) , testWorkspace, simulated: false )
165
177
let SRCROOT = testWorkspace. sourceRoot. join ( " aProject " )
166
178
let signableTargets : Set < String > = Set ( tester. workspace. projects [ 0 ] . targets. map ( { $0. name } ) )
179
+ let supportsMergeableDebugHook = try await linkerSupportsMergeableDebugHook ( )
167
180
168
181
// Write the source files.
169
182
try await tester. fs. writeFileContents ( SRCROOT . join ( " Sources/Application.swift " ) ) { contents in
@@ -216,6 +229,9 @@ fileprivate struct MergeableLibrariesBuildOperationTests: CoreBasedTests {
216
229
results. checkTask ( . matchTargetName( targetName) , . matchRuleType( " SwiftCompile " ) ) { _ in }
217
230
results. checkTask ( . matchTargetName( targetName) , . matchRuleType( " Ld " ) ) { task in
218
231
task. checkCommandLineDoesNotContain ( " -make_mergeable " )
232
+ if supportsMergeableDebugHook {
233
+ task. checkCommandLineContains ( " -add_mergeable_debug_hook " )
234
+ }
219
235
task. checkCommandLineContains ( [ " -o " , " \( SYMROOT) /Debug-iphoneos/ \( targetName) .framework/ \( targetName) " ] )
220
236
}
221
237
results. checkTasks ( . matchTargetName( targetName) , . matchRuleType( " Copy " ) ) { _ in /* likely Swift-related */ }
@@ -234,6 +250,7 @@ fileprivate struct MergeableLibrariesBuildOperationTests: CoreBasedTests {
234
250
task. checkCommandLineContains ( [ " -o " , " \( SYMROOT) /Debug-iphoneos/ \( targetName) .framework/ \( targetName) " ] )
235
251
task. checkCommandLineDoesNotContain ( " -merge_framework " )
236
252
task. checkCommandLineDoesNotContain ( " -make_mergeable " )
253
+ task. checkCommandLineDoesNotContain ( " -add_mergeable_debug_hook " )
237
254
}
238
255
results. checkTask ( . matchTargetName( targetName) , . matchRuleType( " CodeSign " ) , . matchRuleItemBasename( " \( targetName) .framework " ) ) { _ in }
239
256
// Check that the mergeable frameworks' binaries were copied in and re-signed.
@@ -396,6 +413,7 @@ fileprivate struct MergeableLibrariesBuildOperationTests: CoreBasedTests {
396
413
results. checkTask ( . matchTargetName( targetName) , . matchRuleType( " SwiftCompile " ) ) { _ in }
397
414
results. checkTask ( . matchTargetName( targetName) , . matchRuleType( " Ld " ) ) { task in
398
415
task. checkCommandLineContains ( " -make_mergeable " )
416
+ task. checkCommandLineDoesNotContain ( " -add_mergeable_debug_hook " )
399
417
task. checkCommandLineContains ( [ " -o " , " \( OBJROOT) /UninstalledProducts/iphoneos/ \( targetName) .framework/ \( targetName) " ] )
400
418
}
401
419
results. checkTasks ( . matchTargetName( targetName) , . matchRuleType( " Copy " ) ) { _ in /* likely Swift-related */ }
@@ -415,6 +433,7 @@ fileprivate struct MergeableLibrariesBuildOperationTests: CoreBasedTests {
415
433
task. checkCommandLineContains ( [ " -Xlinker " , " -merge_framework " , " -Xlinker " , " FwkTarget2 " ] )
416
434
task. checkCommandLineContains ( [ " -o " , " \( OBJROOT) /UninstalledProducts/iphoneos/ \( targetName) .framework/ \( targetName) " ] )
417
435
task. checkCommandLineDoesNotContain ( " -make_mergeable " )
436
+ task. checkCommandLineDoesNotContain ( " -add_mergeable_debug_hook " )
418
437
task. checkCommandLineDoesNotContain ( " -no_merge_framework " )
419
438
}
420
439
results. checkTask ( . matchTargetName( targetName) , . matchRuleType( " Strip " ) ) { _ in }
@@ -649,6 +668,7 @@ fileprivate struct MergeableLibrariesBuildOperationTests: CoreBasedTests {
649
668
let SRCROOT_App = testWorkspace. sourceRoot. join ( " AppProject " )
650
669
let SRCROOT_Fwk = testWorkspace. sourceRoot. join ( " FwkProject " )
651
670
let signableTargets : Set < String > = Set ( tester. workspace. projects. flatMap ( { $0. targets} ) . map ( { $0. name } ) )
671
+ let supportsMergeableDebugHook = try await linkerSupportsMergeableDebugHook ( )
652
672
653
673
// Write the source files.
654
674
try await tester. fs. writeFileContents ( SRCROOT_App . join ( " Sources/Application.swift " ) ) { contents in
@@ -698,6 +718,9 @@ fileprivate struct MergeableLibrariesBuildOperationTests: CoreBasedTests {
698
718
results. checkTask ( . matchTargetName( targetName) , . matchRuleType( " SwiftCompile " ) ) { _ in }
699
719
results. checkTask ( . matchTargetName( targetName) , . matchRuleType( " Ld " ) ) { task in
700
720
task. checkCommandLineDoesNotContain ( " -make_mergeable " )
721
+ if supportsMergeableDebugHook {
722
+ task. checkCommandLineContains ( " -add_mergeable_debug_hook " )
723
+ }
701
724
task. checkCommandLineContains ( [ " -o " , " \( SYMROOT) /Config-iphoneos/ \( targetName) .framework/ \( targetName) " ] )
702
725
}
703
726
results. checkTasks ( . matchTargetName( targetName) , . matchRuleType( " Copy " ) ) { _ in /* likely Swift-related */ }
@@ -855,6 +878,7 @@ fileprivate struct MergeableLibrariesBuildOperationTests: CoreBasedTests {
855
878
results. checkTask ( . matchTargetName( targetName) , . matchRuleType( " SwiftCompile " ) ) { _ in }
856
879
results. checkTask ( . matchTargetName( targetName) , . matchRuleType( " Ld " ) ) { task in
857
880
task. checkCommandLineContains ( " -make_mergeable " )
881
+ task. checkCommandLineDoesNotContain ( " -add_mergeable_debug_hook " )
858
882
task. checkCommandLineContains ( [ " -o " , " \( OBJROOT) /UninstalledProducts/iphoneos/ \( targetName) .framework/ \( targetName) " ] )
859
883
}
860
884
results. checkTasks ( . matchTargetName( targetName) , . matchRuleType( " Copy " ) ) { _ in /* likely Swift-related */ }
@@ -876,6 +900,7 @@ fileprivate struct MergeableLibrariesBuildOperationTests: CoreBasedTests {
876
900
task. checkCommandLineContains ( [ " -Xlinker " , " -merge_library " , " -Xlinker " , " \( OBJROOT) /UninstalledProducts/iphoneos/ \( fwkTargetName) .framework/ \( fwkTargetName) " ] )
877
901
task. checkCommandLineContains ( [ " -o " , " \( DSTROOT) /Applications/ \( targetName) .app/ \( targetName) " ] )
878
902
task. checkCommandLineDoesNotContain ( " -make_mergeable " )
903
+ task. checkCommandLineDoesNotContain ( " -add_mergeable_debug_hook " )
879
904
task. checkCommandLineDoesNotContain ( " -no_merge_framework " )
880
905
}
881
906
// 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 {
1512
1537
task. checkCommandLineContains ( [ " -Xlinker " , " -merge-l \( libBaseName) " ] )
1513
1538
task. checkCommandLineContains ( [ " -o " , " \( OBJROOT) /UninstalledProducts/iphoneos/ \( targetName) .framework/ \( targetName) " ] )
1514
1539
task. checkCommandLineDoesNotContain ( " -make_mergeable " )
1540
+ task. checkCommandLineDoesNotContain ( " -add_mergeable_debug_hook " )
1515
1541
task. checkCommandLineDoesNotContain ( " -no_merge_framework " )
1516
1542
}
1517
1543
results. checkTasks ( . matchTargetName( targetName) , . matchRuleType( " Copy " ) ) { _ in /* likely Swift-related */ }
0 commit comments