Skip to content

Commit

Permalink
fix(cli): replace SDK variables with default values on Cordova plugins (
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Sep 8, 2020
1 parent cfb74af commit 090427a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions cli/src/ios/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { convertToUnixPath, copySync, readFileAsync, readFileSync, removeSync, w
import { Config } from '../config';
import { join, relative, resolve } from 'path';
import { realpathSync } from 'fs';
import { Plugin, PluginType, getFilePath, getPlatformElement, getPluginType, getPlugins, printPlugins } from '../plugin';
import { Plugin, PluginType, getAllElements, getFilePath, getPlatformElement, getPluginType, getPlugins, printPlugins } from '../plugin';
import { checkAndInstallDependencies, handleCordovaPluginsJS, logCordovaManualSteps } from '../cordova';


Expand Down Expand Up @@ -132,6 +132,7 @@ async function generateCordovaPodspec(cordovaPlugins: Plugin[], config: Config,
let sourceFrameworks: Array<string> = [];
let frameworkDeps: Array<string> = [];
let compilerFlags: Array<string> = [];
let prefsArray: Array<any> = [];
let name = 'CordovaPlugins';
let sourcesFolderName = 'sources';
if (isStatic) {
Expand Down Expand Up @@ -174,6 +175,7 @@ async function generateCordovaPodspec(cordovaPlugins: Plugin[], config: Config,
}
}
});
prefsArray = prefsArray.concat(getAllElements(plugin, platform, 'preference'));
const podspecs = getPlatformElement(plugin, platform, 'podspec');
podspecs.map((podspec: any) => {
podspec.pods.map((pods: any) => {
Expand Down Expand Up @@ -234,7 +236,8 @@ async function generateCordovaPodspec(cordovaPlugins: Plugin[], config: Config,
sna.source_files = 'noarc/**/*.{swift,h,m,c,cc,mm,cpp}'
end`);
}
const frameworksString = frameworkDeps.join('\n ');
let frameworksString = frameworkDeps.join('\n ');
frameworksString = await replaceFrameworkVariables(config, prefsArray, frameworksString);
const content = `
Pod::Spec.new do |s|
s.name = '${name}'
Expand Down Expand Up @@ -360,3 +363,10 @@ async function getPluginsTask(config: Config) {
return iosPlugins;
});
}

async function replaceFrameworkVariables(config: Config, prefsArray: Array<any>, frameworkString: string) {
prefsArray.map((preference: any) => {
frameworkString = frameworkString.replace(new RegExp(('$' + preference.$.name).replace('$', '\\$&'), 'g'), preference.$.default);
});
return frameworkString;
}

0 comments on commit 090427a

Please sign in to comment.