@@ -2,7 +2,6 @@ import * as path from "path";
2
2
import * as shell from "shelljs" ;
3
3
import * as os from "os" ;
4
4
import * as semver from "semver" ;
5
- import * as xcode from "xcode" ;
6
5
import * as constants from "../constants" ;
7
6
import * as helpers from "../common/helpers" ;
8
7
import { attachAwaitDetach } from "../common/helpers" ;
@@ -11,7 +10,6 @@ import { PlistSession } from "plist-merge-patch";
11
10
import { EOL } from "os" ;
12
11
import * as temp from "temp" ;
13
12
import * as plist from "plist" ;
14
- import { Xcode } from "pbxproj-dom/xcode" ;
15
13
import { IOSProvisionService } from "./ios-provision-service" ;
16
14
17
15
export class IOSProjectService extends projectServiceBaseLib . PlatformProjectServiceBase implements IPlatformProjectService {
@@ -42,7 +40,9 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
42
40
private $pluginVariablesService : IPluginVariablesService ,
43
41
private $xcprojService : IXcprojService ,
44
42
private $iOSProvisionService : IOSProvisionService ,
45
- private $sysInfo : ISysInfo ) {
43
+ private $sysInfo : ISysInfo ,
44
+ private $pbxprojDomXcode : IPbxprojDomXcode ,
45
+ private $xcode : IXcode ) {
46
46
super ( $fs , $projectDataService ) ;
47
47
}
48
48
@@ -379,10 +379,9 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
379
379
await this . createIpa ( projectRoot , projectData , buildConfig ) ;
380
380
}
381
381
382
- private async setupSigningFromProvision ( projectRoot : string , projectData : IProjectData , provision ?: any ) : Promise < void > {
382
+ private async setupSigningFromProvision ( projectRoot : string , projectData : IProjectData , provision ?: string ) : Promise < void > {
383
383
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 ) ) ;
386
385
const signing = xcode . getSigning ( projectData . projectName ) ;
387
386
388
387
let shouldUpdateXcode = false ;
@@ -399,8 +398,6 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
399
398
}
400
399
401
400
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.
404
401
const pickStart = Date . now ( ) ;
405
402
const mobileprovision = await this . $iOSProvisionService . pick ( provision , projectData . projectId ) ;
406
403
const pickEnd = Date . now ( ) ;
@@ -428,11 +425,16 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
428
425
}
429
426
430
427
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 ) ) ;
433
429
const signing = xcode . getSigning ( projectData . projectName ) ;
434
430
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" ) ) {
436
438
xcode . setManualSigningStyle ( projectData . projectName ) ;
437
439
xcode . save ( ) ;
438
440
} else if ( ! buildConfig . provision && ! ( signing && signing . style === "Manual" && ! buildConfig . teamId ) ) {
@@ -490,7 +492,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
490
492
let frameworkBinaryPath = path . join ( frameworkPath , frameworkName ) ;
491
493
let isDynamic = _ . includes ( ( await this . $childProcess . spawnFromEvent ( "otool" , [ "-Vh" , frameworkBinaryPath ] , "close" ) ) . stdout , " DYLIB " ) ;
492
494
493
- let frameworkAddOptions : xcode . Options = { customFramework : true } ;
495
+ let frameworkAddOptions : IXcode . Options = { customFramework : true } ;
494
496
495
497
if ( isDynamic ) {
496
498
frameworkAddOptions [ "embed" ] = true ;
@@ -623,7 +625,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
623
625
624
626
if ( provision ) {
625
627
let projectRoot = path . join ( projectData . platformsDir , "ios" ) ;
626
- await this . setupSigningFromProvision ( projectRoot , provision ) ;
628
+ await this . setupSigningFromProvision ( projectRoot , projectData , provision ) ;
627
629
}
628
630
629
631
let project = this . createPbxProj ( projectData ) ;
@@ -787,7 +789,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
787
789
}
788
790
789
791
private createPbxProj ( projectData : IProjectData ) : any {
790
- let project = new xcode . project ( this . getPbxProjPath ( projectData ) ) ;
792
+ let project = new this . $ xcode. project ( this . getPbxProjPath ( projectData ) ) ;
791
793
project . parseSync ( ) ;
792
794
793
795
return project ;
@@ -844,6 +846,35 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
844
846
return Promise . resolve ( ) ;
845
847
}
846
848
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
+
847
878
private getAllLibsForPluginWithFileExtension ( pluginData : IPluginData , fileExtension : string ) : string [ ] {
848
879
let filterCallback = ( fileName : string , pluginPlatformsFolderPath : string ) => path . extname ( fileName ) === fileExtension ;
849
880
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
1186
1217
return this . readXCConfig ( "PROVISIONING_PROFILE[sdk=iphoneos*]" , projectData ) ;
1187
1218
}
1188
1219
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
+
1189
1228
private async getDevelopmentTeam ( projectData : IProjectData , teamId ?: string ) : Promise < string > {
1190
1229
teamId = teamId || this . readTeamId ( projectData ) ;
1191
1230
0 commit comments