If your project is using Swift, there are two separate "Optimization Level" settings in the project/target configuration.
Make sure you set them both correctly:
None [-O0]
for LLVM and None [-0none]
for Swift) for the build config in question.Doing this resolved that warning for me.
It looks like your project is in Release mode. Release mode compiles the app with lots of optimizations, but debuggers hate optimizations, so to reliably debug the app, you need to switch it to Debug mode which reduces optimization and adds a bunch of debugging information. To switch it to Debug mode:
This warning only appear when you hit a breakpoint and the source is in a project where optimization is enabled, preventing you from watching real variable values (every object is shown as nil, even if it's not)
In my case, it only happened when debugging step by step through a cocoapod dependency.
So even if you have your main target and project settings correctly set (Strip Debug Symbol=OFF, and Optimization level None), you need to make sure it is the same for the Pod project your hitting the breakpoint from.
Turns out that after importing an old project (Xcode 7.x+) to new Xcode 8.3 (8E162), probably due to compiler optimization, the Swift Compiler - Optimization Level was set by default to Fast, Single-File Optimization:
Changing it to none, solved the issue:
Editor
-> Validate Settings
then confirm all changes. Then you should get
Set Debug to None
.
This was the solution for me...
Along the lines of gimino's answer, if you are using cocoapods, add a line like this to the Podfile:
xcodeproj 'MyProject', 'Debug - local'=>:debug, 'Debug - staging'=>:debug, 'Debug - PRODUCTION'=>:debug
or for cocoapods versions >= 1.0 (thanks Diejmon)
project 'MyProject', 'Debug - local'=>:debug, 'Debug - staging'=>:debug, 'Debug - PRODUCTION'=>:debug
Where MyProject has 'Debug - local', 'Debug - staging', 'Debug - PRODUCTION' as debug configuations in addition to the standard 'Debug'
By default, cocoapods will usually generate pod configurations as Release, this Podfile line allows you to tell it they are debug.
I ran into the same issue today, and figured it out (at least in my case). I'm also using CocoaPods, and I was having this issue when running my test target (Swift mixed with ObjC).
I'm using Xcode 7.2, with iOS 9.2 SDK.
In the image below, you can see the optimizations for the target and project before my change:
The surprising thing is that even though the resolved Optimization is None [-O0], only after changing the project setting from -Os to -O0 did the compiler stop optimizing the target.
Below you can see my final settings:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With