diff --git a/lib/build.js b/lib/build.js index 236e46e96..11a6df614 100644 --- a/lib/build.js +++ b/lib/build.js @@ -406,6 +406,19 @@ function getXcodeBuildArgs (projectPath, configuration, emulatorTarget, buildCon */ function getXcodeArchiveArgs (projectPath, outputPath, exportOptionsPath, buildConfig = {}) { const options = []; + const buildFlags = buildConfig.buildFlag; + const customArgs = {}; + customArgs.otherFlags = []; + + if (buildFlags) { + if (typeof buildFlags === 'string' || buildFlags instanceof String) { + parseBuildFlag(buildFlags, customArgs); + } else { // buildFlags is an Array of strings + buildFlags.forEach(flag => { + parseBuildFlag(flag, customArgs); + }); + } + } if (buildConfig.automaticProvisioning) { options.push('-allowProvisioningUpdates'); @@ -422,10 +435,10 @@ function getXcodeArchiveArgs (projectPath, outputPath, exportOptionsPath, buildC return [ '-exportArchive', - '-archivePath', 'App.xcarchive', + '-archivePath', customArgs.archivePath || 'App.xcarchive', '-exportOptionsPlist', exportOptionsPath, '-exportPath', outputPath - ].concat(options); + ].concat(options).concat(customArgs.otherFlags); } function parseBuildFlag (buildFlag, args) { diff --git a/tests/spec/unit/build.spec.js b/tests/spec/unit/build.spec.js index 4da1e8118..0c35ff915 100644 --- a/tests/spec/unit/build.spec.js +++ b/tests/spec/unit/build.spec.js @@ -288,6 +288,20 @@ describe('build', () => { expect(archiveArgs[13]).toEqual('00000000-0000-0000-0000-000000000000'); expect(archiveArgs.length).toEqual(14); }); + + it('should generate the appropriate arguments with build flag overrides', () => { + const buildFlags = '-archivePath TestArchivePathFlag'; + + const archiveArgs = getXcodeArchiveArgs(testProjectPath, '/test/output/path', '/test/export/options/path', { buildFlag: buildFlags }); + expect(archiveArgs[0]).toEqual('-exportArchive'); + expect(archiveArgs[1]).toEqual('-archivePath'); + expect(archiveArgs[2]).toEqual('TestArchivePathFlag'); + expect(archiveArgs[3]).toEqual('-exportOptionsPlist'); + expect(archiveArgs[4]).toEqual('/test/export/options/path'); + expect(archiveArgs[5]).toEqual('-exportPath'); + expect(archiveArgs[6]).toEqual('/test/output/path'); + expect(archiveArgs.length).toEqual(7); + }); }); describe('parseBuildFlag method', () => {