@@ -94,19 +94,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
94
94
this . $errors . fail ( "Xcode is not installed. Make sure you have Xcode installed and added to your PATH" ) ;
95
95
}
96
96
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 ( ) ;
110
98
if ( helpers . versionCompare ( xcodeBuildVersion , IOSProjectService . XCODEBUILD_MIN_VERSION ) < 0 ) {
111
99
this . $errors . fail ( "NativeScript can only run in Xcode version %s or greater" , IOSProjectService . XCODEBUILD_MIN_VERSION ) ;
112
100
}
@@ -290,6 +278,18 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
290
278
] ) ;
291
279
292
280
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
+ }
293
293
} else {
294
294
args = basicArgs . concat ( [
295
295
"-sdk" , "iphonesimulator" ,
@@ -1073,6 +1073,49 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
1073
1073
}
1074
1074
} ) . future < void > ( ) ( ) ;
1075
1075
}
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
+ }
1076
1119
}
1077
1120
1078
1121
$injector . register ( "iOSProjectService" , IOSProjectService ) ;
0 commit comments