Fix formatting of PBXContainerItemProxy

Ensure the formatting of PBXContainerItemProxy is identical to
the one used by Xcode to make comparison of generated project
with the upgraded version easier.

The object needs to be formatted on multiple line and the value
of remoteGlobalIDString should be just the object id, without
its comment (i.e. id() and not Reference()).

Bug: chromium/1071055
Change-Id: Id9e55777c67e90b03a52d7585b3f4c8a65afe48f
Reviewed-on: https://gn-review.googlesource.com/c/gn/+/8083
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: Brett Wilson <brettw@chromium.org>
diff --git a/src/gn/xcode_object.cc b/src/gn/xcode_object.cc
index 007ca4e..de00523 100644
--- a/src/gn/xcode_object.cc
+++ b/src/gn/xcode_object.cc
@@ -161,6 +161,15 @@
          ext == "m" || ext == "mm";
 }
 
+// Wrapper around a const PBXObject* allowing to print just the object
+// identifier instead of a reference (i.e. identitifer and name). This
+// is used in a few place where Xcode uses the short identifier only.
+struct NoReference {
+  const PBXObject* value;
+
+  explicit NoReference(const PBXObject* value) : value(value) {}
+};
+
 void PrintValue(std::ostream& out, IndentRules rules, unsigned value) {
   out << value;
 }
@@ -175,6 +184,10 @@
   out << EncodeString(value);
 }
 
+void PrintValue(std::ostream& out, IndentRules rules, const NoReference& obj) {
+  out << obj.value->id();
+}
+
 void PrintValue(std::ostream& out, IndentRules rules, const PBXObject* value) {
   out << value->Reference();
 }
@@ -476,12 +489,12 @@
 
 void PBXContainerItemProxy::Print(std::ostream& out, unsigned indent) const {
   const std::string indent_str(indent, '\t');
-  const IndentRules rules = {true, 0};
-  out << indent_str << Reference() << " = {";
+  const IndentRules rules = {false, indent + 1};
+  out << indent_str << Reference() << " = {\n";
   PrintProperty(out, rules, "isa", ToString(Class()));
   PrintProperty(out, rules, "containerPortal", project_);
   PrintProperty(out, rules, "proxyType", 1u);
-  PrintProperty(out, rules, "remoteGlobalIDString", target_);
+  PrintProperty(out, rules, "remoteGlobalIDString", NoReference(target_));
   PrintProperty(out, rules, "remoteInfo", target_->Name());
   out << indent_str << "};\n";
 }