Skip to content

Commit 52c0a4a

Browse files
committed
Fix some issues about the provision switch
1 parent 99c9bf5 commit 52c0a4a

File tree

5 files changed

+70
-18
lines changed

5 files changed

+70
-18
lines changed

lib/definitions/project.d.ts

+6
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,12 @@ interface IPlatformProjectService extends NodeJS.EventEmitter {
258258
* @returns {void}
259259
*/
260260
cleanProject(projectRoot: string, projectData: IProjectData): Promise<void>
261+
262+
/**
263+
* Check the current state of the project, and validate against the options.
264+
* If there are parts in the project that are inconsistent with the desired options, marks them in the changeset flags.
265+
*/
266+
checkForChanges(changeset: IProjectChangesInfo, options: IProjectChangesOptions, projectData: IProjectData): void;
261267
}
262268

263269
interface IAndroidProjectPropertiesManager {

lib/services/android-project-service.ts

+4
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,10 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
430430
await adb.executeShellCommand(["rm", "-rf", deviceRootPath]);
431431
}
432432

433+
public checkForChanges(changesInfo: IProjectChangesInfo, options: IProjectChangesOptions, projectData: IProjectData): void {
434+
// Nothing android specific to check yet.
435+
}
436+
433437
private _canUseGradle: boolean;
434438
private canUseGradle(projectData: IProjectData, frameworkVersion?: string): boolean {
435439
if (!this._canUseGradle) {

lib/services/ios-project-service.ts

+55-7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import * as temp from "temp";
1212
import * as plist from "plist";
1313
import { Xcode } from "pbxproj-dom/xcode";
1414
import { IOSProvisionService } from "./ios-provision-service";
15+
import * as fs from "fs";
1516

1617
export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServiceBase implements IPlatformProjectService {
1718
private static XCODE_PROJECT_EXT_NAME = ".xcodeproj";
@@ -372,10 +373,9 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
372373
await this.createIpa(projectRoot, projectData, buildConfig);
373374
}
374375

375-
private async setupSigningFromProvision(projectRoot: string, projectData: IProjectData, provision?: any): Promise<void> {
376+
private async setupSigningFromProvision(projectRoot: string, projectData: IProjectData, provision?: string): Promise<void> {
376377
if (provision) {
377-
const pbxprojPath = path.join(projectRoot, projectData.projectName + ".xcodeproj", "project.pbxproj");
378-
const xcode = Xcode.open(pbxprojPath);
378+
const xcode = Xcode.open(this.getPbxProjPath(projectData));
379379
const signing = xcode.getSigning(projectData.projectName);
380380

381381
let shouldUpdateXcode = false;
@@ -421,11 +421,16 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
421421
}
422422

423423
private async setupSigningForDevice(projectRoot: string, buildConfig: IiOSBuildConfig, projectData: IProjectData): Promise<void> {
424-
const pbxprojPath = path.join(projectRoot, projectData.projectName + ".xcodeproj", "project.pbxproj");
425-
const xcode = Xcode.open(pbxprojPath);
424+
const xcode = Xcode.open(this.getPbxProjPath(projectData));
426425
const signing = xcode.getSigning(projectData.projectName);
427426

428-
if ((this.readXCConfigProvisioningProfile(projectData) || this.readXCConfigProvisioningProfileForIPhoneOs(projectData)) && (!signing || signing.style !== "Manual")) {
427+
const hasProvisioningProfileInXCConfig =
428+
this.readXCConfigProvisioningProfile(projectData) ||
429+
this.readXCConfigProvisioningProfileForIPhoneOs(projectData) ||
430+
this.readXCConfigProvisioningProfileSpecifier(projectData) ||
431+
this.readXCConfigProvisioningProfileSpecifierForIPhoneOs(projectData);
432+
433+
if (hasProvisioningProfileInXCConfig && (!signing || signing.style !== "Manual")) {
429434
xcode.setManualSigningStyle(projectData.projectName);
430435
xcode.save();
431436
} else if (!buildConfig.provision && !(signing && signing.style === "Manual" && !buildConfig.teamId)) {
@@ -616,7 +621,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
616621

617622
if (provision) {
618623
let projectRoot = path.join(projectData.platformsDir, "ios");
619-
await this.setupSigningFromProvision(projectRoot, provision);
624+
await this.setupSigningFromProvision(projectRoot, projectData, provision);
620625
}
621626

622627
let project = this.createPbxProj(projectData);
@@ -837,6 +842,41 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
837842
return Promise.resolve();
838843
}
839844

845+
public checkForChanges(changesInfo: IProjectChangesInfo, options: IProjectChangesOptions, projectData: IProjectData): void {
846+
const nextCommandProvisionUUID = options.provision;
847+
848+
if (typeof nextCommandProvisionUUID === "string") {
849+
const pbxprojPath = this.getPbxProjPath(projectData);
850+
851+
// Check if the native project's signing is set to the provided provision...
852+
let signingChanged = false;
853+
if (!fs.existsSync(pbxprojPath)) {
854+
const xcode = Xcode.open(pbxprojPath);
855+
const signing = xcode.getSigning(projectData.projectName);
856+
if (signing.style === "Manual") {
857+
for (let name in signing.configurations) {
858+
let config = signing.configurations[name];
859+
if (config.uuid !== nextCommandProvisionUUID && config.name !== nextCommandProvisionUUID) {
860+
signingChanged = true;
861+
break;
862+
}
863+
}
864+
} else {
865+
signingChanged = true;
866+
}
867+
} else {
868+
signingChanged = true;
869+
}
870+
871+
if (signingChanged) {
872+
changesInfo.nativeChanged = true;
873+
changesInfo.configChanged = true;
874+
// TRICKY: The native project is prepared only if appResourcesChanged.
875+
changesInfo.appResourcesChanged = true;
876+
}
877+
}
878+
}
879+
840880
private getAllLibsForPluginWithFileExtension(pluginData: IPluginData, fileExtension: string): string[] {
841881
let filterCallback = (fileName: string, pluginPlatformsFolderPath: string) => path.extname(fileName) === fileExtension;
842882
return this.getAllNativeLibrariesForPlugin(pluginData, IOSProjectService.IOS_PLATFORM_NAME, filterCallback);
@@ -1179,6 +1219,14 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
11791219
return this.readXCConfig("PROVISIONING_PROFILE[sdk=iphoneos*]", projectData);
11801220
}
11811221

1222+
private readXCConfigProvisioningProfileSpecifier(projectData: IProjectData): string {
1223+
return this.readXCConfig("PROVISIONING_PROFILE_SPECIFIER", projectData);
1224+
}
1225+
1226+
private readXCConfigProvisioningProfileSpecifierForIPhoneOs(projectData: IProjectData): string {
1227+
return this.readXCConfig("PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]", projectData);
1228+
}
1229+
11821230
private async getDevelopmentTeam(projectData: IProjectData, teamId?: string): Promise<string> {
11831231
teamId = teamId || this.readTeamId(projectData);
11841232

lib/services/project-changes-service.ts

+4-10
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,10 @@ export class ProjectChangesService implements IProjectChangesService {
7575
]);
7676
}
7777
}
78-
if (platform.toLowerCase() === this.$devicePlatformsConstants.iOS.toLowerCase()) {
79-
const nextCommandProvisionUUID = projectChangesOptions.provision;
80-
// We should consider reading here the provisioning profile UUID from the xcodeproj and xcconfig.
81-
const prevProvisionUUID = this._prepareInfo.iOSProvisioningProfileUUID;
82-
if (nextCommandProvisionUUID !== prevProvisionUUID) {
83-
this._changesInfo.nativeChanged = true;
84-
this._changesInfo.configChanged = true;
85-
this._prepareInfo.iOSProvisioningProfileUUID = nextCommandProvisionUUID;
86-
}
87-
}
78+
79+
let projectService = platformData.platformProjectService;
80+
projectService.checkForChanges(this._changesInfo, projectChangesOptions, projectData);
81+
8882
if (projectChangesOptions.bundle !== this._prepareInfo.bundle || projectChangesOptions.release !== this._prepareInfo.release) {
8983
this._changesInfo.appFilesChanged = true;
9084
this._changesInfo.appResourcesChanged = true;

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"mute-stream": "0.0.5",
5757
"open": "0.0.5",
5858
"osenv": "0.1.3",
59-
"pbxproj-dom": "1.0.9",
59+
"pbxproj-dom": "1.0.11",
6060
"plist": "1.1.0",
6161
"plist-merge-patch": "0.0.9",
6262
"plistlib": "0.2.1",

0 commit comments

Comments
 (0)