Disable code signing for app clip targets.

PiperOrigin-RevId: 334618523
diff --git a/src/TulsiGenerator/PBXTargetGenerator.swift b/src/TulsiGenerator/PBXTargetGenerator.swift
index a8684fd..ccce2eb 100644
--- a/src/TulsiGenerator/PBXTargetGenerator.swift
+++ b/src/TulsiGenerator/PBXTargetGenerator.swift
@@ -1656,6 +1656,13 @@
       buildSettings["TARGETED_DEVICE_FAMILY[sdk=iphonesimulator*]"] = "1,4"
     }
 
+    // App clips are improperly signed by Xcode when using the legacy build system even with
+    // CODE_SIGNING_REQUIRED=NO so disable code signing and let bazel_build.py do the necessary
+    // signing.
+    if pbxTargetType == .AppClip {
+      buildSettings["CODE_SIGNING_ALLOWED"] = "NO"
+    }
+
     // bazel_build.py uses this to determine if it needs to pass the --xcode_version flag, as the
     // flag can have implications for caching even if the user's active Xcode version is the same
     // as the flag.
diff --git a/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/AppClipProject.xcodeproj/project.pbxproj b/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/AppClipProject.xcodeproj/project.pbxproj
index e4c5eef..dcf925c 100644
--- a/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/AppClipProject.xcodeproj/project.pbxproj
+++ b/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/AppClipProject.xcodeproj/project.pbxproj
@@ -361,6 +361,7 @@
 			buildSettings = {
 				ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = "Stub Launch Image";
 				BAZEL_TARGET = "//tulsi_e2e_app_clip:AppClip";
+				CODE_SIGNING_ALLOWED = NO;
 				DEBUG_INFORMATION_FORMAT = dwarf;
 				FRAMEWORK_SEARCH_PATHS = "";
 				GCC_PREPROCESSOR_DEFINITIONS = "NDEBUG=1";
@@ -447,6 +448,7 @@
 			buildSettings = {
 				ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = "Stub Launch Image";
 				BAZEL_TARGET = "//tulsi_e2e_app_clip:AppClip";
+				CODE_SIGNING_ALLOWED = NO;
 				DEBUG_INFORMATION_FORMAT = dwarf;
 				GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1";
 				INFOPLIST_FILE = "${PROJECT_FILE_PATH}/.tulsi/Resources/StubInfoPlist.plist";
@@ -529,6 +531,7 @@
 			buildSettings = {
 				ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = "Stub Launch Image";
 				BAZEL_TARGET = "//tulsi_e2e_app_clip:AppClip";
+				CODE_SIGNING_ALLOWED = NO;
 				DEBUG_INFORMATION_FORMAT = dwarf;
 				GCC_PREPROCESSOR_DEFINITIONS = "NDEBUG=1";
 				INFOPLIST_FILE = "${PROJECT_FILE_PATH}/.tulsi/Resources/StubInfoPlist.plist";
@@ -616,6 +619,7 @@
 			buildSettings = {
 				ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = "Stub Launch Image";
 				BAZEL_TARGET = "//tulsi_e2e_app_clip:AppClip";
+				CODE_SIGNING_ALLOWED = NO;
 				DEBUG_INFORMATION_FORMAT = dwarf;
 				FRAMEWORK_SEARCH_PATHS = "";
 				GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1";
diff --git a/src/TulsiGeneratorTests/PBXTargetGeneratorTests.swift b/src/TulsiGeneratorTests/PBXTargetGeneratorTests.swift
index 52081a8..6aa4031 100644
--- a/src/TulsiGeneratorTests/PBXTargetGeneratorTests.swift
+++ b/src/TulsiGeneratorTests/PBXTargetGeneratorTests.swift
@@ -458,6 +458,107 @@
     }
   }
 
+  func testGenerateTargetsForRuleEntriesWithAppClips() {
+    let rule1BuildPath = "test/app"
+    let rule1TargetName = "TestApplication"
+    let rule1BuildTarget = "\(rule1BuildPath):\(rule1TargetName)"
+    let rule2BuildPath = "test/appclip"
+    let rule2TargetName = "TestAppClip"
+    let rule2BuildTarget = "\(rule2BuildPath):\(rule2TargetName)"
+
+    let rules = Set([
+      makeTestRuleEntry(rule1BuildTarget, type: "ios_application", appClips: Set([BuildLabel(rule2BuildTarget)]), productType: .Application),
+      makeTestRuleEntry(rule2BuildTarget, type: "ios_app_clip", productType: .AppClip),
+    ])
+
+    do {
+      _ = try targetGenerator.generateBuildTargetsForRuleEntries(
+        rules, ruleEntryMap: RuleEntryMap(), pathFilters: pathFilters)
+    } catch let e as NSError {
+      XCTFail("Failed to generate build targets with error \(e.localizedDescription)")
+    }
+
+    let topLevelConfigs = project.buildConfigurationList.buildConfigurations
+    XCTAssertEqual(topLevelConfigs.count, 0)
+
+    let targets = project.targetByName
+    XCTAssertEqual(targets.count, 2)
+
+    do {
+      let expectedBuildSettings = [
+        "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
+        "BAZEL_TARGET": "test/app:TestApplication",
+        "DEBUG_INFORMATION_FORMAT": "dwarf",
+        "INFOPLIST_FILE": stubPlistPaths.defaultStub,
+        "PRODUCT_NAME": rule1TargetName,
+        "SDKROOT": "iphoneos",
+        "TULSI_BUILD_PATH": rule1BuildPath,
+      ]
+      let expectedTarget = TargetDefinition(
+        name: rule1TargetName,
+        buildConfigurations: [
+          BuildConfigurationDefinition(
+            name: "Debug",
+            expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
+          ),
+          BuildConfigurationDefinition(
+            name: "Release",
+            expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
+          ),
+          BuildConfigurationDefinition(
+            name: "__TulsiTestRunner_Debug",
+            expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+          ),
+          BuildConfigurationDefinition(
+            name: "__TulsiTestRunner_Release",
+            expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+          ),
+        ],
+        expectedBuildPhases: [
+          BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: rule1BuildTarget),
+        ]
+      )
+      assertTarget(expectedTarget, inTargets: targets)
+    }
+    do {
+      let expectedBuildSettings = [
+        "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
+        "BAZEL_TARGET": "test/appclip:TestAppClip",
+        "CODE_SIGNING_ALLOWED": "NO",
+        "DEBUG_INFORMATION_FORMAT": "dwarf",
+        "INFOPLIST_FILE": stubPlistPaths.defaultStub,
+        "PRODUCT_NAME": rule2TargetName,
+        "SDKROOT": "iphoneos",
+        "TULSI_BUILD_PATH": rule2BuildPath,
+      ]
+      let expectedTarget = TargetDefinition(
+        name: rule2TargetName,
+        buildConfigurations: [
+          BuildConfigurationDefinition(
+            name: "Debug",
+            expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
+          ),
+          BuildConfigurationDefinition(
+            name: "Release",
+            expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
+          ),
+          BuildConfigurationDefinition(
+            name: "__TulsiTestRunner_Debug",
+            expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+          ),
+          BuildConfigurationDefinition(
+            name: "__TulsiTestRunner_Release",
+            expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+          ),
+        ],
+        expectedBuildPhases: [
+          BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: rule2BuildTarget),
+        ]
+      )
+      assertTarget(expectedTarget, inTargets: targets)
+    }
+  }
+
   func testGenerateTargetsForLinkedRuleEntriesWithNoSourcesAndSkylarkUnitTest() {
     checkGenerateTargetsForLinkedRuleEntriesWithNoSources(
       "ios_unit_test",
@@ -3127,6 +3228,7 @@
     sourceFiles: [String] = [],
     dependencies: Set<BuildLabel> = Set(),
     extensions: Set<BuildLabel>? = nil,
+    appClips: Set<BuildLabel>? = nil,
     bundleID: String? = nil,
     bundleName: String? = nil,
     productType: PBXTarget.ProductType? = nil,
@@ -3144,6 +3246,7 @@
       sourceFiles: sourceFiles,
       dependencies: dependencies,
       extensions: extensions,
+      appClips: appClips,
       bundleID: bundleID,
       bundleName: bundleName,
       productType: productType,
@@ -3168,6 +3271,7 @@
     sourceFiles: [String] = [],
     dependencies: Set<BuildLabel> = Set(),
     extensions: Set<BuildLabel>? = nil,
+    appClips: Set<BuildLabel>? = nil,
     bundleID: String? = nil,
     bundleName: String? = nil,
     productType: PBXTarget.ProductType? = nil,
@@ -3187,6 +3291,7 @@
       sourceFiles: sourceInfos,
       dependencies: dependencies,
       extensions: extensions,
+      appClips: appClips,
       bundleID: bundleID,
       bundleName: bundleName,
       productType: productType,