如何抑制来自第三方依赖项但不来自主要目标的所有警告?通过 SPM 安装的许多第三方依赖项会通过警告污染构建日志,这些不是我想要关注并获取报告的事情,因为它们永远不会被修复。
我在构建脚本中使用的代码:
#!/bin/bash -e
SCHEME_NAME="NameOfTheScheme"
WORKSPACE_NAME="NameOfTheWorkspace.xcworkspace"
DERIVED_DATA="./DerivedData"
rm -rf Package.resolved
git clean -dxff
xcodebuild -resolvePackageDependencies -workspace $WORKSPACE_NAME -scheme $SCHEME_NAME -derivedDataPath $DERIVED_DATA OTHER_SWIFT_FLAGS="-Xfrontend -suppress-warnings"
# iOS module build
xcodebuild -workspace $WORKSPACE_NAME -scheme $SCHEME_NAME -sdk iphoneos -destination 'generic/platform=iOS' -derivedDataPath $DERIVED_DATA
xcodebuild -workspace $WORKSPACE_NAME -scheme $SCHEME_NAME -sdk iphonesimulator -destination 'generic/platform=iOS Simulator' -derivedDataPath $DERIVED_DATA
OTHER_SWIFT_FLAGS="-DSUPPRESS_WARNINGS"
标志非常适合 xcodebuild
:
#!/bin/bash -e
PACKAGE_SCHEME=$(xcodebuild -list | (awk '/Schemes:/ {p=1; next} p && NF; !p {p=0}' | grep "Package" || xcodebuild -list | awk '/Schemes:/ {p=1; next} p && NF; !p {p=0}' | head -1) | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
xcodebuild \
-scheme "$PACKAGE_SCHEME" \
-sdk iphonesimulator \
-destination "platform=iOS Simulator,name=iPhone" \
-configuration Debug
OTHER_SWIFT_FLAGS="-DSUPPRESS_WARNINGS"