Last active
September 24, 2016 02:31
-
-
Save Delagen/47d74d9604f5b8e9af45 to your computer and use it in GitHub Desktop.
Revisions
-
Delagen revised this gist
Sep 17, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,6 @@ /*use in config.xml <hook type="after_platform_add" src="../path/to/cordova-ios-disable-push.js"/>*/ var fs = require("fs"); var path = require("path"); var COMMENT_KEY = /_comment$/; function nonComments(obj) { @@ -29,6 +28,7 @@ module.exports = function(ctx) { var projectName = /<name[^>]*>([\s\S]*)<\/name>/mi.exec(configContent)[1].trim(); var xcodeProjectName = [projectName, ".xcodeproj"].join(""); var xcodeProjectPath = path.join(ctx.opts.projectRoot, "platforms", "ios", xcodeProjectName, "project.pbxproj"); var xcode = ctx.requireCordovaModule("xcode"); var xcodeProject = xcode.project(xcodeProjectPath); xcodeProject.parse(function(parseError) { if (parseError) { -
Delagen created this gist
Aug 31, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,54 @@ "use strict"; /*use in config.xml <hook type="after_platform_add" src="../path/to/cordova-ios-disable-push.js"/>*/ var fs = require("fs"); var path = require("path"); var xcode = require("xcode"); var COMMENT_KEY = /_comment$/; function nonComments(obj) { var newObj = {}; Object.keys(obj).forEach(function(key) { if (!COMMENT_KEY.test(key)) { newObj[key] = obj[key]; } }); return newObj; } module.exports = function(ctx) { var GCC_PREPROCESSOR_DEFINITIONS = '"$(inherited) DISABLE_PUSH_NOTIFICATIONS=1"'; var q = ctx.requireCordovaModule("q"); var deferred = q.defer(); var cordovaConfigPath = path.join(ctx.opts.projectRoot, "config.xml"); fs.readFile(cordovaConfigPath, {encoding: "utf-8"}, function(errConfigRead, configContent) { if (errConfigRead) { return deferred.reject(errConfigRead); } var projectName = /<name[^>]*>([\s\S]*)<\/name>/mi.exec(configContent)[1].trim(); var xcodeProjectName = [projectName, ".xcodeproj"].join(""); var xcodeProjectPath = path.join(ctx.opts.projectRoot, "platforms", "ios", xcodeProjectName, "project.pbxproj"); var xcodeProject = xcode.project(xcodeProjectPath); xcodeProject.parse(function(parseError) { if (parseError) { return deferred.reject(parseError); } var configurations = nonComments(xcodeProject.pbxXCBuildConfigurationSection()); Object.keys(configurations).forEach(function(config) { var buildSettings = configurations[config].buildSettings; buildSettings.GCC_PREPROCESSOR_DEFINITIONS = GCC_PREPROCESSOR_DEFINITIONS; }); fs.writeFile(xcodeProjectPath, /*eslint-disable no-sync*/xcodeProject.writeSync()/*eslint-enable*/, {encoding: "utf-8"}, function(projectWriteError) { if (projectWriteError) { return deferred.reject(projectWriteError); } deferred.resolve(); }); }); }); return deferred.promise; };