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

Function processFileChange

src/utils/xcode-state-watcher.ts:113–176  ·  view source on GitHub ↗

* Process the file change and update session defaults

()

Source from the content-addressed store, hash-verified

111 * Process the file change and update session defaults
112 */
113async function processFileChange(): Promise<void> {
114 if (!state.watchedPath) return;
115
116 const newState = extractState(state.watchedPath);
117
118 const schemeChanged = newState.scheme !== state.cachedScheme;
119 const simulatorChanged = newState.simulatorId !== state.cachedSimulatorId;
120
121 if (!schemeChanged && !simulatorChanged) {
122 log('debug', '[xcode-watcher] File changed but scheme/simulator unchanged');
123 return;
124 }
125
126 const updates: Record<string, string> = {};
127
128 if (schemeChanged && newState.scheme) {
129 updates.scheme = newState.scheme;
130 log('info', `[xcode-watcher] Scheme changed: "${state.cachedScheme}" -> "${newState.scheme}"`);
131 state.cachedScheme = newState.scheme;
132 }
133
134 if (simulatorChanged && newState.simulatorId) {
135 updates.simulatorId = newState.simulatorId;
136 log(
137 'info',
138 `[xcode-watcher] Simulator changed: "${state.cachedSimulatorId}" -> "${newState.simulatorId}"`,
139 );
140 state.cachedSimulatorId = newState.simulatorId;
141 }
142
143 // Update session defaults immediately with scheme/simulatorId
144 if (Object.keys(updates).length > 0) {
145 sessionStore.setDefaults(updates);
146 log('info', `[xcode-watcher] Session defaults updated: ${JSON.stringify(updates)}`);
147 }
148
149 // Look up simulator name asynchronously (non-blocking)
150 if (simulatorChanged && newState.simulatorId && state.executor && state.cwd) {
151 lookupSimulatorName({ executor: state.executor, cwd: state.cwd }, newState.simulatorId)
152 .then((name) => {
153 if (name) {
154 sessionStore.setDefaults({ simulatorName: name });
155 log('info', `[xcode-watcher] Simulator name resolved: "${name}"`);
156 }
157 })
158 .catch((e) => {
159 log('debug', `[xcode-watcher] Failed to lookup simulator name: ${e}`);
160 });
161 }
162
163 // Look up bundle ID asynchronously when scheme changes (non-blocking)
164 if (schemeChanged && newState.scheme && state.executor) {
165 lookupBundleId(state.executor, newState.scheme, state.projectPath, state.workspacePath)
166 .then((bundleId) => {
167 if (bundleId) {
168 sessionStore.setDefaults({ bundleId });
169 log('info', `[xcode-watcher] Bundle ID resolved: "${bundleId}"`);
170 }

Callers 1

handleFileChangeFunction · 0.85

Calls 5

logFunction · 0.90
lookupSimulatorNameFunction · 0.90
extractStateFunction · 0.85
lookupBundleIdFunction · 0.85
setDefaultsMethod · 0.80

Tested by

no test coverage detected