From 49acce8a027252585d61e2c82f7298acad9da77a Mon Sep 17 00:00:00 2001 From: Googler Date: Fri, 22 Apr 2016 22:18:30 +0000 Subject: Always output entitlements plist in the XML format Adding --extra_entitlements flag to a build triggers a merge of entitlements files using plmerge tool. Configure build rules to output the resulting plist file in the XML format. Bundles signed with entitlements in the binary format fail to load on device. -- MOS_MIGRATED_REVID=120588271 --- .../com/google/devtools/build/xcode/plmerge/PlMerge.java | 16 +++++++++++++++- .../devtools/build/xcode/plmerge/PlistMerging.java | 13 ++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) (limited to 'src/objc_tools') diff --git a/src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/PlMerge.java b/src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/PlMerge.java index c204e2f53d..8f9f558938 100644 --- a/src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/PlMerge.java +++ b/src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/PlMerge.java @@ -27,6 +27,7 @@ import java.io.InputStream; import java.nio.file.FileSystem; import java.nio.file.FileSystems; import java.nio.file.Files; +import java.nio.file.Path; /** * Entry point for the {@code plmerge} tool, which merges the data from one or more plists into a @@ -75,7 +76,20 @@ public class PlMerge { // This prevents CFBundleIdentifiers being put into strings files. merging.setBundleIdentifier(primaryBundleId, fallbackBundleId); } - merging.writePlist(fileSystem.getPath(control.getOutFile())); + + Path outputPath = fileSystem.getPath(control.getOutFile()); + switch (control.getOutputFormat()) { + case BINARY: + merging.writePlist(outputPath); + break; + case XML: + merging.writeXmlPlist(outputPath); + break; + default: + throw new IllegalArgumentException(String.format( + "Unknown output format in the control file: %s", + control.getOutputFormat())); + } } private static void validateControl(Control control) { diff --git a/src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/PlistMerging.java b/src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/PlistMerging.java index 0463039fac..b292a65bd1 100644 --- a/src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/PlistMerging.java +++ b/src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/PlistMerging.java @@ -122,7 +122,7 @@ public class PlistMerging extends Value { } /** - * Writes the results of a merge operation to a plist file. + * Writes the results of a merge operation to a binary plist file. * @param plistPath the path of the plist to write in binary format */ public PlistMerging writePlist(Path plistPath) throws IOException { @@ -132,6 +132,17 @@ public class PlistMerging extends Value { return this; } + /** + * Writes the results of a merge operation to an XML plist file. + * @param plistPath the path of the plist to write in XML format + */ + public PlistMerging writeXmlPlist(Path plistPath) throws IOException { + try (OutputStream out = Files.newOutputStream(plistPath)) { + PropertyListParser.saveAsXML(merged, out); + } + return this; + } + /** * Writes a PkgInfo file based on certain keys in the merged plist. * @param pkgInfoPath the path of the PkgInfo file to write. In many iOS apps, this file just -- cgit v1.2.3