Skip to content

Commit 409e4ee

Browse files
committed
Do not create empty .entitlements file
Fixes #3481
1 parent bf3969b commit 409e4ee

File tree

4 files changed

+27
-12
lines changed

4 files changed

+27
-12
lines changed

lib/services/ios-entitlements-service.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,11 @@ export class IOSEntitlementsService {
5656
makePatch(appEntitlementsPath);
5757
}
5858

59-
const plistContent = session.build();
60-
this.$logger.trace("App.entitlements: Write to: " + this.getPlatformsEntitlementsPath(projectData));
61-
this.$fs.writeFile(this.getPlatformsEntitlementsPath(projectData), plistContent);
62-
return;
59+
if ((<any>session).patches && (<any>session).patches.length > 0) {
60+
const plistContent = session.build();
61+
this.$logger.trace("App.entitlements: Write to: " + this.getPlatformsEntitlementsPath(projectData));
62+
this.$fs.writeFile(this.getPlatformsEntitlementsPath(projectData), plistContent);
63+
}
6364
}
6465

6566
private getAllInstalledPlugins(projectData: IProjectData): Promise<IPluginData[]> {

lib/services/ios-project-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
12411241

12421242
// Set Entitlements Property to point to default file if not set explicitly by the user.
12431243
const entitlementsPropertyValue = this.$xCConfigService.readPropertyValue(pluginsXcconfigFilePath, constants.CODE_SIGN_ENTITLEMENTS);
1244-
if (entitlementsPropertyValue === null) {
1244+
if (entitlementsPropertyValue === null && this.$fs.exists(this.$iOSEntitlementsService.getPlatformsEntitlementsPath(projectData))) {
12451245
temp.track();
12461246
const tempEntitlementsDir = temp.mkdirSync("entitlements");
12471247
const tempEntitlementsFilePath = path.join(tempEntitlementsDir, "set-entitlements.xcconfig");

test/ios-entitlements-service.ts

+11-7
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,6 @@ describe("IOSEntitlements Service Tests", () => {
7676
});
7777

7878
describe("Merge", () => {
79-
const defaultPlistContent = `<?xml version="1.0" encoding="UTF-8"?>
80-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
81-
<plist version="1.0">
82-
<dict/>
83-
</plist>`;
8479
const defaultAppResourcesEntitlementsContent = `<?xml version="1.0" encoding="UTF-8"?>
8580
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
8681
<plist version="1.0">
@@ -123,13 +118,22 @@ describe("IOSEntitlements Service Tests", () => {
123118
assert.equal(strip(actual), strip(expected));
124119
}
125120

126-
it("Merge creates a default entitlements file.", async () => {
121+
it("Merge creates a merged entitlements file.", async () => {
122+
const realExistsFunction = injector.resolve("fs").exists;
123+
injector.resolve("fs").exists = (filePath: string) => {
124+
if (iOSEntitlementsService.getPlatformsEntitlementsPath(projectData) === filePath) {
125+
return true;
126+
}
127+
128+
return realExistsFunction(filePath);
129+
};
130+
127131
// act
128132
await iOSEntitlementsService.merge(projectData);
129133

130134
// assert
131135
const actual = fs.readText(destinationFilePath);
132-
assertContent(actual, defaultPlistContent);
136+
assertContent(actual, mergedEntitlementsContent);
133137
});
134138

135139
it("Merge uses the entitlements from App_Resources folder", async () => {

test/ios-project-service.ts

+10
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,16 @@ describe("Merge Project XCConfig files", () => {
839839

840840
it("Adds the entitlements property if not set by the user", async () => {
841841
for (const release in [true, false]) {
842+
const realExistsFunction = testInjector.resolve("fs").exists;
843+
844+
testInjector.resolve("fs").exists = (filePath: string) => {
845+
if (iOSEntitlementsService.getPlatformsEntitlementsPath(projectData) === filePath) {
846+
return true;
847+
}
848+
849+
return realExistsFunction(filePath);
850+
};
851+
842852
await (<any>iOSProjectService).mergeProjectXcconfigFiles(release, projectData);
843853

844854
const destinationFilePath = release ? (<any>iOSProjectService).getPluginsReleaseXcconfigFilePath(projectData)

0 commit comments

Comments
 (0)