'Project Name' was compiled with optimization - stepping may behave oddly; variables may not be available

Mojtaba picture Mojtaba · Sep 25, 2015 · Viewed 90.1k times · Source

Trying to step into AFNetworking code generates following warning:

[Project Name] was compiled with optimization - stepping may behave oddly; variables may not be available.

And of course I'm not able to debug the code. To be specific I'm trying to debug UIImageView+AFNetworking category which seems impossible. Changing the code has no effect (tried NSLog, etc) and when trying to step in compilers goes to assembly code and shows UIImageView+TVASTAFNetworking as category name which does not exist anywhere in the code base.

enter image description here

Using Xcode 7. iOS 9 & 8. Cocoapods (no Framework)

UPDATE I forgot to mention that Optimizer is set to none for both release and debug configuration and I am in fact using Debug config.

enter image description here

UPDATE 2

Strip Debug Symbols Is off as well.

Answer

Albert Bori picture Albert Bori · Oct 7, 2015

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:

  1. Select your project in the Project Navigator pane
  2. Select your project's settings under the "PROJECT" tree
  3. Click "Build Settings" tab
  4. Search for "Optimization Level" and you'll see two settings, one for LLVM and one for swift.
  5. Set the appropriate setting (None [-O0] for LLVM and None [-0none] for Swift) for the build config in question.

was compiled with optimization stepping may behave oddlyvariables may not be available

Doing this resolved that warning for me.