2 Replies
      Latest reply on Jul 15, 2019 1:07 PM by eskimo
      interim_descriptor Level 1 Level 1 (0 points)

        Hi.

         

        I'm having difficulty setting the summary format for my Swift classes.

         

        I have a class, "class Foo { var name: String }", and desire its "name" variable to be displayed when an instance is listed in Xcode's Variables View.

         

        I can get as far as right clicking an instance in the Variables View and selecting "Edit Summary Format...", but the correct format eludes me.

        • Re: Swift Summary Format
          linfeld Level 1 Level 1 (0 points)

          The Summary Format seems random.  For example, if you have a struct that has Int variables called "hour", "minute", "second", the following formats are invalid:

           

          %hour%/%minute%/%second%

          %hour% %minute% %second%

           

          but this one is valid:

           

          %hour%':%minute%':%second%

           

          but the output will be: "5':30':20"

            • Re: Swift Summary Format
              eskimo Apple Staff Apple Staff (11,485 points)

              Xcode’s summary formats are indeed a bit whacky, partly because they pre-date LLDB and thus don’t match LLDB’s type summary formats [1].

              As to why the Xcode is treating the colon character weirdly, it’s definitely related to the data formatting but I’m kinda hazy on the details.

              Regardless, to answer interim_descriptor’s original question, if you have a class like this:

              class Foo {
                  var name: String
                  … other stuff …
              }

              you can use name as the summary with the format %name%:s.  Note the :s to format it as a string.

              Share and Enjoy

              Quinn “The Eskimo!”
              Apple Developer Relations, Developer Technical Support, Core OS/Hardware
              let myEmail = "eskimo" + "1" + "@apple.com"

              [1] Despite what the documentation currently says (r. 51829873)!