MAC OS

Xcode中Optimization Level的设置

2017-09-22  本文已影响1733人  木小土

问题

LLDB中使用po打印变量时,变量为空,且会抛出如下报错信息:

error: warning: couldn’t get cmd pointer (substituting NULL): extracting data from value failed 
Couldn’t materialize: couldn’t get the value of variable now: no location, value may have been optimized out 
Errored out in Execute, couldn’t PrepareToExecuteJITExpression

解决方案:

  1. Produc-> Scheme-> Edit Scheme -> run ,Build Configuration 改为Debug.
  2. 如果scheme已经是Debug, 则在Build Settings > Optimization Level项,将Debug的值设置为None[-O0]

设置完成后,重新运行后,LLDB中可以正常打印出变量的值。

什么是Optimization Level

下面是苹果的官方解释:

Specifies the degree to which the generated code is optimized for speed and binary size.

简单翻译如下,英文水平有限,有错误的地方望指出:

指定被编译代码的执行速度和二进制文件大小的优化程度:

在Xcode中,为了方便调试,通常Debug模式默认为None[-O0],Release模式默认为Fastest, Smallest[-Os],在实际的项目中,可以根据项目的情况设置优化级别。

上一篇 下一篇

猜你喜欢

热点阅读