diff --git a/cli/src/cordova.ts b/cli/src/cordova.ts
index 7195eb7e68..9acbad61db 100644
--- a/cli/src/cordova.ts
+++ b/cli/src/cordova.ts
@@ -352,44 +352,57 @@ export async function logCordovaManualSteps(
}
async function logiOSPlist(configElement: any, config: Config, plugin: Plugin) {
- const plistPath = resolve(config.ios.nativeTargetDirAbs, 'Info.plist');
- const xmlMeta = await readXML(plistPath);
- const data = await readFile(plistPath, { encoding: 'utf-8' });
- const plistData = plist.parse(data) as PlistObject;
- const dict = xmlMeta.plist.dict.pop();
- if (!dict.key.includes(configElement.$.parent)) {
- let xml = buildConfigFileXml(configElement);
- xml = `${configElement.$.parent}${getConfigFileTagContent(xml)}`;
- logger.warn(
- `Configuration required for ${c.strong(plugin.id)}.\n` +
- `Add the following to Info.plist:\n` +
- xml,
+ let plistPath = resolve(config.ios.nativeTargetDirAbs, 'Info.plist');
+ if (!(await pathExists(plistPath))) {
+ plistPath = resolve(
+ config.ios.nativeTargetDirAbs,
+ 'Base.lproj',
+ 'Info.plist',
);
- } else if (configElement.array || configElement.dict) {
- if (
- configElement.array &&
- configElement.array.length > 0 &&
- configElement.array[0].string
- ) {
- let xml = '';
- configElement.array[0].string.map((element: any) => {
- const d = plistData[configElement.$.parent];
- if (Array.isArray(d) && !d.includes(element)) {
- xml = xml.concat(`${element}\n`);
+ }
+ if (await pathExists(plistPath)) {
+ const xmlMeta = await readXML(plistPath);
+ const data = await readFile(plistPath, { encoding: 'utf-8' });
+ const plistData = plist.parse(data) as PlistObject;
+ const dict = xmlMeta.plist.dict.pop();
+ if (!dict.key.includes(configElement.$.parent)) {
+ let xml = buildConfigFileXml(configElement);
+ xml = `${configElement.$.parent}${getConfigFileTagContent(
+ xml,
+ )}`;
+ logger.warn(
+ `Configuration required for ${c.strong(plugin.id)}.\n` +
+ `Add the following to Info.plist:\n` +
+ xml,
+ );
+ } else if (configElement.array || configElement.dict) {
+ if (
+ configElement.array &&
+ configElement.array.length > 0 &&
+ configElement.array[0].string
+ ) {
+ let xml = '';
+ configElement.array[0].string.map((element: any) => {
+ const d = plistData[configElement.$.parent];
+ if (Array.isArray(d) && !d.includes(element)) {
+ xml = xml.concat(`${element}\n`);
+ }
+ });
+ if (xml.length > 0) {
+ logger.warn(
+ `Configuration required for ${c.strong(plugin.id)}.\n` +
+ `Add the following in the existing ${c.strong(
+ configElement.$.parent,
+ )} array of your Info.plist:\n` +
+ xml,
+ );
}
- });
- if (xml.length > 0) {
- logger.warn(
- `Configuration required for ${c.strong(plugin.id)}.\n` +
- `Add the following in the existing ${c.strong(
- configElement.$.parent,
- )} array of your Info.plist:\n` +
- xml,
- );
+ } else {
+ logPossibleMissingItem(configElement, plugin);
}
- } else {
- logPossibleMissingItem(configElement, plugin);
}
+ } else {
+ logPossibleMissingItem(configElement, plugin);
}
}