Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

224
Views
How can I access a swift convenience variable from objc in lldb?

I'm trying to set some convenience variable in a swift context and to access it from a ObjC context.

(lldb) expression -l swift -- var $answerSwift = 42
(lldb) expression -o -l swift -- $answerSwift
42
(lldb) expression -o -l objc -- $answerSwift
error: use of undeclared identifier '$answerSwift'

The other way around works perfectly fine:

(lldb) expression -l objc -- int $answerObjc = 42
(lldb) expression -o -l swift -- $answerObjc
42

How can I move a value from the swift scope (?) to the objC scope?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

It's possible to create a "temporary context" that will be evaluated and then passed in as a variable to the expression by putting it in backticks.

So this is going to work for breakpoints in swift code:

(lldb) expression -l swift -- var $answerSwift = 42
(lldb) expression -o -l objc -- `$answerSwift`
42

When I have a breakpoint in swift code I tried to set an objc var like this:

(lldb) expression -l objc -- id $label = (id)self.label
error: use of undeclared identifier 'self'

The objc context can't access the swift variable self, so it fails.

But when putting self.label in backticks to create the temporary swift context I can assign it to the objc variable:

(lldb) expression -l objc -- id $label = (id)`self.label`
(lldb) expression -l objc -O -- $label
<UILabel: 0x7f8030c03c40; frame = (44 44; 42 21); text = 'Label'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x6000019b35c0>>

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!