Skip to content

Commit

Permalink
fix(build): Consistent handling of archivePath flags
Browse files Browse the repository at this point in the history
  • Loading branch information
dpogue committed Sep 25, 2024
1 parent cf61630 commit d6100b8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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) {
Expand Down
14 changes: 14 additions & 0 deletions tests/spec/unit/build.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit d6100b8

Please sign in to comment.