Entitlements reference check compares forward-slash paths on every OS (false 'not referenced by CODE_SIGN_ENTITLEMENTS' on Windows); test, pitfall 103

This commit is contained in:
CRTkafa 2026-10-22 16:03:07 +08:00
parent e7874a2c25
commit cbba936ed8
4 changed files with 33 additions and 3 deletions

View file

@ -14,7 +14,7 @@
import { ensureGcSwitch, gcSwitchPlan, readGcSwitch } from './game-center';
import { chmodSync, existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';
import { homedir, tmpdir } from 'node:os';
import { basename, dirname, join, relative, resolve as resolvePath } from 'node:path';
import { basename, dirname, join, relative, resolve as resolvePath, sep } from 'node:path';
import type { Ctx } from '../lib/ctx';
import { confirm, need } from '../lib/ctx';
import { buildCsr, csrContent, newSigningKey, spkiOfKey } from '../lib/csr';
@ -83,9 +83,11 @@ export function readProjectEntitlements(root: string): ProjectEntitlements[] | n
for (const n of names) {
const f = join(dir, n);
if (n.endsWith('.entitlements')) {
const rel = relative(root, f);
// forward slashes on every OS: the pbxproj writes App/App.entitlements, Windows paths use backslashes
const rel = relative(root, f).split(sep).join('/');
const fwd = f.split(sep).join('/');
if (isBuildCopyPath(rel) || out.some(o => o.file === rel)) continue;
out.push(projectEntitlements(rel, readFileSync(f, 'utf8'), pbx ? refs.some(r => f.endsWith('/' + r)) : null));
out.push(projectEntitlements(rel, readFileSync(f, 'utf8'), pbx ? refs.some(r => fwd.endsWith('/' + r.replace(/\\/g, '/'))) : null));
} else if (d > 0 && !n.startsWith('.') && !['node_modules', 'Pods', 'build', 'DerivedData'].includes(n) && !n.endsWith('.xcodeproj')) {
try { if (statSync(f).isDirectory()) walk(f, d - 1); } catch { /* unreadable */ }
}