'Project Name' was compiled with optimization - stepping may behave oddly; variables may not be available
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:
- Select your project in the Project Navigator pane
- Select your project's settings under the "PROJECT" tree
- Click "Build Settings" tab
- Search for "Optimization Level" and you'll see two settings, one for LLVM and one for swift.
- Set the appropriate setting (
None [-O0]
for LLVM andNone [-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:
- Click on your scheme in the top-left corner of Xcode.
- Select "Edit Scheme..."
- Click on the "Build Configuration" dropdown. and change 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.