use of com.facebook.buck.apple.xcode.XcodeprojSerializer in project bazel by bazelbuild.
the class XcodeprojGeneration method write.
/**
* Writes a project to an {@code OutputStream} in the correct encoding.
*/
public static void write(OutputStream out, PBXProject project) throws IOException {
XcodeprojSerializer ser = new XcodeprojSerializer(new GidGenerator(ImmutableSet.<String>of()), project);
Writer outWriter = new OutputStreamWriter(out, StandardCharsets.UTF_8);
// toXMLPropertyList includes an XML encoding specification (UTF-8), which we specify above.
// Standard Xcodeproj files use the toASCIIPropertyList format, but Xcode will rewrite
// XML-encoded project files automatically when first opening them. We use XML to prevent
// encoding issues, since toASCIIPropertyList does not include the UTF-8 encoding comment, and
// Xcode by default apparently uses MacRoman.
// This encoding concern is probably why Buck also generates XML project files as well.
outWriter.write(ser.toPlist().toXMLPropertyList());
outWriter.flush();
}
use of com.facebook.buck.apple.xcode.XcodeprojSerializer in project buck by facebook.
the class ProjectGenerator method writeProjectFile.
/**
* Create the project bundle structure and write {@code project.pbxproj}.
*/
private Path writeProjectFile(PBXProject project) throws IOException {
XcodeprojSerializer serializer = new XcodeprojSerializer(new GidGenerator(ImmutableSet.copyOf(gidsToTargetNames.keySet())), project);
NSDictionary rootObject = serializer.toPlist();
Path xcodeprojDir = outputDirectory.resolve(projectName + ".xcodeproj");
projectFilesystem.mkdirs(xcodeprojDir);
Path serializedProject = xcodeprojDir.resolve("project.pbxproj");
String contentsToWrite = rootObject.toXMLPropertyList();
// Before we write any files, check if the file contents have changed.
if (MoreProjectFilesystems.fileContentsDiffer(new ByteArrayInputStream(contentsToWrite.getBytes(Charsets.UTF_8)), serializedProject, projectFilesystem)) {
LOG.debug("Regenerating project at %s", serializedProject);
if (shouldGenerateReadOnlyFiles()) {
projectFilesystem.writeContentsToPath(contentsToWrite, serializedProject, READ_ONLY_FILE_ATTRIBUTE);
} else {
projectFilesystem.writeContentsToPath(contentsToWrite, serializedProject);
}
} else {
LOG.debug("Not regenerating project at %s (contents have not changed)", serializedProject);
}
return xcodeprojDir;
}
Aggregations