title: Xcode watch 'invalid expression'
body: <p>I'm stepping through some Swift code in Xcode and I'd like to watch values. Following the advice in many of the answers here (e.g. <a href="https://stackoverflow.com/a/6500739/575530">this one</a>) I can add the expression to the local variables window.</p>
  
  <p>The breakpoint I am on is the last line of this fragment from the <a href="https://github.com/daltoniam/Starscream/blob/master/Sources/Starscream/WebSocket.swift" rel="nofollow noreferrer">Starscream library</a> (by <a href="https://github.com/daltoniam" rel="nofollow noreferrer">daltoniam</a>) which I include as a pod.</p>
  
  <pre><code>for i in 0..&lt;dataLength {
    buffer[offset] = data[i] ^ maskKey[i % MemoryLayout&lt;UInt32&gt;.size]
    offset += 1
  }
  var total = 0
  </code></pre>
  
  <p>I've added two expressions to watch:</p>
  
  <ol>
  <li><code>buffer[0]</code> and </li>
  <li><code>MemoryLayout&lt;UInt32&gt;.size</code></li>
  </ol>
  
  <p>For both the value I see is "invalid expression":</p>
  
  <p><a href="https://i.stack.imgur.com/80dsZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/80dsZ.png" alt="xcode screenshot"></a></p>
  
  <p>These expressions are clearly are not invalid, if they were the code would have thrown an exception when they were encountered executing the previous few lines. What am I missing? How should I watch and not get 'invalid expression'</p>
  
  <p>N.B. If I call <code>p buffer[0]</code> from the lldb prompt I get the cryptic error:</p>
  
  <blockquote>
    <p>(lldb) p buffer[0]<br>
    error: warning: :12:9: warning: initialization of variable<br>
        '$__lldb_error_result' was never used; consider replacing with assignment to '_'<br>
        or removing it<br>
        var $__lldb_error_result = __lldb_tmp_error<br>
        ~~~~^~~~~~~~~~~~~~~~~~~~<br>
        _</p>
    
    <p>error: :19:5: error: value of type 'WebSocket' has no member<br>
        '$__lldb_wrapped_expr_72'
        $__lldb_injected_self.$__lldb_wrapped_expr_72(
        ^~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~</p>
  </blockquote>
  
  <p>I have tried changing the podfile (as per <a href="https://stackoverflow.com/a/54208599/575530">Jim's answer</a>) so that it explicitly gets the debug code:</p>
  
  <pre><code>pod 'Starscream', '~&gt; 3.0.6', :configuration =&gt; 'Debug'
  </code></pre>
  
  <p>and I have even gone as far as removing the pods, cloning Starscream, and including the source code as a sub-project. I still get the same error.</p>