Skip to content

Commit

Permalink
well turn it all off i guess
Browse files Browse the repository at this point in the history
  • Loading branch information
lawrence-forooghian committed Aug 22, 2024
1 parent fa715b9 commit 258bb87
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions Sources/BuildTool/XcodeRunner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,40 @@ enum XcodeRunner {

arguments.append(contentsOf: ["-scheme", scheme])
arguments.append(contentsOf: ["-destination", destination.xcodebuildArgument])
arguments.append("SWIFT_TREAT_WARNINGS_AS_ERRORS=YES")
arguments.append("SWIFT_SUPPRESS_WARNINGS=NO")

/*
Note: I was previously passing SWIFT_TREAT_WARNINGS_AS_ERRORS=YES here, but am no longer able to do so, for the following reasons:

1. After adding a new package dependency, Xcode started trying to pass
the Swift compiler the -suppress-warnings flag when compiling one of
the newly-added transitive dependencies. This clashes with the
-warnings-as-errors flag that Xcode adds when you set
SWIFT_TREAT_WARNINGS_AS_ERRORS=YES, leading to a compiler error like

> error: Conflicting options '-warnings-as-errors' and '-suppress-warnings' (in target 'InternalCollectionsUtilities' from project 'swift-collections')

It’s not clear _why_ Xcode is adding this flag (see
https://forums.swift.org/t/warnings-as-errors-in-sub-packages/70810),
but perhaps it’s because of what I mention in point 2 below.

It seems that there is no way to tell Xcode, when building your own
Swift package, “treat warnings as errors, but only for my package, and
not for its dependencies”.

2. So, I thought that I’d try making Xcode remove the
-suppress-warnings flag by additionally passing
SWIFT_SUPPRESS_WARNINGS=NO, but this also doesn’t work because it turns
out that one of our dependencies (swift-async-algorithms) actually does
have some warnings, causing the build to fail.

tl;dr: There doesn’t seem to be a way to treat warnings as errors when
compiling the package from Package.swift using Xcode.

It’s probably OK, though, because we also compile the package with SPM,
and hopefully that will flag any warnings in CI (unless there’s some
class of warnings I’m not aware of that only appear when compiling
against the tvOS or iOS SDK).
*/

if let exampleAppSwiftVersion {
arguments.append(
Expand Down

0 comments on commit 258bb87

Please sign in to comment.