Skip to content

Commit f73c1b9

Browse files
committed
Update PBXNativeTarget.ts
1 parent b2a8a1a commit f73c1b9

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

src/api/PBXNativeTarget.ts

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,12 @@ export class PBXNativeTarget extends AbstractTarget<PBXNativeTargetModel> {
210210
);
211211
});
212212
if (existing) {
213-
return existing as PBXCopyFilesBuildPhase;
213+
const phase = existing as PBXCopyFilesBuildPhase;
214+
// Ensure correct settings even for existing phases.
215+
// This handles cases where an existing phase has incorrect dstPath/dstSubfolderSpec,
216+
// which can cause App Store validation failures (e.g., watch apps must be in Watch/ subdirectory).
217+
phase.ensureDefaultsForTarget(target);
218+
return phase;
214219
}
215220

216221
const phase = this.createBuildPhase(PBXCopyFilesBuildPhase, {
@@ -223,13 +228,35 @@ export class PBXNativeTarget extends AbstractTarget<PBXNativeTargetModel> {
223228
return phase;
224229
}
225230

231+
/**
232+
* Returns true if this target is a watchOS application.
233+
* This includes both legacy watchOS app types (watchapp, watchapp2) and
234+
* modern watchOS apps which use the standard application product type
235+
* with SDKROOT = watchos in build settings.
236+
*/
226237
isWatchOSTarget(): boolean {
227-
return (
238+
// Legacy watchOS app product types
239+
if (
228240
this.props.productType === "com.apple.product-type.application.watchapp" ||
229241
this.props.productType === "com.apple.product-type.application.watchapp2" ||
230242
this.props.productType ===
231243
"com.apple.product-type.application.watchapp2-container"
232-
);
244+
) {
245+
return true;
246+
}
247+
248+
// Modern watchOS apps use com.apple.product-type.application with
249+
// SDKROOT = watchos in build settings
250+
if (this.props.productType === "com.apple.product-type.application") {
251+
const buildSettings =
252+
this.props.buildConfigurationList?.props.buildConfigurations?.[0]?.props
253+
.buildSettings;
254+
if (buildSettings && buildSettings.SDKROOT === "watchos") {
255+
return true;
256+
}
257+
}
258+
259+
return false;
233260
}
234261

235262
isWatchExtension(): boolean {

0 commit comments

Comments
 (0)