diff --git a/lib/pbxProject.js b/lib/pbxProject.js index 41bc398..25bd8f3 100644 --- a/lib/pbxProject.js +++ b/lib/pbxProject.js @@ -1621,6 +1621,12 @@ function pbxShellScriptBuildPhaseObj (obj, options, phaseName) { obj.runOnlyForDeploymentPostprocessing = 1; } + // By default, alwaysOutOfDate is not set and treated as false. + // Any truthy value, it will be set to 1, including any non-empty strings. + if (options.alwaysOutOfDate) { + obj.alwaysOutOfDate = 1; + } + return obj; } diff --git a/test/addBuildPhase.js b/test/addBuildPhase.js index d3249b9..5d1ace2 100644 --- a/test/addBuildPhase.js +++ b/test/addBuildPhase.js @@ -197,4 +197,26 @@ describe('addBuildPhase', () => { const buildPhase = proj.addBuildPhase([], 'PBXShellScriptBuildPhase', 'Run a script', proj.getFirstTarget().uuid, options).buildPhase; assert.equal(buildPhase.runOnlyForDeploymentPostprocessing, 1); }); + + it('should add the PBXBuildPhase with alwaysOutOfDate property', () => { + const options = { + shellPath: '/bin/sh', + shellScript: 'test', + alwaysOutOfDate: true + }; + + const buildPhase = proj.addBuildPhase([], 'PBXShellScriptBuildPhase', 'Run a script', proj.getFirstTarget().uuid, options).buildPhase; + assert.equal(buildPhase.shellPath, '/bin/sh'); + assert.equal(buildPhase.shellScript, '"test"'); + assert.strictEqual(buildPhase.alwaysOutOfDate, 1); + }); + + it('should add the PBXBuildPhase without alwaysOutOfDate property', () => { + const options = { shellPath: '/bin/sh', shellScript: 'test' }; + + const buildPhase = proj.addBuildPhase([], 'PBXShellScriptBuildPhase', 'Run a script', proj.getFirstTarget().uuid, options).buildPhase; + assert.equal(buildPhase.shellPath, '/bin/sh'); + assert.equal(buildPhase.shellScript, '"test"'); + assert.strictEqual(buildPhase.alwaysOutOfDate, undefined); + }); });