Skip to content

Commit e3926c7

Browse files
committed
Fix bug in xcode task when project argument is specified and workspace is not used
1 parent 3b3ec02 commit e3926c7

File tree

6 files changed

+89
-4
lines changed

6 files changed

+89
-4
lines changed

Tasks/Xcode/task.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"version": {
1313
"Major": 2,
1414
"Minor": 1,
15-
"Patch": 21
15+
"Patch": 22
1616
},
1717
"demands": [
1818
"xcode"

Tasks/Xcode/task.loc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"version": {
1313
"Major": 2,
1414
"Minor": 1,
15-
"Patch": 21
15+
"Patch": 22
1616
},
1717
"demands": [
1818
"xcode"

Tasks/Xcode/xcode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ async function run() {
7171
var xcb: ToolRunner = tl.createToolRunner(tool);
7272
xcb.argIf(sdk, ['-sdk', sdk]);
7373
xcb.argIf(configuration, ['-configuration', configuration]);
74-
if(ws) {
74+
if(ws && tl.filePathSupplied('xcWorkspacePath')) {
7575
xcb.arg('-workspace');
7676
xcb.pathArg(ws);
7777
}

Tests/L0/Xcode/_suite.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,58 @@ describe('Xcode Suite', function() {
127127
})
128128
})
129129

130+
it('run Xcode with project and no workspace', (done) => {
131+
setResponseFile('responseProject.json');
132+
133+
var tr = new trm.TaskRunner('Xcode', true, true);
134+
tr.setInput('actions', 'build');
135+
tr.setInput('configuration', '$(Configuration)');
136+
tr.setInput('sdk', '$(SDK)');
137+
tr.setInput('xcWorkspacePath', '/user/build');
138+
tr.setInput('scheme', '');
139+
tr.setInput('packageApp', 'true');
140+
tr.setInput('signMethod', 'file');
141+
tr.setInput('p12', '/user/build');
142+
tr.setInput('p12pwd', '');
143+
tr.setInput('provProfile', '/user/build');
144+
tr.setInput('removeProfile', 'false');
145+
tr.setInput('unlockDefaultKeychain', 'false');
146+
tr.setInput('defaultKeychainPassword', '');
147+
tr.setInput('iosSigningIdentity', '');
148+
tr.setInput('provProfileUuid', '');
149+
tr.setInput('args', '-project test.xcodeproj');
150+
tr.setInput('cwd', '/user/build');
151+
tr.setInput('outputPattern', 'output/$(SDK)/$(Configuration)');
152+
tr.setInput('xcodeDeveloperDir', '');
153+
tr.setInput('useXctool', 'false');
154+
tr.setInput('xctoolReporter', '');
155+
tr.setInput('publishJUnitResults', 'false');
156+
157+
tr.run()
158+
.then(() => {
159+
assert(tr.ran('/home/bin/xcodebuild -version'), 'xcodebuild for version should have been run.');
160+
assert(tr.ran('/home/bin/xcodebuild -sdk $(SDK) -configuration $(Configuration) ' +
161+
'build DSTROOT=/user/build/output/$(SDK)/$(Configuration)/build.dst ' +
162+
'OBJROOT=/user/build/output/$(SDK)/$(Configuration)/build.obj ' +
163+
'SYMROOT=/user/build/output/$(SDK)/$(Configuration)/build.sym ' +
164+
'SHARED_PRECOMPS_DIR=/user/build/output/$(SDK)/$(Configuration)/build.pch ' +
165+
'-project test.xcodeproj'),
166+
'xcodebuild for building the ios project should have been run.');
167+
assert(tr.ran('/home/bin/xcrun -sdk $(SDK) PackageApplication ' +
168+
'-v /user/build/output/$(SDK)/$(Configuration)/build.sym/Release.iphoneos/fun.app ' +
169+
'-o /user/build/output/$(SDK)/$(Configuration)/build.sym/Release.iphoneos/fun.ipa'),
170+
"xcrun to package the app and generate an .ipa should have been run.");
171+
assert(tr.invokedToolCount == 3, 'should have xcodebuild for version, xcodebuild for build and xcrun for packaging');
172+
assert(tr.resultWasSet, 'task should have set a result');
173+
assert(tr.stderr.length == 0, 'should not have written to stderr');
174+
assert(tr.succeeded, 'task should have succeeded');
175+
done();
176+
})
177+
.fail((err) => {
178+
done(err);
179+
})
180+
})
181+
130182
it('run Xcode build with test action, publish test results', (done) => {
131183
setResponseFile('responseXctool.json');
132184

Tests/L0/Xcode/responseErrorArgs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"code": 0,
2020
"stdout": "Xcode 7.3.1"
2121
},
22-
"/home/bin/xcodebuild -workspace /user/build build DSTROOT=/user/build/output/$(SDK)/$(Configuration)/build.dst OBJROOT=/user/build/output/$(SDK)/$(Configuration)/build.obj SYMROOT=/user/build/output/$(SDK)/$(Configuration)/build.sym SHARED_PRECOMPS_DIR=/user/build/output/$(SDK)/$(Configuration)/build.pch" : {
22+
"/home/bin/xcodebuild build DSTROOT=/user/build/output/$(SDK)/$(Configuration)/build.dst OBJROOT=/user/build/output/$(SDK)/$(Configuration)/build.obj SYMROOT=/user/build/output/$(SDK)/$(Configuration)/build.sym SHARED_PRECOMPS_DIR=/user/build/output/$(SDK)/$(Configuration)/build.pch": {
2323
"code": 0,
2424
"stdout": "xcodebuild output here"
2525
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"which": {
3+
"xcodebuild": "/home/bin/xcodebuild",
4+
"xcrun": "/home/bin/xcrun"
5+
},
6+
"checkPath" : {
7+
"/home/bin/xcodebuild": true,
8+
"/home/bin/xcrun": true
9+
},
10+
"getVariable": {
11+
"build.sourcesDirectory": "/user/build",
12+
"HOME": "/users/test"
13+
},
14+
"glob": {
15+
"/user/build/output/$(SDK)/$(Configuration)/build.sym/**/*.app": [
16+
"/user/build/output/$(SDK)/$(Configuration)/build.sym/Release.iphoneos/fun.app"
17+
]
18+
},
19+
"exec": {
20+
"/home/bin/xcodebuild -version": {
21+
"code": 0,
22+
"stdout": "Xcode 7.3.1"
23+
},
24+
"/home/bin/xcodebuild -sdk $(SDK) -configuration $(Configuration) build DSTROOT=/user/build/output/$(SDK)/$(Configuration)/build.dst OBJROOT=/user/build/output/$(SDK)/$(Configuration)/build.obj SYMROOT=/user/build/output/$(SDK)/$(Configuration)/build.sym SHARED_PRECOMPS_DIR=/user/build/output/$(SDK)/$(Configuration)/build.pch -project test.xcodeproj": {
25+
"code": 0,
26+
"stdout": "xcodebuild output here"
27+
},
28+
"/home/bin/xcrun -sdk $(SDK) PackageApplication -v /user/build/output/$(SDK)/$(Configuration)/build.sym/Release.iphoneos/fun.app -o /user/build/output/$(SDK)/$(Configuration)/build.sym/Release.iphoneos/fun.ipa": {
29+
"code": 0,
30+
"stdout": "xcrun output here"
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)