Suppress warnings from dependencies with Swift Package Manager
With Swift Tools Version 5 you may define compiler flags in the package file (see https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html#swiftsetting). Here is an example for a Package.swift
which suppresses compiler warnings during build:
// swift-tools-version:5.0
import PackageDescription
let package = Package(
name: "Antlr4",
products: [
.library(
name: "Antlr4",
targets: ["Antlr4"]),
],
targets: [
.target(
name: "Antlr4",
dependencies: [],
swiftSettings: [
.unsafeFlags(["-suppress-warnings"]),
]),
.testTarget(
name: "Antlr4Tests",
dependencies: ["Antlr4"]),
]
)
To suppress warnings only in foreign code you should split the code into two packages.
For Objective-C modules, you can use the following to disable all warnings:
cSettings: [
.unsafeFlags(["-w"])
]