12

I have an objective-C object that we can call ObjCObj I implemented a simple description method that usually works perfectly fine if I instanciate the class in a local variable.

The problem: I iterate through an array of ObjCObj objects and put them into a Swift Array

let cacheArray = [ObjCObj]()

After my array is filled, I try set a breakpoint, try to print the value of an Item and I get the following error:

expression produced error: 

/var/folders/w9/3rvg1bk95379dgvcr11n16_h0000gp/T/lldb/3499/expr878.swift:1:46: error: use of undeclared type '__ObjC'
$__lldb__DumpForDebugger(Swift.UnsafePointer<__ObjC.ObjCObj>(bitPattern: 0x67fd9b0).memory)

If I try to print an Expression like:

cacheArray[2]

It works. But If I open the array in the debugger inspector and choose one line of the array and ask for printing the description, it fails.

2
  • Hi @Mikael, running into something similar myself. Did you find any resolution/workaround for this? Commented May 16, 2016 at 15:51
  • For now, I implement debugDescription in my objects to display the information I need. I also directly access the objects properties in the console. po myarray.count or things like that.
    – Mikael
    Commented May 17, 2016 at 5:20

2 Answers 2

3

I was getting the same error only moments ago and tracked it down to a bad property attribute in one of my Obj-C Mantle model classes. (Incorrectly treated an object as a scalar.)

Broken:

@property(nonatomic, assign, readonly, nullable) AdditionalInformationStatus *additionalInformationStatus;
                     ^^^^^^

Fixed:

@property(nonatomic, copy, readonly, nullable) AdditionalInformationStatus *additionalInformationStatus;
                     ^^^^

It was an easy fix, but tough to track down.

3
  • well, I don't know why we should have to change this property in order for xcode to simply print a variable :/
    – Mikael
    Commented May 18, 2016 at 14:13
  • 1
    This wasn't just preventing me from printing values, it was also crashing our app. When I added a breakpoint to interrogate the value, I got the same error you received. When I zeroed in on the problem, it was clearly a mistake on our part. We intended to retain a copy of the object, but instead we did a simple assign as one would for a delegate, which meant our object reference count did not increase, which caused it to be deallocated, which caused the crash... (and the unhelpful error message above) Commented May 20, 2016 at 0:41
  • Disabling the Addess Sanitizer solves the problem apparently. Not for all situation though.
    – Mikael
    Commented May 20, 2016 at 6:16
1

That sounds like a bug. Please file it at http://bugreporter.apple.com.

1
  • Was this a bug?
    – mm24
    Commented Oct 12, 2016 at 11:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.