3

Knocking up an empty class within a Swift Playground gives an error __lldb_expr_

//: Playground - noun: a place where people can play

import UIKit

class FooBar {

}

let foo = FooBar()

See attached screenshot. __lldb_expr_4 at line 12 on attempted instantiation of class FooBar

This occurs on Xcode Version 6.3.1 (6D1002). I have also tried with the latest Xcode 6.4 beta 3 - Version 6.4 (6E7) - available 11th May 2015. The same error occurs.

Empty classes build without issue in a normal Swift project.

The error can be avoided by simply adding a dummy constant as follows:

//: Playground - noun: a place where people can play

import UIKit

class FooBar {
    let wibble = 10
}

let foo = FooBar()

Was surprised at this error given that creating a initial empty class is such a basic thing. In my case I wanted a scroll view delegate class to track content offsets. It would seem entirely reasonable to use a delegate with no properties.

Any ideas?

Max MacLeod
  • 26,115
  • 13
  • 104
  • 132

1 Answers1

9

This is not an error.

It's an information that the variable foo now holds an object of class FooBar whose internal name is __lldb_expr_12.FooBar. __lldb_expr_12 is the Swift module's name in the Playground in this case.

fluidsonic
  • 4,655
  • 2
  • 24
  • 34
  • ah, that's good news! So basically with no properties, the __lldb_expr is output as default? – Max MacLeod May 18 '15 at 12:44
  • 1
    All your class names are prefixed with `__lldb_expr….` in Playground. All classes must belong to a Swift module which has a name. The class's internal name is then `ModuleName.ClassName`. And since you cannot pick a custom module name in Playground it'll use `__lldb_expr…`. - When you build an app for example it'll be `AppName.ClassName`. - i.e. it does not depend on the properties. – fluidsonic May 18 '15 at 12:47
  • I tried this in Xcode 11.3.1, what I got is foobar = Optional(LearnARC.Foobar) – infinity_coding7 Feb 21 '20 at 20:58