MCPcopy Index your code
hub / github.com/getsentry/XcodeBuildMCP / lookupBundleId

Function lookupBundleId

src/utils/xcode-state-watcher.ts:47–76  ·  view source on GitHub ↗
(
  executor: CommandExecutor,
  scheme: string,
  projectPath?: string | null,
  workspacePath?: string | null,
)

Source from the content-addressed store, hash-verified

45 * Look up bundle ID for a scheme using xcodebuild -showBuildSettings
46 */
47export async function lookupBundleId(
48 executor: CommandExecutor,
49 scheme: string,
50 projectPath?: string | null,
51 workspacePath?: string | null,
52): Promise<string | undefined> {
53 const args = ['xcodebuild', '-showBuildSettings', '-scheme', scheme, '-skipPackageUpdates'];
54
55 if (workspacePath) {
56 args.push('-workspace', workspacePath);
57 } else if (projectPath) {
58 args.push('-project', projectPath);
59 } else {
60 // No project/workspace specified, let xcodebuild find it
61 }
62
63 const result = await executor(args, 'Get bundle ID from build settings', false);
64
65 if (!result.success) {
66 log('debug', `[xcode-watcher] Failed to get build settings: ${result.error}`);
67 return undefined;
68 }
69
70 const matches = [...result.output.matchAll(/PRODUCT_BUNDLE_IDENTIFIER\s*=\s*(.+)/g)]
71 .map((match) => match[1]?.trim())
72 .filter((value): value is string => Boolean(value) && value !== 'NO');
73
74 const preferredMatch = matches.find((value) => value.includes('.'));
75 return preferredMatch ?? matches[0];
76}
77
78/**
79 * Extract scheme and simulator ID from xcuserstate file

Callers 3

bootstrapServerFunction · 0.90
processFileChangeFunction · 0.85

Calls 3

logFunction · 0.90
pushMethod · 0.80
executorFunction · 0.50

Tested by

no test coverage detected