Skip to content

Do not create empty .entitlements file #3482

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

Merged
merged 1 commit into from
Mar 27, 2018
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
9 changes: 5 additions & 4 deletions lib/services/ios-entitlements-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ export class IOSEntitlementsService {
makePatch(appEntitlementsPath);
}

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

private getAllInstalledPlugins(projectData: IProjectData): Promise<IPluginData[]> {
Expand Down
2 changes: 1 addition & 1 deletion lib/services/ios-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f

// Set Entitlements Property to point to default file if not set explicitly by the user.
const entitlementsPropertyValue = this.$xCConfigService.readPropertyValue(pluginsXcconfigFilePath, constants.CODE_SIGN_ENTITLEMENTS);
if (entitlementsPropertyValue === null) {
if (entitlementsPropertyValue === null && this.$fs.exists(this.$iOSEntitlementsService.getPlatformsEntitlementsPath(projectData))) {
temp.track();
const tempEntitlementsDir = temp.mkdirSync("entitlements");
const tempEntitlementsFilePath = path.join(tempEntitlementsDir, "set-entitlements.xcconfig");
Expand Down
10 changes: 2 additions & 8 deletions test/ios-entitlements-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ describe("IOSEntitlements Service Tests", () => {
});

describe("Merge", () => {
const defaultPlistContent = `<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>`;
const defaultAppResourcesEntitlementsContent = `<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
Expand Down Expand Up @@ -123,13 +118,12 @@ describe("IOSEntitlements Service Tests", () => {
assert.equal(strip(actual), strip(expected));
}

it("Merge creates a default entitlements file.", async () => {
it("Merge does not create a default entitlements file.", async () => {
// act
await iOSEntitlementsService.merge(projectData);

// assert
const actual = fs.readText(destinationFilePath);
assertContent(actual, defaultPlistContent);
assert.isFalse(fs.exists(destinationFilePath));
});

it("Merge uses the entitlements from App_Resources folder", async () => {
Expand Down
10 changes: 10 additions & 0 deletions test/ios-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,16 @@ describe("Merge Project XCConfig files", () => {

it("Adds the entitlements property if not set by the user", async () => {
for (const release in [true, false]) {
const realExistsFunction = testInjector.resolve("fs").exists;

testInjector.resolve("fs").exists = (filePath: string) => {
if (iOSEntitlementsService.getPlatformsEntitlementsPath(projectData) === filePath) {
return true;
}

return realExistsFunction(filePath);
};

await (<any>iOSProjectService).mergeProjectXcconfigFiles(release, projectData);

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