Optimization level defines how code are compiled and linked. For code debugging this should be disabled other wise breakpoint will not behave properly. Xcode will complain about the same by printing message “App Name was compiled with optimization – stepping may behave oddly; variables may not be available.” on console. Different optimization flags that may be turn off for debugging are :

  • LLVM Link Time Optimization (-flto)
  • LLVM Optimization Level (-O)
  • Swift Compiler Optimization Level

Set the Optimization Level to None while debugging to make the message go away and your break points behave normally. Project setting to change for the same is: 

  • Click on your target in the left sidebar.
  • Click on Build Settings
  • Search for ‘Optimization level’
  • Change the values as required


Optimization levels

Optimization levels in LLVM are:

  • None [-O0]:  Compiler does not attempt to optimize code. Use this option during development when you are focused on solving logic errors and need a fast compile time.
  • Fast [-O, O1]: Compiler performs simple optimizations to boost code performance while minimizing the impact to compile time.
  • Faster [-O2] : Compiler performs nearly all supported optimizations that do not require a space-time tradeoff. This option increases both compilation time and the performance of generated code.
  • Fastest [-O3]: Compiler performs all optimizations in an attempt to improve the speed of the generated code.
  • Fastest, Smallest [-Os]: Compiler performs all optimizations that do not typically increase code size.
  • Fastest, Aggressive optimization [-Ofast] : This setting enables ‘Fastest’ but also enables aggressive optimizations that may break strict standards compliance but should work well on well-behaved code.


Project Configurations 

Xcode sets up two configurations with following default values for the LLVM optimization levels:

  • Debug ( -O0) : Fastest compile time, the easiest debugging
  • Release( -Os) : Best combination of small binary size and fast runtime execution

Option responsible for C-family language optimization is called GCC_OPTIMIZATION_LEVEL.