Skip to content

Commit

Permalink
Update warning as errors config
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle-Ye committed Feb 18, 2024
1 parent 52d08a9 commit d444641
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"location" : "https://github.com/OpenSwiftUIProject/OpenGraph",
"state" : {
"branch" : "main",
"revision" : "8f0376278186b6e24e8d7a07a560f3efaa2fef1d"
"revision" : "8cc89abc1fff74b387a083eab8ffa91f1b9fdca7"
}
},
{
Expand Down
53 changes: 32 additions & 21 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,63 @@
import Foundation
import PackageDescription

let isXcodeEnv = ProcessInfo.processInfo.environment["__CFBundleIdentifier"] == "com.apple.dt.Xcode"
func envEnable(_ key: String, default defaultValue: Bool = false) -> Bool {
guard let value = Context.environment[key] else {
return defaultValue
}
if value == "1" {
return true
} else if value == "0" {
return false
} else {
return defaultValue
}
}

let isXcodeEnv = Context.environment["__CFBundleIdentifier"] == "com.apple.dt.Xcode"

// Xcode use clang as linker which supports "-iframework" while SwiftPM use swiftc as linker which supports "-Fsystem"
let systemFrameworkSearchFlag = isXcodeEnv ? "-iframework" : "-Fsystem"

var sharedSwiftSettings: [SwiftSetting] = [
.enableExperimentalFeature("AccessLevelOnImport"),
.define("OPENSWIFTUI_SUPPRESS_DEPRECATED_WARNINGS"),
]

let warningsAsErrorsCondition = envEnable("OPENSWIFTUI_WERROR", default: isXcodeEnv)
if warningsAsErrorsCondition {
sharedSwiftSettings.append(.unsafeFlags(["-warnings-as-errors"]))
}

let openSwiftUITarget = Target.target(
name: "OpenSwiftUI",
dependencies: [
"OpenSwiftUIShims",
.target(name: "CoreServices", condition: .when(platforms: [.iOS])),
.product(name: "OpenGraphShims", package: "OpenGraph"),
],
swiftSettings: [
.enableExperimentalFeature("AccessLevelOnImport"),
.define("OPENSWIFTUI_SUPPRESS_DEPRECATED_WARNINGS"),
]
swiftSettings: sharedSwiftSettings
)
let openSwiftUITestTarget = Target.testTarget(
name: "OpenSwiftUITests",
dependencies: [
"OpenSwiftUI",
],
exclude: ["README.md"]
exclude: ["README.md"],
swiftSettings: sharedSwiftSettings
)
let openSwiftUITempTestTarget = Target.testTarget(
name: "OpenSwiftUITempTests",
dependencies: [
"OpenSwiftUI",
],
exclude: ["README.md"]
exclude: ["README.md"],
swiftSettings: sharedSwiftSettings
)
let openSwiftUICompatibilityTestTarget = Target.testTarget(
name: "OpenSwiftUICompatibilityTests",
exclude: ["README.md"]
exclude: ["README.md"],
swiftSettings: sharedSwiftSettings
)

let package = Package(
Expand Down Expand Up @@ -71,19 +95,6 @@ let package = Package(
]
)

func envEnable(_ key: String, default defaultValue: Bool = false) -> Bool {
guard let value = ProcessInfo.processInfo.environment[key] else {
return defaultValue
}
if value == "1" {
return true
} else if value == "0" {
return false
} else {
return defaultValue
}
}

#if os(macOS)
let attributeGraphCondition = envEnable("OPENGRAPH_ATTRIBUTEGRAPH", default: true)
#else
Expand Down

0 comments on commit d444641

Please sign in to comment.