Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): replace SDK variables with default values on Cordova plugins #3525

Merged
merged 1 commit into from
Sep 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}