Setting swift compiler flags per file

Hi!


I'm trying to make the swift compiler optimize only a single file (in Debug configuration I would like to have optimization off, except this single file).


I went to the Build Phases, and added "-O" to the Compiler Flags to that file, but it doesn't seem to have any effect. In the debug logs I can see the command to compile that file, and "-Onone" is among the arguments there, but there is no "-O".


What am I doing wrong? Is it possible at all to set separate optimization level for a single file?


Thanks,

Zsombor

It seems like with Swift files the compiler flags that are added via the Build Phases pane on a per file basis are simply ignored.

If say I add a nonsensical flag to the Swift file in question, everything builds fine.

Adding the same nonsensical gibberish to say an Objective-C file in the pane, and then I get the expected "Unknown argument: " compiler error.

Is this expected, is there no way to add specific compiler flags to individual Swift files? In particular, I would like to add the new deprecation warning suppression flags to a specific file in my framework as documented by this Swift Proposal...

https://github.com/swiftlang/swift-evolution/blob/main/proposals/0443-warning-control-flags.md

Setting swift compiler flags per file
 
 
Q