@@ -2,7 +2,6 @@ import * as path from "path";
22import * as shell from "shelljs" ;
33import * as os from "os" ;
44import * as semver from "semver" ;
5- import * as xcode from "xcode" ;
65import * as constants from "../constants" ;
76import * as helpers from "../common/helpers" ;
87import { attachAwaitDetach } from "../common/helpers" ;
@@ -11,7 +10,6 @@ import { PlistSession } from "plist-merge-patch";
1110import { EOL } from "os" ;
1211import * as temp from "temp" ;
1312import * as plist from "plist" ;
14- import { Xcode } from "pbxproj-dom/xcode" ;
1513import { IOSProvisionService } from "./ios-provision-service" ;
1614
1715export class IOSProjectService extends projectServiceBaseLib . PlatformProjectServiceBase implements IPlatformProjectService {
@@ -42,7 +40,9 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
4240 private $pluginVariablesService : IPluginVariablesService ,
4341 private $xcprojService : IXcprojService ,
4442 private $iOSProvisionService : IOSProvisionService ,
45- private $sysInfo : ISysInfo ) {
43+ private $sysInfo : ISysInfo ,
44+ private $pbxprojDomXcode : IPbxprojDomXcode ,
45+ private $xcode : IXcode ) {
4646 super ( $fs , $projectDataService ) ;
4747 }
4848
@@ -379,10 +379,9 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
379379 await this . createIpa ( projectRoot , projectData , buildConfig ) ;
380380 }
381381
382- private async setupSigningFromProvision ( projectRoot : string , projectData : IProjectData , provision ?: any ) : Promise < void > {
382+ private async setupSigningFromProvision ( projectRoot : string , projectData : IProjectData , provision ?: string ) : Promise < void > {
383383 if ( provision ) {
384- const pbxprojPath = path . join ( projectRoot , projectData . projectName + ".xcodeproj" , "project.pbxproj" ) ;
385- const xcode = Xcode . open ( pbxprojPath ) ;
384+ const xcode = this . $pbxprojDomXcode . Xcode . open ( this . getPbxProjPath ( projectData ) ) ;
386385 const signing = xcode . getSigning ( projectData . projectName ) ;
387386
388387 let shouldUpdateXcode = false ;
@@ -399,8 +398,6 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
399398 }
400399
401400 if ( shouldUpdateXcode ) {
402- // This is slow, it read through 260 mobileprovision files on my machine and does quite some checking whether provisioning profiles and devices will match.
403- // That's why we try to avoid id by checking in the Xcode first.
404401 const pickStart = Date . now ( ) ;
405402 const mobileprovision = await this . $iOSProvisionService . pick ( provision , projectData . projectId ) ;
406403 const pickEnd = Date . now ( ) ;
@@ -428,11 +425,16 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
428425 }
429426
430427 private async setupSigningForDevice ( projectRoot : string , buildConfig : IiOSBuildConfig , projectData : IProjectData ) : Promise < void > {
431- const pbxprojPath = path . join ( projectRoot , projectData . projectName + ".xcodeproj" , "project.pbxproj" ) ;
432- const xcode = Xcode . open ( pbxprojPath ) ;
428+ const xcode = this . $pbxprojDomXcode . Xcode . open ( this . getPbxProjPath ( projectData ) ) ;
433429 const signing = xcode . getSigning ( projectData . projectName ) ;
434430
435- if ( ( this . readXCConfigProvisioningProfile ( projectData ) || this . readXCConfigProvisioningProfileForIPhoneOs ( projectData ) ) && ( ! signing || signing . style !== "Manual" ) ) {
431+ const hasProvisioningProfileInXCConfig =
432+ this . readXCConfigProvisioningProfileSpecifierForIPhoneOs ( projectData ) ||
433+ this . readXCConfigProvisioningProfileSpecifier ( projectData ) ||
434+ this . readXCConfigProvisioningProfileForIPhoneOs ( projectData ) ||
435+ this . readXCConfigProvisioningProfile ( projectData ) ;
436+
437+ if ( hasProvisioningProfileInXCConfig && ( ! signing || signing . style !== "Manual" ) ) {
436438 xcode . setManualSigningStyle ( projectData . projectName ) ;
437439 xcode . save ( ) ;
438440 } else if ( ! buildConfig . provision && ! ( signing && signing . style === "Manual" && ! buildConfig . teamId ) ) {
@@ -490,7 +492,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
490492 let frameworkBinaryPath = path . join ( frameworkPath , frameworkName ) ;
491493 let isDynamic = _ . includes ( ( await this . $childProcess . spawnFromEvent ( "otool" , [ "-Vh" , frameworkBinaryPath ] , "close" ) ) . stdout , " DYLIB " ) ;
492494
493- let frameworkAddOptions : xcode . Options = { customFramework : true } ;
495+ let frameworkAddOptions : IXcode . Options = { customFramework : true } ;
494496
495497 if ( isDynamic ) {
496498 frameworkAddOptions [ "embed" ] = true ;
@@ -623,7 +625,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
623625
624626 if ( provision ) {
625627 let projectRoot = path . join ( projectData . platformsDir , "ios" ) ;
626- await this . setupSigningFromProvision ( projectRoot , provision ) ;
628+ await this . setupSigningFromProvision ( projectRoot , projectData , provision ) ;
627629 }
628630
629631 let project = this . createPbxProj ( projectData ) ;
@@ -787,7 +789,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
787789 }
788790
789791 private createPbxProj ( projectData : IProjectData ) : any {
790- let project = new xcode . project ( this . getPbxProjPath ( projectData ) ) ;
792+ let project = new this . $ xcode. project ( this . getPbxProjPath ( projectData ) ) ;
791793 project . parseSync ( ) ;
792794
793795 return project ;
@@ -844,6 +846,35 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
844846 return Promise . resolve ( ) ;
845847 }
846848
849+ public checkForChanges ( changesInfo : IProjectChangesInfo , options : IProjectChangesOptions , projectData : IProjectData ) : void {
850+ const provision = options . provision ;
851+ if ( provision !== undefined ) {
852+ // Check if the native project's signing is set to the provided provision...
853+ const pbxprojPath = this . getPbxProjPath ( projectData ) ;
854+
855+ if ( this . $fs . exists ( pbxprojPath ) ) {
856+ const xcode = this . $pbxprojDomXcode . Xcode . open ( pbxprojPath ) ;
857+ const signing = xcode . getSigning ( projectData . projectName ) ;
858+ if ( signing && signing . style === "Manual" ) {
859+ for ( let name in signing . configurations ) {
860+ let config = signing . configurations [ name ] ;
861+ if ( config . uuid !== provision && config . name !== provision ) {
862+ changesInfo . signingChanged = true ;
863+ break ;
864+ }
865+ }
866+ } else {
867+ // Specifying provisioning profile requires "Manual" signing style.
868+ // If the current signing style was not "Manual" it was probably "Automatic" or,
869+ // it was not uniform for the debug and release build configurations.
870+ changesInfo . signingChanged = true ;
871+ }
872+ } else {
873+ changesInfo . signingChanged = true ;
874+ }
875+ }
876+ }
877+
847878 private getAllLibsForPluginWithFileExtension ( pluginData : IPluginData , fileExtension : string ) : string [ ] {
848879 let filterCallback = ( fileName : string , pluginPlatformsFolderPath : string ) => path . extname ( fileName ) === fileExtension ;
849880 return this . getAllNativeLibrariesForPlugin ( pluginData , IOSProjectService . IOS_PLATFORM_NAME , filterCallback ) ;
@@ -1186,6 +1217,14 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
11861217 return this . readXCConfig ( "PROVISIONING_PROFILE[sdk=iphoneos*]" , projectData ) ;
11871218 }
11881219
1220+ private readXCConfigProvisioningProfileSpecifier ( projectData : IProjectData ) : string {
1221+ return this . readXCConfig ( "PROVISIONING_PROFILE_SPECIFIER" , projectData ) ;
1222+ }
1223+
1224+ private readXCConfigProvisioningProfileSpecifierForIPhoneOs ( projectData : IProjectData ) : string {
1225+ return this . readXCConfig ( "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" , projectData ) ;
1226+ }
1227+
11891228 private async getDevelopmentTeam ( projectData : IProjectData , teamId ?: string ) : Promise < string > {
11901229 teamId = teamId || this . readTeamId ( projectData ) ;
11911230
0 commit comments