Skip to content

Commit

Permalink
Merge pull request #398 from erisu/remove-xcconfig-flag
Browse files Browse the repository at this point in the history
Removal of xcconfig build flag
  • Loading branch information
dpogue authored Sep 6, 2018
2 parents ad96ef0 + 4dd0586 commit 004b830
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 130 deletions.
3 changes: 0 additions & 3 deletions bin/templates/scripts/cordova/lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ var projectName = null;
// These are regular expressions to detect if the user is changing any of the built-in xcodebuildArgs
/* eslint-disable no-useless-escape */
var buildFlagMatchers = {
'xcconfig': /^\-xcconfig\s*(.*)$/,
'workspace': /^\-workspace\s*(.*)/,
'scheme': /^\-scheme\s*(.*)/,
'configuration': /^\-configuration\s*(.*)/,
Expand Down Expand Up @@ -291,7 +290,6 @@ function getXcodeBuildArgs (projectName, projectPath, configuration, isDevice, b

if (isDevice) {
options = [
'-xcconfig', customArgs.xcconfig || path.join(__dirname, '..', 'build-' + configuration.toLowerCase() + '.xcconfig'),
'-workspace', customArgs.workspace || projectName + '.xcworkspace',
'-scheme', customArgs.scheme || projectName,
'-configuration', customArgs.configuration || configuration,
Expand All @@ -314,7 +312,6 @@ function getXcodeBuildArgs (projectName, projectPath, configuration, isDevice, b
}
} else { // emulator
options = [
'-xcconfig', customArgs.xcconfig || path.join(__dirname, '..', 'build-' + configuration.toLowerCase() + '.xcconfig'),
'-workspace', customArgs.project || projectName + '.xcworkspace',
'-scheme', customArgs.scheme || projectName,
'-configuration', customArgs.configuration || configuration,
Expand Down
245 changes: 118 additions & 127 deletions tests/spec/unit/build.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,31 @@ describe('build', function () {

it('should generate appropriate args if a single buildFlag is passed in', function (done) {
var isDevice = true;
var buildFlags = '-xcconfig TestXcconfigFlag';
var buildFlags = '';

var args = getXcodeBuildArgs('TestProjectName', testProjectPath, 'TestConfiguration', isDevice, buildFlags);
expect(args[0]).toEqual('-xcconfig');
expect(args[1]).toEqual('TestXcconfigFlag');
expect(args[2]).toEqual('-workspace');
expect(args[3]).toEqual('TestProjectName.xcworkspace');
expect(args[4]).toEqual('-scheme');
expect(args[5]).toEqual('TestProjectName');
expect(args[6]).toEqual('-configuration');
expect(args[7]).toEqual('TestConfiguration');
expect(args[8]).toEqual('-destination');
expect(args[9]).toEqual('generic/platform=iOS');
expect(args[10]).toEqual('-archivePath');
expect(args[11]).toEqual('TestProjectName.xcarchive');
expect(args[12]).toEqual('archive');
expect(args[13]).toEqual('CONFIGURATION_BUILD_DIR=' + path.join(testProjectPath, 'build', 'device'));
expect(args[14]).toEqual('SHARED_PRECOMPS_DIR=' + path.join(testProjectPath, 'build', 'sharedpch'));
expect(args.length).toEqual(15);
expect(args).toEqual([
'-workspace',
'TestProjectName.xcworkspace',
'-scheme',
'TestProjectName',
'-configuration',
'TestConfiguration',
'-destination',
'generic/platform=iOS',
'-archivePath',
'TestProjectName.xcarchive',
'archive',
'CONFIGURATION_BUILD_DIR=' + path.join(testProjectPath, 'build', 'device'),
'SHARED_PRECOMPS_DIR=' + path.join(testProjectPath, 'build', 'sharedpch')
]);
expect(args.length).toEqual(13);
done();
});

it('should generate appropriate args if buildFlags are passed in', function (done) {
var isDevice = true;
var buildFlags = [
'-xcconfig TestXcconfigFlag',
'-workspace TestWorkspaceFlag',
'-scheme TestSchemeFlag',
'-configuration TestConfigurationFlag',
Expand All @@ -67,66 +66,66 @@ describe('build', function () {
];

var args = getXcodeBuildArgs('TestProjectName', testProjectPath, 'TestConfiguration', isDevice, buildFlags);
expect(args[0]).toEqual('-xcconfig');
expect(args[1]).toEqual('TestXcconfigFlag');
expect(args[2]).toEqual('-workspace');
expect(args[3]).toEqual('TestWorkspaceFlag');
expect(args[4]).toEqual('-scheme');
expect(args[5]).toEqual('TestSchemeFlag');
expect(args[6]).toEqual('-configuration');
expect(args[7]).toEqual('TestConfigurationFlag');
expect(args[8]).toEqual('-destination');
expect(args[9]).toEqual('TestDestinationFlag');
expect(args[10]).toEqual('-archivePath');
expect(args[11]).toEqual('TestArchivePathFlag');
expect(args[12]).toEqual('archive');
expect(args[13]).toEqual('CONFIGURATION_BUILD_DIR=TestConfigBuildDirFlag');
expect(args[14]).toEqual('SHARED_PRECOMPS_DIR=TestSharedPrecompsDirFlag');
expect(args.length).toEqual(15);
expect(args).toEqual([
'-workspace',
'TestWorkspaceFlag',
'-scheme',
'TestSchemeFlag',
'-configuration',
'TestConfigurationFlag',
'-destination',
'TestDestinationFlag',
'-archivePath',
'TestArchivePathFlag',
'archive',
'CONFIGURATION_BUILD_DIR=TestConfigBuildDirFlag',
'SHARED_PRECOMPS_DIR=TestSharedPrecompsDirFlag'
]);
expect(args.length).toEqual(13);
done();
});

it('should generate appropriate args for device', function (done) {
var isDevice = true;
var args = getXcodeBuildArgs('TestProjectName', testProjectPath, 'TestConfiguration', isDevice, null);
expect(args[0]).toEqual('-xcconfig');
expect(args[1]).toEqual(path.join('/test', 'build-testconfiguration.xcconfig'));
expect(args[2]).toEqual('-workspace');
expect(args[3]).toEqual('TestProjectName.xcworkspace');
expect(args[4]).toEqual('-scheme');
expect(args[5]).toEqual('TestProjectName');
expect(args[6]).toEqual('-configuration');
expect(args[7]).toEqual('TestConfiguration');
expect(args[8]).toEqual('-destination');
expect(args[9]).toEqual('generic/platform=iOS');
expect(args[10]).toEqual('-archivePath');
expect(args[11]).toEqual('TestProjectName.xcarchive');
expect(args[12]).toEqual('archive');
expect(args[13]).toEqual('CONFIGURATION_BUILD_DIR=' + path.join(testProjectPath, 'build', 'device'));
expect(args[14]).toEqual('SHARED_PRECOMPS_DIR=' + path.join(testProjectPath, 'build', 'sharedpch'));
expect(args.length).toEqual(15);
expect(args).toEqual([
'-workspace',
'TestProjectName.xcworkspace',
'-scheme',
'TestProjectName',
'-configuration',
'TestConfiguration',
'-destination',
'generic/platform=iOS',
'-archivePath',
'TestProjectName.xcarchive',
'archive',
'CONFIGURATION_BUILD_DIR=' + path.join(testProjectPath, 'build', 'device'),
'SHARED_PRECOMPS_DIR=' + path.join(testProjectPath, 'build', 'sharedpch')
]);
expect(args.length).toEqual(13);
done();
});

it('should generate appropriate args for simulator', function (done) {
var isDevice = false;
var args = getXcodeBuildArgs('TestProjectName', testProjectPath, 'TestConfiguration', isDevice, null, 'iPhone 5s');
expect(args[0]).toEqual('-xcconfig');
expect(args[1]).toEqual(path.join('/test', 'build-testconfiguration.xcconfig'));
expect(args[2]).toEqual('-workspace');
expect(args[3]).toEqual('TestProjectName.xcworkspace');
expect(args[4]).toEqual('-scheme');
expect(args[5]).toEqual('TestProjectName');
expect(args[6]).toEqual('-configuration');
expect(args[7]).toEqual('TestConfiguration');
expect(args[8]).toEqual('-sdk');
expect(args[9]).toEqual('iphonesimulator');
expect(args[10]).toEqual('-destination');
expect(args[11]).toEqual('platform=iOS Simulator,name=iPhone 5s');
expect(args[12]).toEqual('build');
expect(args[13]).toEqual('CONFIGURATION_BUILD_DIR=' + path.join(testProjectPath, 'build', 'emulator'));
expect(args[14]).toEqual('SHARED_PRECOMPS_DIR=' + path.join(testProjectPath, 'build', 'sharedpch'));
expect(args.length).toEqual(15);
expect(args).toEqual([
'-workspace',
'TestProjectName.xcworkspace',
'-scheme',
'TestProjectName',
'-configuration',
'TestConfiguration',
'-sdk',
'iphonesimulator',
'-destination',
'platform=iOS Simulator,name=iPhone 5s',
'build',
'CONFIGURATION_BUILD_DIR=' + path.join(testProjectPath, 'build', 'emulator'),
'SHARED_PRECOMPS_DIR=' + path.join(testProjectPath, 'build', 'sharedpch')
]);
expect(args.length).toEqual(13);
done();
});

Expand All @@ -135,24 +134,24 @@ describe('build', function () {
var buildFlags = '-sdk TestSdkFlag';

var args = getXcodeBuildArgs('TestProjectName', testProjectPath, 'TestConfiguration', isDevice, buildFlags);
expect(args[0]).toEqual('-xcconfig');
expect(args[1]).toEqual(path.join('/test', 'build-testconfiguration.xcconfig'));
expect(args[2]).toEqual('-workspace');
expect(args[3]).toEqual('TestProjectName.xcworkspace');
expect(args[4]).toEqual('-scheme');
expect(args[5]).toEqual('TestProjectName');
expect(args[6]).toEqual('-configuration');
expect(args[7]).toEqual('TestConfiguration');
expect(args[8]).toEqual('-destination');
expect(args[9]).toEqual('generic/platform=iOS');
expect(args[10]).toEqual('-archivePath');
expect(args[11]).toEqual('TestProjectName.xcarchive');
expect(args[12]).toEqual('archive');
expect(args[13]).toEqual('CONFIGURATION_BUILD_DIR=' + path.join(testProjectPath, 'build', 'device'));
expect(args[14]).toEqual('SHARED_PRECOMPS_DIR=' + path.join(testProjectPath, 'build', 'sharedpch'));
expect(args[15]).toEqual('-sdk');
expect(args[16]).toEqual('TestSdkFlag');
expect(args.length).toEqual(17);
expect(args).toEqual([
'-workspace',
'TestProjectName.xcworkspace',
'-scheme',
'TestProjectName',
'-configuration',
'TestConfiguration',
'-destination',
'generic/platform=iOS',
'-archivePath',
'TestProjectName.xcarchive',
'archive',
'CONFIGURATION_BUILD_DIR=' + path.join(testProjectPath, 'build', 'device'),
'SHARED_PRECOMPS_DIR=' + path.join(testProjectPath, 'build', 'sharedpch'),
'-sdk',
'TestSdkFlag'
]);
expect(args.length).toEqual(15);
done();
});

Expand All @@ -161,47 +160,47 @@ describe('build', function () {
var buildFlags = '-archivePath TestArchivePathFlag';

var args = getXcodeBuildArgs('TestProjectName', testProjectPath, 'TestConfiguration', isDevice, buildFlags, 'iPhone 5s');
expect(args[0]).toEqual('-xcconfig');
expect(args[1]).toEqual(path.join('/test', 'build-testconfiguration.xcconfig'));
expect(args[2]).toEqual('-workspace');
expect(args[3]).toEqual('TestProjectName.xcworkspace');
expect(args[4]).toEqual('-scheme');
expect(args[5]).toEqual('TestProjectName');
expect(args[6]).toEqual('-configuration');
expect(args[7]).toEqual('TestConfiguration');
expect(args[8]).toEqual('-sdk');
expect(args[9]).toEqual('iphonesimulator');
expect(args[10]).toEqual('-destination');
expect(args[11]).toEqual('platform=iOS Simulator,name=iPhone 5s');
expect(args[12]).toEqual('build');
expect(args[13]).toEqual('CONFIGURATION_BUILD_DIR=' + path.join(testProjectPath, 'build', 'emulator'));
expect(args[14]).toEqual('SHARED_PRECOMPS_DIR=' + path.join(testProjectPath, 'build', 'sharedpch'));
expect(args[15]).toEqual('-archivePath');
expect(args[16]).toEqual('TestArchivePathFlag');
expect(args.length).toEqual(17);
expect(args).toEqual([
'-workspace',
'TestProjectName.xcworkspace',
'-scheme',
'TestProjectName',
'-configuration',
'TestConfiguration',
'-sdk',
'iphonesimulator',
'-destination',
'platform=iOS Simulator,name=iPhone 5s',
'build',
'CONFIGURATION_BUILD_DIR=' + path.join(testProjectPath, 'build', 'emulator'),
'SHARED_PRECOMPS_DIR=' + path.join(testProjectPath, 'build', 'sharedpch'),
'-archivePath',
'TestArchivePathFlag'
]);
expect(args.length).toEqual(15);
done();
});

it('should generate appropriate args for automatic provisioning', function (done) {
var isDevice = true;
var args = getXcodeBuildArgs('TestProjectName', testProjectPath, 'TestConfiguration', isDevice, null, null, true);
expect(args[0]).toEqual('-xcconfig');
expect(args[1]).toEqual(path.join('/test', 'build-testconfiguration.xcconfig'));
expect(args[2]).toEqual('-workspace');
expect(args[3]).toEqual('TestProjectName.xcworkspace');
expect(args[4]).toEqual('-scheme');
expect(args[5]).toEqual('TestProjectName');
expect(args[6]).toEqual('-configuration');
expect(args[7]).toEqual('TestConfiguration');
expect(args[8]).toEqual('-destination');
expect(args[9]).toEqual('generic/platform=iOS');
expect(args[10]).toEqual('-archivePath');
expect(args[11]).toEqual('TestProjectName.xcarchive');
expect(args[12]).toEqual('-allowProvisioningUpdates');
expect(args[13]).toEqual('archive');
expect(args[14]).toEqual('CONFIGURATION_BUILD_DIR=' + path.join(testProjectPath, 'build', 'device'));
expect(args[15]).toEqual('SHARED_PRECOMPS_DIR=' + path.join(testProjectPath, 'build', 'sharedpch'));
expect(args.length).toEqual(16);
expect(args).toEqual([
'-workspace',
'TestProjectName.xcworkspace',
'-scheme',
'TestProjectName',
'-configuration',
'TestConfiguration',
'-destination',
'generic/platform=iOS',
'-archivePath',
'TestProjectName.xcarchive',
'-allowProvisioningUpdates',
'archive',
'CONFIGURATION_BUILD_DIR=' + path.join(testProjectPath, 'build', 'device'),
'SHARED_PRECOMPS_DIR=' + path.join(testProjectPath, 'build', 'sharedpch')
]);
expect(args.length).toEqual(14);
done();
});
});
Expand Down Expand Up @@ -242,14 +241,6 @@ describe('build', function () {

var parseBuildFlag = build.__get__('parseBuildFlag');

it('should detect an xcconfig change', function (done) {
var buildFlag = '-xcconfig /path/to/config';
var args = { 'otherFlags': [] };
parseBuildFlag(buildFlag, args);
expect(args.xcconfig).toEqual('/path/to/config');
expect(args.otherFlags.length).toEqual(0);
done();
});
it('should detect a workspace change', function (done) {
var buildFlag = '-workspace MyTestWorkspace';
var args = { 'otherFlags': [] };
Expand Down

0 comments on commit 004b830

Please sign in to comment.