You said that you tried using a custom hook, and this method is completely valid. You do not have to manually edit the file yourself if that is what you were doing. Using a hook and using the xcode npm package will make this a lot easier. In this case you only need to specify the key and value you want to change in the project file. If you want to change your workspace configuration (build system options) you would want to use the plist npm package. Using these tools it might be less of a pain for you, if you find it easier than the other answer posted.
Example editing the project:
var xcode = require('xcode'),
fs = require('fs'),
plist = require('plist'),
projectPath = 'myproject.xcodeproj/project.pbxproj',
workspacePath = 'myproject.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings',
myProj = xcode.project(projectPath);
myProj = myProj.parseSync();
// Add variable
myProj.AddBuildProperty('DEVELOPMENT_TEAM', 'XXXX', 'Debug');
// Save project file
fs.writeFileSync(projectPath, myProj.writeSync());
// Change workspace settings (build system)
fs.writeFileSync(workspacePath, plist.build({"BuildSystemType": "Original"}));