From 604db13d167b59ad807f5026094c003386768a07 Mon Sep 17 00:00:00 2001 From: Giacomo Balli Date: Thu, 2 Apr 2026 11:35:00 -0700 Subject: [PATCH] Embed watchOS apps in PlugIns directory for Xcode 16+ Starting with Xcode 16, watchOS apps must be embedded in the parent app bundle's PlugIns/ directory (dstSubfolderSpec=13) instead of the legacy Watch/ directory (dstSubfolderSpec=16). Gate the behavior on xcodeVersion so older projects continue to work. Fixes #1613 --- Sources/XcodeGenKit/PBXProjGenerator.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Sources/XcodeGenKit/PBXProjGenerator.swift b/Sources/XcodeGenKit/PBXProjGenerator.swift index 1f20e850..3cdaabc2 100644 --- a/Sources/XcodeGenKit/PBXProjGenerator.swift +++ b/Sources/XcodeGenKit/PBXProjGenerator.swift @@ -1295,11 +1295,15 @@ public class PBXProjGenerator { } if !copyWatchReferences.isEmpty { + // Xcode 16+ requires watchOS apps to be embedded in PlugIns/ + // (as foundation extensions) instead of the legacy Watch/ directory. + let xcodeVersionNumber = Int(project.xcodeVersion.prefix(2)) ?? 0 + let usePlugIns = xcodeVersionNumber >= 16 let copyFilesPhase = addObject( PBXCopyFilesBuildPhase( - dstPath: "$(CONTENTS_FOLDER_PATH)/Watch", - dstSubfolderSpec: .productsDirectory, + dstPath: usePlugIns ? "" : "$(CONTENTS_FOLDER_PATH)/Watch", + dstSubfolderSpec: usePlugIns ? .plugins : .productsDirectory, name: "Embed Watch Content", files: copyWatchReferences )