Skip to content

Commit ac8eb91

Browse files
author
Yosif Yosifov
committed
Fix PR comments
1 parent 6b74cbe commit ac8eb91

File tree

5 files changed

+32
-23
lines changed

5 files changed

+32
-23
lines changed

lib/constants.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ export const TEST_RUNNER_NAME = "nativescript-unit-test-runner";
1616
export const LIVESYNC_EXCLUDED_FILE_PATTERNS = ["**/*.js.map", "**/*.ts"];
1717
export const XML_FILE_EXTENSION = ".xml";
1818
export const PLATFORMS_DIR_NAME = "platforms";
19-
export const IOS_PLATFORM_NAME = "ios";
20-
export const IOS_PLATFORM_NORMALIZED_NAME = "iOS";
2119
export const CODE_SIGN_ENTITLEMENTS = "CODE_SIGN_ENTITLEMENTS";
2220

2321
export class PackageVersion {

lib/services/ios-entitlements-service.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,25 @@ import { PlistSession } from "plist-merge-patch";
44

55
export class IOSEntitlementsService {
66
constructor(private $fs: IFileSystem,
7-
private $injector: IInjector,
8-
private $logger: ILogger) {
7+
private $logger: ILogger,
8+
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
9+
private $mobileHelper: Mobile.IMobileHelper,
10+
private $pluginsService: IPluginsService) {
911
}
1012

1113
public static readonly DefaultEntitlementsName: string = "app.entitlements";
1214

1315
private getDefaultAppEntitlementsPath(projectData: IProjectData) : string {
14-
let entitlementsName = IOSEntitlementsService.DefaultEntitlementsName;
15-
let entitlementsPath = path.join(projectData.projectDir,
16+
const entitlementsName = IOSEntitlementsService.DefaultEntitlementsName;
17+
const entitlementsPath = path.join(projectData.projectDir,
1618
constants.APP_FOLDER_NAME, constants.APP_RESOURCES_FOLDER_NAME,
17-
constants.IOS_PLATFORM_NORMALIZED_NAME,
19+
this.$mobileHelper.normalizePlatformName(this.$devicePlatformsConstants.iOS),
1820
entitlementsName);
1921
return entitlementsPath;
2022
}
2123

2224
public getPlatformsEntitlementsPath(projectData: IProjectData) : string {
23-
return path.join(projectData.platformsDir, constants.IOS_PLATFORM_NAME,
25+
return path.join(projectData.platformsDir, this.$devicePlatformsConstants.iOS,
2426
projectData.projectName, projectData.projectName + ".entitlements");
2527
}
2628
public getPlatformsEntitlementsRelativePath(projectData: IProjectData): string {
@@ -46,7 +48,8 @@ export class IOSEntitlementsService {
4648

4749
let allPlugins = await this.getAllInstalledPlugins(projectData);
4850
for (let plugin of allPlugins) {
49-
let pluginInfoPlistPath = path.join(plugin.pluginPlatformsFolderPath(constants.IOS_PLATFORM_NAME), IOSEntitlementsService.DefaultEntitlementsName);
51+
let pluginInfoPlistPath = path.join(plugin.pluginPlatformsFolderPath(this.$devicePlatformsConstants.iOS),
52+
IOSEntitlementsService.DefaultEntitlementsName);
5053
makePatch(pluginInfoPlistPath);
5154
}
5255

@@ -62,7 +65,7 @@ export class IOSEntitlementsService {
6265
}
6366

6467
private getAllInstalledPlugins(projectData: IProjectData): Promise<IPluginData[]> {
65-
return (<IPluginsService>this.$injector.resolve("pluginsService")).getAllInstalledPlugins(projectData);
68+
return this.$pluginsService.getAllInstalledPlugins(projectData);
6669
}
6770
}
6871

lib/services/ios-project-service.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
4646
private $xcode: IXcode,
4747
private $iOSEntitlementsService: IOSEntitlementsService,
4848
private $sysInfo: ISysInfo,
49-
private xCConfigService: XCConfigService) {
49+
private $xCConfigService: XCConfigService) {
5050
super($fs, $projectDataService);
5151
}
5252

@@ -1108,11 +1108,11 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
11081108
}
11091109

11101110
// Set Entitlements Property to point to default file if not set explicitly by the user.
1111-
let entitlementsPropertyValue = this.xCConfigService.readPropertyValue(pluginsXcconfigFilePath, constants.CODE_SIGN_ENTITLEMENTS);
1112-
if (entitlementsPropertyValue == null) {
1111+
let entitlementsPropertyValue = this.$xCConfigService.readPropertyValue(pluginsXcconfigFilePath, constants.CODE_SIGN_ENTITLEMENTS);
1112+
if (entitlementsPropertyValue === null) {
11131113
temp.track();
1114-
let tempEntitlementsDir = temp.mkdirSync("entitlements");
1115-
let tempEntitlementsFilePath = path.join(tempEntitlementsDir, "set-entitlements.xcconfig");
1114+
const tempEntitlementsDir = temp.mkdirSync("entitlements");
1115+
const tempEntitlementsFilePath = path.join(tempEntitlementsDir, "set-entitlements.xcconfig");
11161116
const entitlementsRelativePath = this.$iOSEntitlementsService.getPlatformsEntitlementsRelativePath(projectData);
11171117
this.$fs.writeFile(tempEntitlementsFilePath, `CODE_SIGN_ENTITLEMENTS = ${entitlementsRelativePath}${EOL}`);
11181118

@@ -1203,7 +1203,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
12031203
}
12041204

12051205
private readTeamId(projectData: IProjectData): string {
1206-
let teamId = this.xCConfigService.readPropertyValue(this.getBuildXCConfigFilePath(projectData), "DEVELOPMENT_TEAM");
1206+
let teamId = this.$xCConfigService.readPropertyValue(this.getBuildXCConfigFilePath(projectData), "DEVELOPMENT_TEAM");
12071207

12081208
let fileName = path.join(this.getPlatformData(projectData).projectRoot, "teamid");
12091209
if (this.$fs.exists(fileName)) {
@@ -1214,19 +1214,19 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
12141214
}
12151215

12161216
private readXCConfigProvisioningProfile(projectData: IProjectData): string {
1217-
return this.xCConfigService.readPropertyValue(this.getBuildXCConfigFilePath(projectData), "PROVISIONING_PROFILE");
1217+
return this.$xCConfigService.readPropertyValue(this.getBuildXCConfigFilePath(projectData), "PROVISIONING_PROFILE");
12181218
}
12191219

12201220
private readXCConfigProvisioningProfileForIPhoneOs(projectData: IProjectData): string {
1221-
return this.xCConfigService.readPropertyValue(this.getBuildXCConfigFilePath(projectData), "PROVISIONING_PROFILE[sdk=iphoneos*]");
1221+
return this.$xCConfigService.readPropertyValue(this.getBuildXCConfigFilePath(projectData), "PROVISIONING_PROFILE[sdk=iphoneos*]");
12221222
}
12231223

12241224
private readXCConfigProvisioningProfileSpecifier(projectData: IProjectData): string {
1225-
return this.xCConfigService.readPropertyValue(this.getBuildXCConfigFilePath(projectData), "PROVISIONING_PROFILE_SPECIFIER");
1225+
return this.$xCConfigService.readPropertyValue(this.getBuildXCConfigFilePath(projectData), "PROVISIONING_PROFILE_SPECIFIER");
12261226
}
12271227

12281228
private readXCConfigProvisioningProfileSpecifierForIPhoneOs(projectData: IProjectData): string {
1229-
return this.xCConfigService.readPropertyValue(this.getBuildXCConfigFilePath(projectData), "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]");
1229+
return this.$xCConfigService.readPropertyValue(this.getBuildXCConfigFilePath(projectData), "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]");
12301230
}
12311231

12321232
private async getDevelopmentTeam(projectData: IProjectData, teamId?: string): Promise<string> {

test/ios-entitlements-service.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import { IOSEntitlementsService } from "../lib/services/ios-entitlements-service
55
import * as yok from "../lib/common/yok";
66
import * as stubs from "./stubs";
77
import * as FsLib from "../lib/common/file-system";
8+
import * as MobilePlatformsCapabilitiesLib from "../lib/common/appbuilder/mobile-platforms-capabilities";
9+
import * as MobileHelperLib from "../lib/common/mobile/mobile-helper";
10+
import * as DevicePlatformsConstantsLib from "../lib/common/mobile/device-platforms-constants";
11+
import * as ErrorsLib from "../lib/common/errors";
812
import * as path from "path";
913

1014
// start tracking temporary folders/files
@@ -19,6 +23,10 @@ describe("IOSEntitlements Service Tests", () => {
1923
testInjector.register('iOSEntitlementsService', IOSEntitlementsService);
2024

2125
testInjector.register("fs", FsLib.FileSystem);
26+
testInjector.register("mobileHelper", MobileHelperLib.MobileHelper);
27+
testInjector.register("devicePlatformsConstants", DevicePlatformsConstantsLib.DevicePlatformsConstants);
28+
testInjector.register("mobilePlatformsCapabilities", MobilePlatformsCapabilitiesLib.MobilePlatformsCapabilities);
29+
testInjector.register("errors", ErrorsLib.Errors);
2230

2331
testInjector.register("pluginsService", {
2432
getAllInstalledPlugins: async () => []
@@ -34,7 +42,7 @@ describe("IOSEntitlements Service Tests", () => {
3442
iOSEntitlementsService: IOSEntitlementsService,
3543
destinationFilePath: string;
3644

37-
beforeEach(function() {
45+
beforeEach(() => {
3846
injector = createTestInjector();
3947

4048
platformsData = injector.resolve("platformsData");

test/ios-project-service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ describe("Merge Project XCConfig files", () => {
781781
iOSEntitlementsService = testInjector.resolve("iOSEntitlementsService");
782782

783783
appResourcesXcconfigPath = path.join(projectData.projectDir, constants.APP_FOLDER_NAME,
784-
constants.APP_RESOURCES_FOLDER_NAME, constants.IOS_PLATFORM_NORMALIZED_NAME, "build.xcconfig");
784+
constants.APP_RESOURCES_FOLDER_NAME, "iOS", "build.xcconfig");
785785
appResourceXCConfigContent = `CODE_SIGN_IDENTITY = iPhone Distribution
786786
// To build for device with XCode 8 you need to specify your development team. More info: https://developer.apple.com/library/prerelease/content/releasenotes/DeveloperTools/RN-Xcode/Introduction.html
787787
// DEVELOPMENT_TEAM = YOUR_TEAM_ID;
@@ -832,7 +832,7 @@ describe("Merge Project XCConfig files", () => {
832832
}
833833
});
834834

835-
it("The user specified entitlements property takes percedence", async () => {
835+
it("The user specified entitlements property takes precedence", async () => {
836836
// setup app_resource build.xcconfig
837837
const expectedEntitlementsFile = 'user.entitlements';
838838
let xcconfigEntitlements = appResourceXCConfigContent + `${EOL}CODE_SIGN_ENTITLEMENTS = ${expectedEntitlementsFile}`;

0 commit comments

Comments
 (0)