Skip to content

Commit 3bf1eec

Browse files
committed
fix(xcode): fix getXcodeVersion() method
Currently `getXcodeVersion` always returns `{ major: null, minor: null, patch: null }`. This method uses internally `sysInfo.getXcodeVersion()`. On the other side, `sysInfo.getXcodeVersion()` returns the xocde's version in format `major.minor.patch` - for example `10.3.4`. After getting the result of `sysInfo.getXcodeVersion()`, NativeScript CLI matches the received output with `/Xcode (.*)/` regex. As the received output doesn't contain `Xcode`, the match returns null and as result `getXcodeVersion` method returns `{ major: null, minor: null, patch: null }`.
1 parent a9ed61f commit 3bf1eec

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

lib/common/services/xcode-select-service.ts

+3-9
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,9 @@ export class XcodeSelectService implements IXcodeSelectService {
3535
this.$errors.fail("xcodebuild execution failed. Make sure that you have latest Xcode and tools installed.");
3636
}
3737

38-
const xcodeVersionMatch = xcodeVer.match(/Xcode (.*)/),
39-
xcodeVersionGroup = xcodeVersionMatch && xcodeVersionMatch[1],
40-
xcodeVersionSplit = xcodeVersionGroup && xcodeVersionGroup.split(".");
41-
42-
return {
43-
major: xcodeVersionSplit && xcodeVersionSplit[0],
44-
minor: xcodeVersionSplit && xcodeVersionSplit[1],
45-
patch: xcodeVersionSplit && xcodeVersionSplit[2]
46-
};
38+
const [ major, minor, patch ] = xcodeVer.split(".");
39+
40+
return { major, minor, patch };
4741
}
4842
}
4943

lib/common/test/unit-tests/xcode-select-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe("xcode-select-service", () => {
5959
});
6060

6161
it("gets correct Xcode version", async () => {
62-
injector = createTestInjector({ xcodeSelectStdout: null, isDarwin: true, xcodeVersionOutput: "Xcode 7.3\nBuild version 7D175" });
62+
injector = createTestInjector({ xcodeSelectStdout: null, isDarwin: true, xcodeVersionOutput: "7.3" });
6363
service = injector.resolve("$xcodeSelectService");
6464

6565
const xcodeVersion = await service.getXcodeVersion();

0 commit comments

Comments
 (0)