-
-
Notifications
You must be signed in to change notification settings - Fork 197
Make --provision work with distribution certificates and able to update the project after initial prepare #2705
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import * as pbxprojDomXcodeModule from "pbxproj-dom/xcode"; | ||
|
||
declare global { | ||
type IPbxprojDomXcode = typeof pbxprojDomXcodeModule; | ||
} | ||
|
||
$injector.register("pbxprojDomXcode", pbxprojDomXcodeModule); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import * as xcode from "xcode"; | ||
|
||
declare global { | ||
type IXcode = typeof xcode; | ||
export namespace IXcode { | ||
export type project = typeof xcode.project; | ||
export interface Options extends xcode.Options {} // tslint:disable-line | ||
} | ||
} | ||
|
||
$injector.register("xcode", xcode); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ import * as path from "path"; | |
import * as shell from "shelljs"; | ||
import * as os from "os"; | ||
import * as semver from "semver"; | ||
import * as xcode from "xcode"; | ||
import * as constants from "../constants"; | ||
import * as helpers from "../common/helpers"; | ||
import { attachAwaitDetach } from "../common/helpers"; | ||
|
@@ -11,7 +10,6 @@ import { PlistSession } from "plist-merge-patch"; | |
import { EOL } from "os"; | ||
import * as temp from "temp"; | ||
import * as plist from "plist"; | ||
import { Xcode } from "pbxproj-dom/xcode"; | ||
import { IOSProvisionService } from "./ios-provision-service"; | ||
|
||
export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServiceBase implements IPlatformProjectService { | ||
|
@@ -42,7 +40,9 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ | |
private $pluginVariablesService: IPluginVariablesService, | ||
private $xcprojService: IXcprojService, | ||
private $iOSProvisionService: IOSProvisionService, | ||
private $sysInfo: ISysInfo) { | ||
private $sysInfo: ISysInfo, | ||
private $pbxprojDomXcode: IPbxprojDomXcode, | ||
private $xcode: IXcode) { | ||
super($fs, $projectDataService); | ||
} | ||
|
||
|
@@ -379,10 +379,9 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ | |
await this.createIpa(projectRoot, projectData, buildConfig); | ||
} | ||
|
||
private async setupSigningFromProvision(projectRoot: string, projectData: IProjectData, provision?: any): Promise<void> { | ||
private async setupSigningFromProvision(projectRoot: string, projectData: IProjectData, provision?: string): Promise<void> { | ||
if (provision) { | ||
const pbxprojPath = path.join(projectRoot, projectData.projectName + ".xcodeproj", "project.pbxproj"); | ||
const xcode = Xcode.open(pbxprojPath); | ||
const xcode = this.$pbxprojDomXcode.Xcode.open(this.getPbxProjPath(projectData)); | ||
const signing = xcode.getSigning(projectData.projectName); | ||
|
||
let shouldUpdateXcode = false; | ||
|
@@ -399,8 +398,6 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ | |
} | ||
|
||
if (shouldUpdateXcode) { | ||
// This is slow, it read through 260 mobileprovision files on my machine and does quite some checking whether provisioning profiles and devices will match. | ||
// That's why we try to avoid id by checking in the Xcode first. | ||
const pickStart = Date.now(); | ||
const mobileprovision = await this.$iOSProvisionService.pick(provision, projectData.projectId); | ||
const pickEnd = Date.now(); | ||
|
@@ -428,11 +425,16 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ | |
} | ||
|
||
private async setupSigningForDevice(projectRoot: string, buildConfig: IiOSBuildConfig, projectData: IProjectData): Promise<void> { | ||
const pbxprojPath = path.join(projectRoot, projectData.projectName + ".xcodeproj", "project.pbxproj"); | ||
const xcode = Xcode.open(pbxprojPath); | ||
const xcode = this.$pbxprojDomXcode.Xcode.open(this.getPbxProjPath(projectData)); | ||
const signing = xcode.getSigning(projectData.projectName); | ||
|
||
if ((this.readXCConfigProvisioningProfile(projectData) || this.readXCConfigProvisioningProfileForIPhoneOs(projectData)) && (!signing || signing.style !== "Manual")) { | ||
const hasProvisioningProfileInXCConfig = | ||
this.readXCConfigProvisioningProfileSpecifierForIPhoneOs(projectData) || | ||
this.readXCConfigProvisioningProfileSpecifier(projectData) || | ||
this.readXCConfigProvisioningProfileForIPhoneOs(projectData) || | ||
this.readXCConfigProvisioningProfile(projectData); | ||
|
||
if (hasProvisioningProfileInXCConfig && (!signing || signing.style !== "Manual")) { | ||
xcode.setManualSigningStyle(projectData.projectName); | ||
xcode.save(); | ||
} else if (!buildConfig.provision && !(signing && signing.style === "Manual" && !buildConfig.teamId)) { | ||
|
@@ -490,7 +492,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ | |
let frameworkBinaryPath = path.join(frameworkPath, frameworkName); | ||
let isDynamic = _.includes((await this.$childProcess.spawnFromEvent("otool", ["-Vh", frameworkBinaryPath], "close")).stdout, " DYLIB "); | ||
|
||
let frameworkAddOptions: xcode.Options = { customFramework: true }; | ||
let frameworkAddOptions: IXcode.Options = { customFramework: true }; | ||
|
||
if (isDynamic) { | ||
frameworkAddOptions["embed"] = true; | ||
|
@@ -623,7 +625,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f | |
|
||
if (provision) { | ||
let projectRoot = path.join(projectData.platformsDir, "ios"); | ||
await this.setupSigningFromProvision(projectRoot, provision); | ||
await this.setupSigningFromProvision(projectRoot, projectData, provision); | ||
} | ||
|
||
let project = this.createPbxProj(projectData); | ||
|
@@ -787,7 +789,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f | |
} | ||
|
||
private createPbxProj(projectData: IProjectData): any { | ||
let project = new xcode.project(this.getPbxProjPath(projectData)); | ||
let project = new this.$xcode.project(this.getPbxProjPath(projectData)); | ||
project.parseSync(); | ||
|
||
return project; | ||
|
@@ -844,6 +846,35 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f | |
return Promise.resolve(); | ||
} | ||
|
||
public checkForChanges(changesInfo: IProjectChangesInfo, options: IProjectChangesOptions, projectData: IProjectData): void { | ||
const provision = options.provision; | ||
if (provision !== undefined) { | ||
// Check if the native project's signing is set to the provided provision... | ||
const pbxprojPath = this.getPbxProjPath(projectData); | ||
|
||
if (this.$fs.exists(pbxprojPath)) { | ||
const xcode = this.$pbxprojDomXcode.Xcode.open(pbxprojPath); | ||
const signing = xcode.getSigning(projectData.projectName); | ||
if (signing && signing.style === "Manual") { | ||
for (let name in signing.configurations) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't you use: for (let config of signing.configurations) {
...
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its an object, not an array, my node throws [Symbol.iterator] is not a function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My mistake, I didn't notice this is an object. |
||
let config = signing.configurations[name]; | ||
if (config.uuid !== provision && config.name !== provision) { | ||
changesInfo.signingChanged = true; | ||
break; | ||
} | ||
} | ||
} else { | ||
// Specifying provisioning profile requires "Manual" signing style. | ||
// If the current signing style was not "Manual" it was probably "Automatic" or, | ||
// it was not uniform for the debug and release build configurations. | ||
changesInfo.signingChanged = true; | ||
} | ||
} else { | ||
changesInfo.signingChanged = true; | ||
} | ||
} | ||
} | ||
|
||
private getAllLibsForPluginWithFileExtension(pluginData: IPluginData, fileExtension: string): string[] { | ||
let filterCallback = (fileName: string, pluginPlatformsFolderPath: string) => path.extname(fileName) === fileExtension; | ||
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 | |
return this.readXCConfig("PROVISIONING_PROFILE[sdk=iphoneos*]", projectData); | ||
} | ||
|
||
private readXCConfigProvisioningProfileSpecifier(projectData: IProjectData): string { | ||
return this.readXCConfig("PROVISIONING_PROFILE_SPECIFIER", projectData); | ||
} | ||
|
||
private readXCConfigProvisioningProfileSpecifierForIPhoneOs(projectData: IProjectData): string { | ||
return this.readXCConfig("PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]", projectData); | ||
} | ||
|
||
private async getDevelopmentTeam(projectData: IProjectData, teamId?: string): Promise<string> { | ||
teamId = teamId || this.readTeamId(projectData); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great if we add few tests for this method