Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions lib/services/ios-entitlements-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class IOSEntitlementsService {
private $logger: ILogger,
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
private $mobileHelper: Mobile.IMobileHelper,
private $pluginsService: IPluginsService
private $pluginsService: IPluginsService,
) {}

public static readonly DefaultEntitlementsName: string = "app.entitlements";
Expand All @@ -23,28 +23,31 @@ export class IOSEntitlementsService {
const entitlementsPath = path.join(
projectData.appResourcesDirectoryPath,
this.$mobileHelper.normalizePlatformName(
this.$options.platformOverride ?? this.$devicePlatformsConstants.iOS
this.$options.platformOverride ?? this.$devicePlatformsConstants.iOS,
),
entitlementsName
entitlementsName,
);
return entitlementsPath;
}

public getPlatformsEntitlementsPath(projectData: IProjectData): string {
return path.join(
projectData.platformsDir,
this.$options.platformOverride ??
this.$devicePlatformsConstants.iOS.toLowerCase(),
this.$mobileHelper
.normalizePlatformName(
this.$options.platformOverride ?? this.$devicePlatformsConstants.iOS,
)
.toLowerCase(),
projectData.projectName,
projectData.projectName + ".entitlements"
projectData.projectName + ".entitlements",
);
}
public getPlatformsEntitlementsRelativePath(
projectData: IProjectData
projectData: IProjectData,
): string {
return path.join(
projectData.projectName,
projectData.projectName + ".entitlements"
projectData.projectName + ".entitlements",
);
}

Expand All @@ -71,7 +74,7 @@ export class IOSEntitlementsService {
for (const plugin of allPlugins) {
const pluginInfoPlistPath = path.join(
plugin.pluginPlatformsFolderPath(this.$devicePlatformsConstants.iOS),
IOSEntitlementsService.DefaultEntitlementsName
IOSEntitlementsService.DefaultEntitlementsName,
);
makePatch(pluginInfoPlistPath);
}
Expand All @@ -85,17 +88,17 @@ export class IOSEntitlementsService {
const plistContent = session.build();
this.$logger.trace(
"App.entitlements: Write to: " +
this.getPlatformsEntitlementsPath(projectData)
this.getPlatformsEntitlementsPath(projectData),
);
this.$fs.writeFile(
this.getPlatformsEntitlementsPath(projectData),
plistContent
plistContent,
);
}
}

private getAllInstalledPlugins(
projectData: IProjectData
projectData: IProjectData,
): Promise<IPluginData[]> {
return this.$pluginsService.getAllInstalledPlugins(projectData);
}
Expand Down
14 changes: 8 additions & 6 deletions lib/services/ios-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
}

private _platformsDirCache: string = null;
private _platformOverrideCache: string = null;
private _platformData: IPlatformData = null;

public getPlatformData(projectData: IProjectData): IPlatformData {
Expand All @@ -139,10 +140,12 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
);
}

const currentOverride = this.$options.platformOverride ?? null;
if (
projectData &&
projectData.platformsDir &&
this._platformsDirCache !== projectData.platformsDir
(this._platformsDirCache !== projectData.platformsDir ||
this._platformOverrideCache !== currentOverride)
) {
const platform = this.$mobileHelper.normalizePlatformName(
this.$options.platformOverride ?? this.$devicePlatformsConstants.iOS,
Expand Down Expand Up @@ -231,6 +234,8 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
".xbm",
], // https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIImage_Class/
};
this._platformsDirCache = projectData.platformsDir;
this._platformOverrideCache = currentOverride;
}

return this._platformData;
Expand Down Expand Up @@ -659,13 +664,10 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
projectData: IProjectData,
prepareData: IOSPrepareData,
): Promise<void> {
const platformData = this.getPlatformData(projectData);
const projectRoot = this.$options.hostProjectPath
? this.$options.hostProjectPath
: path.join(
projectData.platformsDir,
this.$devicePlatformsConstants.iOS.toLowerCase(),
);
const platformData = this.getPlatformData(projectData);
: platformData.projectRoot;

const pluginsData = this.getAllProductionPlugins(projectData);
const pbxProjPath = this.getPbxProjPath(projectData);
Expand Down
Loading