Skip to content

Commit 419cab1

Browse files
committed
fix: xmlUpdates and plistUpdates
1 parent 282cd9a commit 419cab1

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

packages/nx/src/utils/executors.ts

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,11 @@ export function commonExecutor(options: ExecutorSchema, context: ExecutorContext
6565
additionalArgs.push(...options.flags.split(' '));
6666
}
6767

68-
if (options.android?.xmlUpdates) updateXml(options.android.xmlUpdates, 'android');
69-
if (options.ios?.plistUpdates) updateXml(options.ios.plistUpdates, 'ios');
68+
if (isAndroid && options?.xmlUpdates) {
69+
updateXml(options?.xmlUpdates, 'android');
70+
} else if (options?.plistUpdates) {
71+
updateXml(options.plistUpdates, 'ios');
72+
}
7073

7174
await checkOptions();
7275

@@ -223,10 +226,34 @@ export function commonExecutor(options: ExecutorSchema, context: ExecutorContext
223226
recursiveUpdate(target[key], updates[key]);
224227
} else {
225228
if (Array.isArray(target[key])) {
226-
recursiveUpdate(target[key], updates[key]);
229+
// Handle Android XML string resources
230+
if (type === 'android' && key === 'string' && Array.isArray(updates[key])) {
231+
// updates[key] is an array of objects with name-value pairs
232+
for (const updateItem of updates[key]) {
233+
for (const nameAttr in updateItem) {
234+
const newValue = updateItem[nameAttr];
235+
// Find the string element with matching name attribute
236+
for (let i = 0; i < target[key].length; i++) {
237+
const stringElement = target[key][i];
238+
if (stringElement && typeof stringElement === 'object' && stringElement.name === nameAttr) {
239+
// Update the text content (value) of the string element
240+
if (stringElement['#text'] !== newValue) {
241+
stringElement['#text'] = newValue;
242+
needsUpdate = true;
243+
}
244+
break;
245+
}
246+
}
247+
}
248+
}
249+
} else {
250+
recursiveUpdate(target[key], updates[key]);
251+
}
227252
} else {
228-
target[key] = updates[key];
229-
needsUpdate = true;
253+
if (target[key] !== updates[key]) {
254+
target[key] = updates[key];
255+
needsUpdate = true;
256+
}
230257
}
231258
}
232259
}

0 commit comments

Comments
 (0)