Skip to content

Commit 004b830

Browse files
authoredSep 6, 2018
Merge pull request #398 from erisu/remove-xcconfig-flag
Removal of xcconfig build flag
2 parents ad96ef0 + 4dd0586 commit 004b830

File tree

2 files changed

+118
-130
lines changed

2 files changed

+118
-130
lines changed
 

‎bin/templates/scripts/cordova/lib/build.js

-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ var projectName = null;
3636
// These are regular expressions to detect if the user is changing any of the built-in xcodebuildArgs
3737
/* eslint-disable no-useless-escape */
3838
var buildFlagMatchers = {
39-
'xcconfig': /^\-xcconfig\s*(.*)$/,
4039
'workspace': /^\-workspace\s*(.*)/,
4140
'scheme': /^\-scheme\s*(.*)/,
4241
'configuration': /^\-configuration\s*(.*)/,
@@ -291,7 +290,6 @@ function getXcodeBuildArgs (projectName, projectPath, configuration, isDevice, b
291290

292291
if (isDevice) {
293292
options = [
294-
'-xcconfig', customArgs.xcconfig || path.join(__dirname, '..', 'build-' + configuration.toLowerCase() + '.xcconfig'),
295293
'-workspace', customArgs.workspace || projectName + '.xcworkspace',
296294
'-scheme', customArgs.scheme || projectName,
297295
'-configuration', customArgs.configuration || configuration,
@@ -314,7 +312,6 @@ function getXcodeBuildArgs (projectName, projectPath, configuration, isDevice, b
314312
}
315313
} else { // emulator
316314
options = [
317-
'-xcconfig', customArgs.xcconfig || path.join(__dirname, '..', 'build-' + configuration.toLowerCase() + '.xcconfig'),
318315
'-workspace', customArgs.project || projectName + '.xcworkspace',
319316
'-scheme', customArgs.scheme || projectName,
320317
'-configuration', customArgs.configuration || configuration,

‎tests/spec/unit/build.spec.js

+118-127
Original file line numberDiff line numberDiff line change
@@ -31,32 +31,31 @@ describe('build', function () {
3131

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

3636
var args = getXcodeBuildArgs('TestProjectName', testProjectPath, 'TestConfiguration', isDevice, buildFlags);
37-
expect(args[0]).toEqual('-xcconfig');
38-
expect(args[1]).toEqual('TestXcconfigFlag');
39-
expect(args[2]).toEqual('-workspace');
40-
expect(args[3]).toEqual('TestProjectName.xcworkspace');
41-
expect(args[4]).toEqual('-scheme');
42-
expect(args[5]).toEqual('TestProjectName');
43-
expect(args[6]).toEqual('-configuration');
44-
expect(args[7]).toEqual('TestConfiguration');
45-
expect(args[8]).toEqual('-destination');
46-
expect(args[9]).toEqual('generic/platform=iOS');
47-
expect(args[10]).toEqual('-archivePath');
48-
expect(args[11]).toEqual('TestProjectName.xcarchive');
49-
expect(args[12]).toEqual('archive');
50-
expect(args[13]).toEqual('CONFIGURATION_BUILD_DIR=' + path.join(testProjectPath, 'build', 'device'));
51-
expect(args[14]).toEqual('SHARED_PRECOMPS_DIR=' + path.join(testProjectPath, 'build', 'sharedpch'));
52-
expect(args.length).toEqual(15);
37+
expect(args).toEqual([
38+
'-workspace',
39+
'TestProjectName.xcworkspace',
40+
'-scheme',
41+
'TestProjectName',
42+
'-configuration',
43+
'TestConfiguration',
44+
'-destination',
45+
'generic/platform=iOS',
46+
'-archivePath',
47+
'TestProjectName.xcarchive',
48+
'archive',
49+
'CONFIGURATION_BUILD_DIR=' + path.join(testProjectPath, 'build', 'device'),
50+
'SHARED_PRECOMPS_DIR=' + path.join(testProjectPath, 'build', 'sharedpch')
51+
]);
52+
expect(args.length).toEqual(13);
5353
done();
5454
});
5555

5656
it('should generate appropriate args if buildFlags are passed in', function (done) {
5757
var isDevice = true;
5858
var buildFlags = [
59-
'-xcconfig TestXcconfigFlag',
6059
'-workspace TestWorkspaceFlag',
6160
'-scheme TestSchemeFlag',
6261
'-configuration TestConfigurationFlag',
@@ -67,66 +66,66 @@ describe('build', function () {
6766
];
6867

6968
var args = getXcodeBuildArgs('TestProjectName', testProjectPath, 'TestConfiguration', isDevice, buildFlags);
70-
expect(args[0]).toEqual('-xcconfig');
71-
expect(args[1]).toEqual('TestXcconfigFlag');
72-
expect(args[2]).toEqual('-workspace');
73-
expect(args[3]).toEqual('TestWorkspaceFlag');
74-
expect(args[4]).toEqual('-scheme');
75-
expect(args[5]).toEqual('TestSchemeFlag');
76-
expect(args[6]).toEqual('-configuration');
77-
expect(args[7]).toEqual('TestConfigurationFlag');
78-
expect(args[8]).toEqual('-destination');
79-
expect(args[9]).toEqual('TestDestinationFlag');
80-
expect(args[10]).toEqual('-archivePath');
81-
expect(args[11]).toEqual('TestArchivePathFlag');
82-
expect(args[12]).toEqual('archive');
83-
expect(args[13]).toEqual('CONFIGURATION_BUILD_DIR=TestConfigBuildDirFlag');
84-
expect(args[14]).toEqual('SHARED_PRECOMPS_DIR=TestSharedPrecompsDirFlag');
85-
expect(args.length).toEqual(15);
69+
expect(args).toEqual([
70+
'-workspace',
71+
'TestWorkspaceFlag',
72+
'-scheme',
73+
'TestSchemeFlag',
74+
'-configuration',
75+
'TestConfigurationFlag',
76+
'-destination',
77+
'TestDestinationFlag',
78+
'-archivePath',
79+
'TestArchivePathFlag',
80+
'archive',
81+
'CONFIGURATION_BUILD_DIR=TestConfigBuildDirFlag',
82+
'SHARED_PRECOMPS_DIR=TestSharedPrecompsDirFlag'
83+
]);
84+
expect(args.length).toEqual(13);
8685
done();
8786
});
8887

8988
it('should generate appropriate args for device', function (done) {
9089
var isDevice = true;
9190
var args = getXcodeBuildArgs('TestProjectName', testProjectPath, 'TestConfiguration', isDevice, null);
92-
expect(args[0]).toEqual('-xcconfig');
93-
expect(args[1]).toEqual(path.join('/test', 'build-testconfiguration.xcconfig'));
94-
expect(args[2]).toEqual('-workspace');
95-
expect(args[3]).toEqual('TestProjectName.xcworkspace');
96-
expect(args[4]).toEqual('-scheme');
97-
expect(args[5]).toEqual('TestProjectName');
98-
expect(args[6]).toEqual('-configuration');
99-
expect(args[7]).toEqual('TestConfiguration');
100-
expect(args[8]).toEqual('-destination');
101-
expect(args[9]).toEqual('generic/platform=iOS');
102-
expect(args[10]).toEqual('-archivePath');
103-
expect(args[11]).toEqual('TestProjectName.xcarchive');
104-
expect(args[12]).toEqual('archive');
105-
expect(args[13]).toEqual('CONFIGURATION_BUILD_DIR=' + path.join(testProjectPath, 'build', 'device'));
106-
expect(args[14]).toEqual('SHARED_PRECOMPS_DIR=' + path.join(testProjectPath, 'build', 'sharedpch'));
107-
expect(args.length).toEqual(15);
91+
expect(args).toEqual([
92+
'-workspace',
93+
'TestProjectName.xcworkspace',
94+
'-scheme',
95+
'TestProjectName',
96+
'-configuration',
97+
'TestConfiguration',
98+
'-destination',
99+
'generic/platform=iOS',
100+
'-archivePath',
101+
'TestProjectName.xcarchive',
102+
'archive',
103+
'CONFIGURATION_BUILD_DIR=' + path.join(testProjectPath, 'build', 'device'),
104+
'SHARED_PRECOMPS_DIR=' + path.join(testProjectPath, 'build', 'sharedpch')
105+
]);
106+
expect(args.length).toEqual(13);
108107
done();
109108
});
110109

111110
it('should generate appropriate args for simulator', function (done) {
112111
var isDevice = false;
113112
var args = getXcodeBuildArgs('TestProjectName', testProjectPath, 'TestConfiguration', isDevice, null, 'iPhone 5s');
114-
expect(args[0]).toEqual('-xcconfig');
115-
expect(args[1]).toEqual(path.join('/test', 'build-testconfiguration.xcconfig'));
116-
expect(args[2]).toEqual('-workspace');
117-
expect(args[3]).toEqual('TestProjectName.xcworkspace');
118-
expect(args[4]).toEqual('-scheme');
119-
expect(args[5]).toEqual('TestProjectName');
120-
expect(args[6]).toEqual('-configuration');
121-
expect(args[7]).toEqual('TestConfiguration');
122-
expect(args[8]).toEqual('-sdk');
123-
expect(args[9]).toEqual('iphonesimulator');
124-
expect(args[10]).toEqual('-destination');
125-
expect(args[11]).toEqual('platform=iOS Simulator,name=iPhone 5s');
126-
expect(args[12]).toEqual('build');
127-
expect(args[13]).toEqual('CONFIGURATION_BUILD_DIR=' + path.join(testProjectPath, 'build', 'emulator'));
128-
expect(args[14]).toEqual('SHARED_PRECOMPS_DIR=' + path.join(testProjectPath, 'build', 'sharedpch'));
129-
expect(args.length).toEqual(15);
113+
expect(args).toEqual([
114+
'-workspace',
115+
'TestProjectName.xcworkspace',
116+
'-scheme',
117+
'TestProjectName',
118+
'-configuration',
119+
'TestConfiguration',
120+
'-sdk',
121+
'iphonesimulator',
122+
'-destination',
123+
'platform=iOS Simulator,name=iPhone 5s',
124+
'build',
125+
'CONFIGURATION_BUILD_DIR=' + path.join(testProjectPath, 'build', 'emulator'),
126+
'SHARED_PRECOMPS_DIR=' + path.join(testProjectPath, 'build', 'sharedpch')
127+
]);
128+
expect(args.length).toEqual(13);
130129
done();
131130
});
132131

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

137136
var args = getXcodeBuildArgs('TestProjectName', testProjectPath, 'TestConfiguration', isDevice, buildFlags);
138-
expect(args[0]).toEqual('-xcconfig');
139-
expect(args[1]).toEqual(path.join('/test', 'build-testconfiguration.xcconfig'));
140-
expect(args[2]).toEqual('-workspace');
141-
expect(args[3]).toEqual('TestProjectName.xcworkspace');
142-
expect(args[4]).toEqual('-scheme');
143-
expect(args[5]).toEqual('TestProjectName');
144-
expect(args[6]).toEqual('-configuration');
145-
expect(args[7]).toEqual('TestConfiguration');
146-
expect(args[8]).toEqual('-destination');
147-
expect(args[9]).toEqual('generic/platform=iOS');
148-
expect(args[10]).toEqual('-archivePath');
149-
expect(args[11]).toEqual('TestProjectName.xcarchive');
150-
expect(args[12]).toEqual('archive');
151-
expect(args[13]).toEqual('CONFIGURATION_BUILD_DIR=' + path.join(testProjectPath, 'build', 'device'));
152-
expect(args[14]).toEqual('SHARED_PRECOMPS_DIR=' + path.join(testProjectPath, 'build', 'sharedpch'));
153-
expect(args[15]).toEqual('-sdk');
154-
expect(args[16]).toEqual('TestSdkFlag');
155-
expect(args.length).toEqual(17);
137+
expect(args).toEqual([
138+
'-workspace',
139+
'TestProjectName.xcworkspace',
140+
'-scheme',
141+
'TestProjectName',
142+
'-configuration',
143+
'TestConfiguration',
144+
'-destination',
145+
'generic/platform=iOS',
146+
'-archivePath',
147+
'TestProjectName.xcarchive',
148+
'archive',
149+
'CONFIGURATION_BUILD_DIR=' + path.join(testProjectPath, 'build', 'device'),
150+
'SHARED_PRECOMPS_DIR=' + path.join(testProjectPath, 'build', 'sharedpch'),
151+
'-sdk',
152+
'TestSdkFlag'
153+
]);
154+
expect(args.length).toEqual(15);
156155
done();
157156
});
158157

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

163162
var args = getXcodeBuildArgs('TestProjectName', testProjectPath, 'TestConfiguration', isDevice, buildFlags, 'iPhone 5s');
164-
expect(args[0]).toEqual('-xcconfig');
165-
expect(args[1]).toEqual(path.join('/test', 'build-testconfiguration.xcconfig'));
166-
expect(args[2]).toEqual('-workspace');
167-
expect(args[3]).toEqual('TestProjectName.xcworkspace');
168-
expect(args[4]).toEqual('-scheme');
169-
expect(args[5]).toEqual('TestProjectName');
170-
expect(args[6]).toEqual('-configuration');
171-
expect(args[7]).toEqual('TestConfiguration');
172-
expect(args[8]).toEqual('-sdk');
173-
expect(args[9]).toEqual('iphonesimulator');
174-
expect(args[10]).toEqual('-destination');
175-
expect(args[11]).toEqual('platform=iOS Simulator,name=iPhone 5s');
176-
expect(args[12]).toEqual('build');
177-
expect(args[13]).toEqual('CONFIGURATION_BUILD_DIR=' + path.join(testProjectPath, 'build', 'emulator'));
178-
expect(args[14]).toEqual('SHARED_PRECOMPS_DIR=' + path.join(testProjectPath, 'build', 'sharedpch'));
179-
expect(args[15]).toEqual('-archivePath');
180-
expect(args[16]).toEqual('TestArchivePathFlag');
181-
expect(args.length).toEqual(17);
163+
expect(args).toEqual([
164+
'-workspace',
165+
'TestProjectName.xcworkspace',
166+
'-scheme',
167+
'TestProjectName',
168+
'-configuration',
169+
'TestConfiguration',
170+
'-sdk',
171+
'iphonesimulator',
172+
'-destination',
173+
'platform=iOS Simulator,name=iPhone 5s',
174+
'build',
175+
'CONFIGURATION_BUILD_DIR=' + path.join(testProjectPath, 'build', 'emulator'),
176+
'SHARED_PRECOMPS_DIR=' + path.join(testProjectPath, 'build', 'sharedpch'),
177+
'-archivePath',
178+
'TestArchivePathFlag'
179+
]);
180+
expect(args.length).toEqual(15);
182181
done();
183182
});
184183

185184
it('should generate appropriate args for automatic provisioning', function (done) {
186185
var isDevice = true;
187186
var args = getXcodeBuildArgs('TestProjectName', testProjectPath, 'TestConfiguration', isDevice, null, null, true);
188-
expect(args[0]).toEqual('-xcconfig');
189-
expect(args[1]).toEqual(path.join('/test', 'build-testconfiguration.xcconfig'));
190-
expect(args[2]).toEqual('-workspace');
191-
expect(args[3]).toEqual('TestProjectName.xcworkspace');
192-
expect(args[4]).toEqual('-scheme');
193-
expect(args[5]).toEqual('TestProjectName');
194-
expect(args[6]).toEqual('-configuration');
195-
expect(args[7]).toEqual('TestConfiguration');
196-
expect(args[8]).toEqual('-destination');
197-
expect(args[9]).toEqual('generic/platform=iOS');
198-
expect(args[10]).toEqual('-archivePath');
199-
expect(args[11]).toEqual('TestProjectName.xcarchive');
200-
expect(args[12]).toEqual('-allowProvisioningUpdates');
201-
expect(args[13]).toEqual('archive');
202-
expect(args[14]).toEqual('CONFIGURATION_BUILD_DIR=' + path.join(testProjectPath, 'build', 'device'));
203-
expect(args[15]).toEqual('SHARED_PRECOMPS_DIR=' + path.join(testProjectPath, 'build', 'sharedpch'));
204-
expect(args.length).toEqual(16);
187+
expect(args).toEqual([
188+
'-workspace',
189+
'TestProjectName.xcworkspace',
190+
'-scheme',
191+
'TestProjectName',
192+
'-configuration',
193+
'TestConfiguration',
194+
'-destination',
195+
'generic/platform=iOS',
196+
'-archivePath',
197+
'TestProjectName.xcarchive',
198+
'-allowProvisioningUpdates',
199+
'archive',
200+
'CONFIGURATION_BUILD_DIR=' + path.join(testProjectPath, 'build', 'device'),
201+
'SHARED_PRECOMPS_DIR=' + path.join(testProjectPath, 'build', 'sharedpch')
202+
]);
203+
expect(args.length).toEqual(14);
205204
done();
206205
});
207206
});
@@ -242,14 +241,6 @@ describe('build', function () {
242241

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

245-
it('should detect an xcconfig change', function (done) {
246-
var buildFlag = '-xcconfig /path/to/config';
247-
var args = { 'otherFlags': [] };
248-
parseBuildFlag(buildFlag, args);
249-
expect(args.xcconfig).toEqual('/path/to/config');
250-
expect(args.otherFlags.length).toEqual(0);
251-
done();
252-
});
253244
it('should detect a workspace change', function (done) {
254245
var buildFlag = '-workspace MyTestWorkspace';
255246
var args = { 'otherFlags': [] };

0 commit comments

Comments
 (0)