@@ -299,7 +299,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
299299
300300 let xcodeBuildVersion = await this . getXcodeVersion ( ) ;
301301 if ( helpers . versionCompare ( xcodeBuildVersion , "8.0" ) >= 0 ) {
302- await this . setupAutomaticSigning ( projectRoot , buildConfig ) ;
302+ await this . setupSigningForDevice ( projectRoot , buildConfig ) ;
303303 }
304304
305305 if ( buildConfig && buildConfig . codeSignIdentity ) {
@@ -321,7 +321,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
321321 await this . createIpa ( projectRoot ) ;
322322 }
323323
324- private async setupManualSigning ( projectRoot : string , buildConfig ?: IiOSBuildConfig ) : Promise < void > {
324+ private async setupSigningFromProvision ( projectRoot : string , buildConfig ?: IiOSBuildConfig ) : Promise < void > {
325325 if ( this . $options . provision ) {
326326 const pbxprojPath = path . join ( projectRoot , this . $projectData . projectName + ".xcodeproj" , "project.pbxproj" ) ;
327327 const xcode = Xcode . open ( pbxprojPath ) ;
@@ -369,12 +369,15 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
369369 }
370370 }
371371
372- private async setupAutomaticSigning ( projectRoot : string , buildConfig ?: IiOSBuildConfig ) : Promise < void > {
372+ private async setupSigningForDevice ( projectRoot : string , buildConfig ?: IiOSBuildConfig ) : Promise < void > {
373373 const pbxprojPath = path . join ( projectRoot , this . $projectData . projectName + ".xcodeproj" , "project.pbxproj" ) ;
374374 const xcode = Xcode . open ( pbxprojPath ) ;
375375 const signing = xcode . getSigning ( this . $projectData . projectName ) ;
376376
377- if ( ! this . $options . provision && ! ( signing && signing . style === "Manual" && ! this . $options . teamId ) ) {
377+ if ( ( this . readXCConfigProvisioningProfile ( ) || this . readXCConfigProvisioningProfileForIPhoneOs ( ) ) && ( ! signing || signing . style !== "Manual" ) ) {
378+ xcode . setManualSigningStyle ( this . $projectData . projectName ) ;
379+ xcode . save ( ) ;
380+ } else if ( ! this . $options . provision && ! ( signing && signing . style === "Manual" && ! this . $options . teamId ) ) {
378381 if ( buildConfig ) {
379382 delete buildConfig . teamIdentifier ;
380383 }
@@ -385,7 +388,6 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
385388 xcode . save ( ) ;
386389 this . $logger . trace ( "Set Automatic signing style and team." ) ;
387390 }
388-
389391 }
390392
391393 private async buildForSimulator ( projectRoot : string , args : string [ ] , buildConfig ?: IiOSBuildConfig ) : Promise < void > {
@@ -564,7 +566,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
564566 public async prepareProject ( ) : Promise < void > {
565567 if ( this . $options . provision ) {
566568 let projectRoot = path . join ( this . $projectData . platformsDir , "ios" ) ;
567- await this . setupManualSigning ( projectRoot ) ;
569+ await this . setupSigningFromProvision ( projectRoot ) ;
568570 }
569571
570572 let project = this . createPbxProj ( ) ;
@@ -1081,14 +1083,14 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
10811083 return null ;
10821084 }
10831085
1084- private readTeamId ( ) : string {
1086+ private readXCConfig ( flag : string ) : string {
10851087 let xcconfigFile = path . join ( this . $projectData . appResourcesDirectoryPath , this . platformData . normalizedPlatformName , "build.xcconfig" ) ;
10861088 if ( this . $fs . exists ( xcconfigFile ) ) {
10871089 let text = this . $fs . readText ( xcconfigFile ) ;
10881090 let teamId : string ;
10891091 text . split ( / \r ? \n / ) . forEach ( ( line ) => {
10901092 line = line . replace ( / \/ ( \/ ) [ ^ \n ] * $ / , "" ) ;
1091- if ( line . indexOf ( "DEVELOPMENT_TEAM" ) >= 0 ) {
1093+ if ( line . indexOf ( flag ) >= 0 ) {
10921094 teamId = line . split ( "=" ) [ 1 ] . trim ( ) ;
10931095 if ( teamId [ teamId . length - 1 ] === ';' ) {
10941096 teamId = teamId . slice ( 0 , - 1 ) ;
@@ -1108,6 +1110,18 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
11081110 return null ;
11091111 }
11101112
1113+ private readTeamId ( ) : string {
1114+ return this . readXCConfig ( "DEVELOPMENT_TEAM" ) ;
1115+ }
1116+
1117+ private readXCConfigProvisioningProfile ( ) : string {
1118+ return this . readXCConfig ( "PROVISIONING_PROFILE" ) ;
1119+ }
1120+
1121+ private readXCConfigProvisioningProfileForIPhoneOs ( ) : string {
1122+ return this . readXCConfig ( "PROVISIONING_PROFILE[sdk=iphoneos*]" ) ;
1123+ }
1124+
11111125 private async getDevelopmentTeam ( ) : Promise < string > {
11121126 let teamId : string ;
11131127 if ( this . $options . teamId ) {
0 commit comments