# Compile (only) certain files with optimization

**URL:** <https://forums.swift.org/t/compile-only-certain-files-with-optimization/75199>\
**Category:** Using Swift\
**Tags:** performance\
**Created:** [October 7, 2024, 8:44am UTC](https://forums.swift.org/t/compile-only-certain-files-with-optimization/75199 "2024-10-07T08:44:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Geordie\_J](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/geordie_j/32/839_2.png) [@Geordie\_J](https://forums.swift.org/u/Geordie_J)\
**Post date:** [October 7, 2024, 8:44am UTC](https://forums.swift.org/t/compile-only-certain-files-with-optimization/75199/1 "2024-10-07T08:44:21Z")

</div>

I would like to compile certain performance-critical files (modules would also be fine) with `-O` (or `-c release`) but still keep debugging functionality for everything else. Is there some attribute I can use for this in the file itself?

Is there some other sanctioned way of doing this with SwiftPM? I can make an Xcode target and provide different compiler flags for it, but this does not fit in with building for non-Apple platforms.
