Skip to content

Commit 056c063

Browse files
author
Tsvetan Raikov
committed
Added teamid option for run,debug and livesync commands
1 parent 3aa3f2b commit 056c063

File tree

1 file changed

+56
-13
lines changed

1 file changed

+56
-13
lines changed

lib/services/ios-project-service.ts

+56-13
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
9494
this.$errors.fail("Xcode is not installed. Make sure you have Xcode installed and added to your PATH");
9595
}
9696

97-
let xcodeBuildVersion = "";
98-
99-
try {
100-
xcodeBuildVersion = this.$childProcess.exec("xcodebuild -version | head -n 1 | sed -e 's/Xcode //'").wait();
101-
} catch (error) {
102-
this.$errors.fail("xcodebuild execution failed. Make sure that you have latest Xcode and tools installed.");
103-
}
104-
105-
let splitedXcodeBuildVersion = xcodeBuildVersion.split(".");
106-
if (splitedXcodeBuildVersion.length === 3) {
107-
xcodeBuildVersion = `${splitedXcodeBuildVersion[0]}.${splitedXcodeBuildVersion[1]}`;
108-
}
109-
97+
let xcodeBuildVersion = this.getXcodeVersion();
11098
if (helpers.versionCompare(xcodeBuildVersion, IOSProjectService.XCODEBUILD_MIN_VERSION) < 0) {
11199
this.$errors.fail("NativeScript can only run in Xcode version %s or greater", IOSProjectService.XCODEBUILD_MIN_VERSION);
112100
}
@@ -290,6 +278,18 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
290278
]);
291279

292280
args = args.concat((buildConfig && buildConfig.architectures) || defaultArchitectures);
281+
282+
let xcodeBuildVersion = this.getXcodeVersion();
283+
if (helpers.versionCompare(xcodeBuildVersion, "8.0")>=0) {
284+
if (this.$options.teamId) {
285+
args = args.concat("DEVELOPMENT_TEAM="+this.$options.teamId);
286+
} else {
287+
let teamIds = this.parseTeamIds();
288+
if (teamIds.length > 0) {
289+
args = args.concat("DEVELOPMENT_TEAM="+teamIds[0]);
290+
}
291+
}
292+
}
293293
} else {
294294
args = basicArgs.concat([
295295
"-sdk", "iphonesimulator",
@@ -1073,6 +1073,49 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
10731073
}
10741074
}).future<void>()();
10751075
}
1076+
1077+
private getXcodeVersion(): string {
1078+
let xcodeBuildVersion = "";
1079+
1080+
try {
1081+
xcodeBuildVersion = this.$childProcess.exec("xcodebuild -version | head -n 1 | sed -e 's/Xcode //'").wait();
1082+
} catch (error) {
1083+
this.$errors.fail("xcodebuild execution failed. Make sure that you have latest Xcode and tools installed.");
1084+
}
1085+
1086+
let splitedXcodeBuildVersion = xcodeBuildVersion.split(".");
1087+
if (splitedXcodeBuildVersion.length === 3) {
1088+
xcodeBuildVersion = `${splitedXcodeBuildVersion[0]}.${splitedXcodeBuildVersion[1]}`;
1089+
}
1090+
1091+
return xcodeBuildVersion;
1092+
}
1093+
1094+
private parseTeamIds(): Array<string> {
1095+
let dir = "/Users/raikov/Library/MobileDevice/Provisioning Profiles/";
1096+
let files = this.$fs.readDirectory(dir).wait();
1097+
let teamIds: any = {};
1098+
for (let file of files) {
1099+
let filePath = path.join(dir, file);
1100+
let data = this.$fs.readText(filePath, "utf8").wait();
1101+
let id = "TeamIdentifier";
1102+
let index = data.indexOf(id);
1103+
if (index > 0) {
1104+
index = data.indexOf("<string>", index+id.length);
1105+
if (index > 0) {
1106+
index += "<string>".length;
1107+
let endIndex = data.indexOf("</string>", index);
1108+
let teamId = data.substring(index, endIndex);
1109+
teamIds[teamId] = teamId;
1110+
}
1111+
}
1112+
}
1113+
let teamIdsArray = new Array<string>();
1114+
for (let teamId in teamIds) {
1115+
teamIdsArray.push(teamId);
1116+
}
1117+
return teamIdsArray;
1118+
}
10761119
}
10771120

10781121
$injector.register("iOSProjectService", IOSProjectService);

0 commit comments

Comments
 (0)