I’ve been working through the first chapter of the third edition (current edition), and I’m getting a segfault when I try entering Swift code into lldb.
(lldb) ex -l swift -o -- unsafeBitCast(0x0000000112021000, to: NSView.self)
note: Swift compiler options for Xcode conflict with options found in other modules;
Switching to a new expression evaluator for Xcode, old $R variables are lost.
Segmentation fault: 11
Any ideas what’s going wrong?
BTW, I’ve noticed a StackOverflow post and a related Apple Dev Forum post describing the same bug, but it turned out that the problem there was with the CommonCrypto framework, which we’re not using here. Nor did it mention anything about a segfault.
@lolgrep Can you please help with this when you get a chance? Thank you - much appreciated! :]
I’ve encountered the same error. The solution was to save the result of the operation to some variable in swift and later reuse it.
So instead of that
(lldb) ex -l swift -o -- unsafeBitCast(0x0110a42600, to: NSView.self)
You should use something like this:
(lldb) ex -l swift -o -- let $someResult = unsafeBitCast(0x0110a42600, to: NSView.self)
And after it will be more convient to perform operations on saved object.
I just started that book so I don’t know the reason why it works.
The following example with insert text works well so maybe the reason in unsafeBitCast and it return value.
You can try to repeat that example again and sometimes before sefault you will get
unrecognized byte size
@gorloff Thank you for sharing your solution - much appreciated! :]
This topic was automatically closed after 166 days. New replies are no longer allowed.