From 3af9fd9904c6231fa5f6dfbaba5883a2ed301a9b Mon Sep 17 00:00:00 2001 From: Aerex Date: Mon, 26 Sep 2016 12:59:15 -0500 Subject: [PATCH 1/4] check legacy flag for pods --- scripts/podify.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/podify.js b/scripts/podify.js index 639b278..ff142d4 100755 --- a/scripts/podify.js +++ b/scripts/podify.js @@ -32,6 +32,7 @@ module.exports = function (context) { var schemesSrcDir = path.join(pluginDir, 'schemes'); var schemesTargetDir = path.join(sharedDataDir, 'xcschemes'); var bundlePathsToFix = []; + var useLegacy; var newPods = { pods: {} }; @@ -85,6 +86,7 @@ module.exports = function (context) { if(podsConfig) { iosMinVersion = maxVer(iosMinVersion, podsConfig.$['ios-min-version']); useFrameworks = podsConfig.$['use-frameworks'] === 'true' ? 'true' : useFrameworks; + useLegacy = podsConfig.$['use-legacy'] === 'true' ? '2.3' : useLegacy; } (platform.pod || []).forEach(function (pod) { newPods.pods[pod.$.id] = pod.$; @@ -176,6 +178,14 @@ module.exports = function (context) { } + if(useLegacy){ + for(podId in newPods.pods){ + var podXcContents = fs.readFileSync('platforms/ios/Pods/Target Support Files/' + podId + '/' + podId + '.xcconfig', 'utf8'); + fs.writeFileSync('platforms/ios/Pods/Target Support Files/' + podId + '/' + podId + '.xconfig', podXcContents + '\n' + 'SWIFT_VERSION=2.3') + console.log('Writing Legacy Swift Version 2.3'); + } + } + fs.writeFileSync(podConfigPath, JSON.stringify(newPods, null, '\t')); } else { console.log('No new pods detects'); From 5c8af113dc19663a5b5d1451dcaa4674056f07e7 Mon Sep 17 00:00:00 2001 From: Aerex Date: Mon, 26 Sep 2016 14:14:49 -0500 Subject: [PATCH 2/4] error in README for enable 'use-frameworks' and included instructions on how to enable legacy mode for swift --- README.md | 6 ++++-- scripts/podify.js | 35 ++++++++++++++++++++++++++--------- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index d9265d9..1db3860 100644 --- a/README.md +++ b/README.md @@ -41,8 +41,8 @@ In a plugin's plugin.xml - - + + @@ -94,6 +94,8 @@ or have a look at [the demo plugin](https://github.com/blakgeek/cordova-plugin-w * Enabling the pods_use_frameworks preference disables the bridged headers property added by [CB-10072](https://issues.apache.org/jira/browse/CB-10072). This might cause odd behavior in some projects. +* If legacy is not used for swift the default version will be 3.0 + ##TODO: * Update with examples of all of the supported pod attributes (git, podspec, path, subspec, configuration(s) ) diff --git a/scripts/podify.js b/scripts/podify.js index ff142d4..335b0d8 100755 --- a/scripts/podify.js +++ b/scripts/podify.js @@ -44,6 +44,7 @@ module.exports = function (context) { .then(createFiles) .then(installPods) .then(fixBundlePaths) + .then(fixSwiftLegacy) .then(updateBuild); function parseConfigXml() { @@ -64,6 +65,12 @@ module.exports = function (context) { }); } + function getDirectories(srcpath) { + return fs.readdirSync(srcpath).filter(function(file) { + return fs.statSync(path.join(srcpath, file)).isDirectory(); + }); + } + function parsePluginXmls() { var promises = []; @@ -86,7 +93,7 @@ module.exports = function (context) { if(podsConfig) { iosMinVersion = maxVer(iosMinVersion, podsConfig.$['ios-min-version']); useFrameworks = podsConfig.$['use-frameworks'] === 'true' ? 'true' : useFrameworks; - useLegacy = podsConfig.$['use-legacy'] === 'true' ? '2.3' : useLegacy; + useLegacy = podsConfig.$['use-legacy'] === 'true' ? '2.3' : '3.0'; } (platform.pod || []).forEach(function (pod) { newPods.pods[pod.$.id] = pod.$; @@ -178,14 +185,6 @@ module.exports = function (context) { } - if(useLegacy){ - for(podId in newPods.pods){ - var podXcContents = fs.readFileSync('platforms/ios/Pods/Target Support Files/' + podId + '/' + podId + '.xcconfig', 'utf8'); - fs.writeFileSync('platforms/ios/Pods/Target Support Files/' + podId + '/' + podId + '.xconfig', podXcContents + '\n' + 'SWIFT_VERSION=2.3') - console.log('Writing Legacy Swift Version 2.3'); - } - } - fs.writeFileSync(podConfigPath, JSON.stringify(newPods, null, '\t')); } else { console.log('No new pods detects'); @@ -248,6 +247,24 @@ module.exports = function (context) { return shouldRun; } + + function fixSwiftLegacy(shouldRun){ + var directories = getDirectories(path.join(__dirname + '/../../../platforms/ios/Pods/Target Support Files')), + podXcContents; + if(useLegacy){ + for(var i = 0; i < directories.length; i++){ + if(directories[i].indexOf(appName) === -1){ + podXcContents = fs.readFileSync('platforms/ios/Pods/Target Support Files/' + directories[i] + '/' + directories[i] + '.xcconfig', 'utf8'); + fs.writeFileSync('platforms/ios/Pods/Target Support Files/' + directories[i] + '/' + directories[i] + '.xcconfig', podXcContents + '\n' + 'SWIFT_VERSION=' + useLegacy) + } + } + + console.log('Using Swift Version ' + useLegacy); + } + + return shouldRun; + } + function updateBuild(shouldRun) { if(shouldRun) { From 7c7af25372da4b113ef7e48e909bcdf4e58eca75 Mon Sep 17 00:00:00 2001 From: Aerex Date: Mon, 26 Sep 2016 14:18:16 -0500 Subject: [PATCH 3/4] update version of plugin to 1.12.11 --- plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.xml b/plugin.xml index 73337a4..3342b3b 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,5 +1,5 @@ - + Cordova CocoaPods Dependency Support Carlos "blakgeek" Lawton A Cordova/PhoneGap plugin to add support for CocoaPods dependencies. From c14b40f9603e4a475107abe6c9cfe92c99386039 Mon Sep 17 00:00:00 2001 From: Aerex Date: Mon, 26 Sep 2016 14:53:26 -0500 Subject: [PATCH 4/4] If SWIFT_VERSION exist only replace the value otherwise add a new entry to build config --- scripts/podify.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/podify.js b/scripts/podify.js index 335b0d8..f2fe57d 100755 --- a/scripts/podify.js +++ b/scripts/podify.js @@ -250,12 +250,17 @@ module.exports = function (context) { function fixSwiftLegacy(shouldRun){ var directories = getDirectories(path.join(__dirname + '/../../../platforms/ios/Pods/Target Support Files')), - podXcContents; + podXcContents, + SWIFT_VERSION_REGX = /SWIFT_VERSION=(?:\d*\.)\d/g; if(useLegacy){ for(var i = 0; i < directories.length; i++){ if(directories[i].indexOf(appName) === -1){ podXcContents = fs.readFileSync('platforms/ios/Pods/Target Support Files/' + directories[i] + '/' + directories[i] + '.xcconfig', 'utf8'); - fs.writeFileSync('platforms/ios/Pods/Target Support Files/' + directories[i] + '/' + directories[i] + '.xcconfig', podXcContents + '\n' + 'SWIFT_VERSION=' + useLegacy) + if(podXcContents.indexOf('SWIFT_VERSION') === -1){ + fs.writeFileSync('platforms/ios/Pods/Target Support Files/' + directories[i] + '/' + directories[i] + '.xcconfig', podXcContents + '\n' + 'SWIFT_VERSION=' + useLegacy) + } else { + fs.writeFileSync('platforms/ios/Pods/Target Support Files/' + directories[i] + '/' + directories[i] + '.xcconfig', podXcContents.replace(SWIFT_VERSION_REGX, 'SWIFT_VERSION=' + useLegacy)) + } } }