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/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.
diff --git a/scripts/podify.js b/scripts/podify.js
index 639b278..f2fe57d 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: {}
};
@@ -43,6 +44,7 @@ module.exports = function (context) {
.then(createFiles)
.then(installPods)
.then(fixBundlePaths)
+ .then(fixSwiftLegacy)
.then(updateBuild);
function parseConfigXml() {
@@ -63,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 = [];
@@ -85,6 +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' : '3.0';
}
(platform.pod || []).forEach(function (pod) {
newPods.pods[pod.$.id] = pod.$;
@@ -238,6 +247,29 @@ module.exports = function (context) {
return shouldRun;
}
+
+ function fixSwiftLegacy(shouldRun){
+ var directories = getDirectories(path.join(__dirname + '/../../../platforms/ios/Pods/Target Support Files')),
+ 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');
+ 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))
+ }
+ }
+ }
+
+ console.log('Using Swift Version ' + useLegacy);
+ }
+
+ return shouldRun;
+ }
+
function updateBuild(shouldRun) {
if(shouldRun) {