diff --git a/Sources/SWBApplePlatform/Specs/AppIntentsMetadata.xcspec b/Sources/SWBApplePlatform/Specs/AppIntentsMetadata.xcspec index 91487be6..60791556 100644 --- a/Sources/SWBApplePlatform/Specs/AppIntentsMetadata.xcspec +++ b/Sources/SWBApplePlatform/Specs/AppIntentsMetadata.xcspec @@ -203,6 +203,15 @@ NO = (); }; }, + { + Name = LM_ENABLE_APP_NAME_OVERRIDE; + Type = Boolean; + DefaultValue = NO; + CommandLineArgs = { + YES = ( "--app-shortcuts-app-name-override" ); + NO = (); + }; + }, ); }, ) diff --git a/Tests/SWBTaskConstructionTests/AppIntentsMetadataTaskConstructionTests.swift b/Tests/SWBTaskConstructionTests/AppIntentsMetadataTaskConstructionTests.swift index afd64f3c..cacf5453 100644 --- a/Tests/SWBTaskConstructionTests/AppIntentsMetadataTaskConstructionTests.swift +++ b/Tests/SWBTaskConstructionTests/AppIntentsMetadataTaskConstructionTests.swift @@ -1595,6 +1595,133 @@ fileprivate struct AppIntentsMetadataTaskConstructionTests: CoreBasedTests { } } + @Test(.requireSDKs(.iOS)) + func appNameOverrideIsNotPresent() async throws { + try await withTemporaryDirectory { tmpDir in + let testProject = try await TestProject( + "aProject", + sourceRoot: tmpDir, + groupTree: TestGroup( + "SomeFiles", + children: [ + TestFile("source.swift"), + TestFile(appShortcutsStringsFileName) + ]), + buildConfigurations: [ + TestBuildConfiguration( + "Debug", + buildSettings: [ + "AD_HOC_CODE_SIGNING_ALLOWED": "YES", + "ARCHS": "arm64", + "CODE_SIGN_IDENTITY": "-", + "GENERATE_INFOPLIST_FILE": "YES", + "PRODUCT_BUNDLE_IDENTIFIER": "com.foo.bar", + "PRODUCT_NAME": "$(TARGET_NAME)", + "SDKROOT": "iphoneos", + "SWIFT_EXEC": swiftCompilerPath.str, + "SWIFT_VERSION": swiftVersion, + "VERSIONING_SYSTEM": "apple-generic", + "SWIFT_EMIT_CONST_VALUE_PROTOCOLS": "Foo Bar", + ]), + ], + targets: [ + TestStandardTarget( + "LinkTest", + type: .application, + buildConfigurations: [ + TestBuildConfiguration( + "Debug", + buildSettings: [ + "LM_ENABLE_LINK_GENERATION": "YES", + "LM_ENABLE_APP_NAME_OVERRIDE": "NO" + ]), + ], + buildPhases: [ + TestResourcesBuildPhase([TestBuildFile(appShortcutsStringsFileName)]), + TestSourcesBuildPhase(["source.swift"]), + ] + ) + ]) + + let core = try await getCore() + let tester = try TaskConstructionTester(core, testProject) + await tester.checkBuild(runDestination: .iOS) { results in + results.checkTask(.matchRuleType("ExtractAppIntentsMetadata")) { task in + let executableName = task.commandLine.first + if let executableName, + executableName == "appintentsmetadataprocessor" { + task.checkCommandLineDoesNotContain("--app-shortcuts-app-name-override") + } + results.checkNoDiagnostics() + } + } + } + } + + + @Test(.requireSDKs(.iOS)) + func appNameOverride() async throws { + try await withTemporaryDirectory { tmpDir in + let testProject = try await TestProject( + "aProject", + sourceRoot: tmpDir, + groupTree: TestGroup( + "SomeFiles", + children: [ + TestFile("source.swift"), + TestFile(appShortcutsStringsFileName) + ]), + buildConfigurations: [ + TestBuildConfiguration( + "Debug", + buildSettings: [ + "AD_HOC_CODE_SIGNING_ALLOWED": "YES", + "ARCHS": "arm64", + "CODE_SIGN_IDENTITY": "-", + "GENERATE_INFOPLIST_FILE": "YES", + "PRODUCT_BUNDLE_IDENTIFIER": "com.foo.bar", + "PRODUCT_NAME": "$(TARGET_NAME)", + "SDKROOT": "iphoneos", + "SWIFT_EXEC": swiftCompilerPath.str, + "SWIFT_VERSION": swiftVersion, + "VERSIONING_SYSTEM": "apple-generic", + "SWIFT_EMIT_CONST_VALUE_PROTOCOLS": "Foo Bar", + ]), + ], + targets: [ + TestStandardTarget( + "LinkTest", + type: .application, + buildConfigurations: [ + TestBuildConfiguration( + "Debug", + buildSettings: [ + "LM_ENABLE_LINK_GENERATION": "YES", + "LM_ENABLE_APP_NAME_OVERRIDE": "YES" + ]), + ], + buildPhases: [ + TestResourcesBuildPhase([TestBuildFile(appShortcutsStringsFileName)]), + TestSourcesBuildPhase(["source.swift"]), + ] + ) + ]) + + let core = try await getCore() + let tester = try TaskConstructionTester(core, testProject) + await tester.checkBuild(runDestination: .iOS) { results in + results.checkTask(.matchRuleType("ExtractAppIntentsMetadata")) { task in + let executableName = task.commandLine.first + if let executableName, + executableName == "appintentsmetadataprocessor" { + task.checkCommandLineContains(["--app-shortcuts-app-name-override"]) + } + results.checkNoDiagnostics() + } + } + } + } + @Test(.requireSDKs(.iOS)) func quietWarnings() async throws { try await withTemporaryDirectory { tmpDir in