We are encountering an issue in an iOS application where functionality works correctly in Debug builds but fails in Release builds distributed via TestFlight.
Details
- Debug (No Optimization -Onone): Works correctly
- Release (Optimize for Speed -O): Fails
- Release with -Onone: Works, but app size nearly doubles
Context
The issue is related to integration with the Microsoft ONNX runtime library. It appears that the Swift/Clang compiler is aggressively optimizing certain parts of the code in Release builds, possibly removing or altering required logic.
Observations
- The issue started appearing with recent iOS/Xcode updates.
- No code changes affecting this logic were made recently.
- Behavior strongly suggests optimization-related side effects.
Questions
- Are there known issues with aggressive optimization (-O) affecting third-party libraries?
- Are there recommended flags to selectively disable optimization for specific modules or functions?
- Any tools or diagnostics to identify what is being optimized out?
Temporary Workaround
Using -Onone resolves the issue but is not viable for production due to significant increase in app size.
Any guidance would be greatly appreciated.