diff --git a/lib/pbxProject.js b/lib/pbxProject.js index 299a7cc..41bc398 100644 --- a/lib/pbxProject.js +++ b/lib/pbxProject.js @@ -1615,6 +1615,12 @@ function pbxShellScriptBuildPhaseObj (obj, options, phaseName) { obj.shellPath = options.shellPath; obj.shellScript = '"' + options.shellScript.replace(/"/g, '\\"') + '"'; + // By default, runOnlyForDeploymentPostprocessing is set to 0. + // Any truthy value, it will be set to 1, including any non-empty strings. + if (options.runOnlyForDeploymentPostprocessing) { + obj.runOnlyForDeploymentPostprocessing = 1; + } + return obj; } diff --git a/test/addBuildPhase.js b/test/addBuildPhase.js index f653f09..d3249b9 100644 --- a/test/addBuildPhase.js +++ b/test/addBuildPhase.js @@ -191,4 +191,10 @@ describe('addBuildPhase', () => { assert.equal(buildPhase.shellPath, '/bin/sh'); assert.equal(buildPhase.shellScript, '"echo \\"hello world!\\""'); }); + + it('should add runOnlyForDeploymentPostprocessing option to run scripts', () => { + const options = { shellPath: '/bin/sh', shellScript: 'echo "hello world!"', runOnlyForDeploymentPostprocessing: 1 }; + const buildPhase = proj.addBuildPhase([], 'PBXShellScriptBuildPhase', 'Run a script', proj.getFirstTarget().uuid, options).buildPhase; + assert.equal(buildPhase.runOnlyForDeploymentPostprocessing, 1); + }); });