Skip to content
This repository has been archived by the owner on Oct 2, 2021. It is now read-only.

Commit

Permalink
Set SWIFT_VERSION on Xcode project
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnwalraven committed Oct 3, 2016
1 parent 0026e0c commit a27143f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion plugin.xml
Expand Up @@ -22,7 +22,7 @@

<platform name="ios">
<hook type="after_plugin_install" src="scripts/iosAddBridgingHeader.js" />
<hook type="before_prepare" src="scripts/iosSetLastSwiftUpdateCheck.js" />
<hook type="before_prepare" src="scripts/iosSetSwiftVersion.js" />

<config-file target="config.xml" parent="/*">
<feature name="WebAppLocalServer">
Expand Down
Expand Up @@ -15,16 +15,30 @@ module.exports = function(context) {
var projectPath = path.join(platformRoot, projectName + '.xcodeproj/project.pbxproj');
var xcodeProject = xcode.project(projectPath);

xcodeProject.parse(function(error) {
if (error) {
console.log('Error: ' + JSON.stringify(error));
} else {
var pbxProjectSection = xcodeProject.pbxProjectSection();
var firstProjectUUID = Object.keys(pbxProjectSection)[0];
var firstProject = pbxProjectSection[firstProjectUUID];
// Xcode 7.2
firstProject.attributes['LastSwiftUpdateCheck'] = '0720';
fs.writeFileSync(projectPath, xcodeProject.writeSync());
xcodeProject.parseSync();

var configurations, buildSettings;
configurations = nonComments(xcodeProject.pbxXCBuildConfigurationSection());
Object.keys(configurations).forEach(function (config) {
buildSettings = configurations[config].buildSettings;
buildSettings.SWIFT_VERSION = '3.0';

This comment has been minimized.

Copy link
@nerdmed

nerdmed Oct 18, 2016

@martijnwalraven is the master now compatible with swift 3 or should we stick with the swift3 branch for now?

This comment has been minimized.

Copy link
@martijnwalraven

martijnwalraven Oct 18, 2016

Author Contributor

Master is both compatible and more recent. I just deleted the swift3 branch to avoid further confusion.

This comment has been minimized.

Copy link
@nerdmed

nerdmed Oct 18, 2016

ok great thx

});

fs.writeFileSync(projectPath, xcodeProject.writeSync());
}

// Extracted from https://github.com/alunny/node-xcode/blob/master/lib/pbxProject.js

COMMENT_KEY = /_comment$/;

function nonComments(obj) {
var keys = Object.keys(obj), newObj = {}, i = 0;

for (i; i < keys.length; i++) {
if (!COMMENT_KEY.test(keys[i])) {
newObj[keys[i]] = obj[keys[i]];
}
});
}

return newObj;
}

0 comments on commit a27143f

Please sign in to comment.