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

GH-523 : ignore swift version settings of cocoapods libraries on windows #528

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
74 changes: 40 additions & 34 deletions bin/templates/scripts/cordova/Api.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ Api.prototype.addPodSpecs = function (plugin, podSpecs, frameworkPods) {

return podfileFile.install(check_reqs.check_cocoapods)
.then(function () {
self.setSwiftVersionForCocoaPodsLibraries(podsjsonFile);
return self.setSwiftVersionForCocoaPodsLibraries(podsjsonFile);
});
} else {
events.emit('verbose', 'Podfile unchanged, skipping `pod install`');
Expand Down Expand Up @@ -564,7 +564,7 @@ Api.prototype.removePodSpecs = function (plugin, podSpecs, frameworkPods) {

return podfileFile.install(check_reqs.check_cocoapods)
.then(function () {
self.setSwiftVersionForCocoaPodsLibraries(podsjsonFile);
return self.setSwiftVersionForCocoaPodsLibraries(podsjsonFile);
});
} else {
events.emit('verbose', 'Podfile unchanged, skipping `pod install`');
Expand All @@ -582,41 +582,47 @@ Api.prototype.removePodSpecs = function (plugin, podSpecs, frameworkPods) {
Api.prototype.setSwiftVersionForCocoaPodsLibraries = function (podsjsonFile) {
var self = this;
var __dirty = false;
var podPbxPath = path.join(self.root, 'Pods', 'Pods.xcodeproj', 'project.pbxproj');
var podXcodeproj = xcode.project(podPbxPath);
podXcodeproj.parseSync();
var podTargets = podXcodeproj.pbxNativeTargetSection();
var podConfigurationList = podXcodeproj.pbxXCConfigurationList();
var podConfigs = podXcodeproj.pbxXCBuildConfigurationSection();

var libraries = podsjsonFile.getLibraries();
Object.keys(libraries).forEach(function (key) {
var podJson = libraries[key];
var name = podJson.name;
var swiftVersion = podJson['swift-version'];
if (swiftVersion) {
__dirty = true;
Object.keys(podTargets).filter(function (targetKey) {
return podTargets[targetKey].productName === name;
}).map(function (targetKey) {
return podTargets[targetKey].buildConfigurationList;
}).map(function (buildConfigurationListId) {
return podConfigurationList[buildConfigurationListId];
}).map(function (buildConfigurationList) {
return buildConfigurationList.buildConfigurations;
}).reduce(function (acc, buildConfigurations) {
return acc.concat(buildConfigurations);
}, []).map(function (buildConfiguration) {
return buildConfiguration.value;
}).forEach(function (buildId) {
__dirty = true;
podConfigs[buildId].buildSettings['SWIFT_VERSION'] = swiftVersion;
return check_reqs.check_cocoapods().then(function (toolOptions) {
if (toolOptions.ignore) {
events.emit('verbose', '=== skip Swift Version Settings For Cocoapods Libraries');
} else {
var podPbxPath = path.join(self.root, 'Pods', 'Pods.xcodeproj', 'project.pbxproj');
var podXcodeproj = xcode.project(podPbxPath);
podXcodeproj.parseSync();
var podTargets = podXcodeproj.pbxNativeTargetSection();
var podConfigurationList = podXcodeproj.pbxXCConfigurationList();
var podConfigs = podXcodeproj.pbxXCBuildConfigurationSection();

var libraries = podsjsonFile.getLibraries();
Object.keys(libraries).forEach(function (key) {
var podJson = libraries[key];
var name = podJson.name;
var swiftVersion = podJson['swift-version'];
if (swiftVersion) {
__dirty = true;
Object.keys(podTargets).filter(function (targetKey) {
return podTargets[targetKey].productName === name;
}).map(function (targetKey) {
return podTargets[targetKey].buildConfigurationList;
}).map(function (buildConfigurationListId) {
return podConfigurationList[buildConfigurationListId];
}).map(function (buildConfigurationList) {
return buildConfigurationList.buildConfigurations;
}).reduce(function (acc, buildConfigurations) {
return acc.concat(buildConfigurations);
}, []).map(function (buildConfiguration) {
return buildConfiguration.value;
}).forEach(function (buildId) {
__dirty = true;
podConfigs[buildId].buildSettings['SWIFT_VERSION'] = swiftVersion;
});
}
});
if (__dirty) {
fs.writeFileSync(podPbxPath, podXcodeproj.writeSync(), 'utf-8');
}
}
});
if (__dirty) {
fs.writeFileSync(podPbxPath, podXcodeproj.writeSync(), 'utf-8');
}
};

/**
Expand Down