diff --git a/.github/workflows/check-package-diff.yml b/.github/workflows/check-package-diff.yml new file mode 100644 index 00000000000..fd2c7a50fa0 --- /dev/null +++ b/.github/workflows/check-package-diff.yml @@ -0,0 +1,24 @@ +# We want to ensure that the Package.swift and Package@swift-5.9.swift are in sync. + +name: Check Package.swift Diff + +on: + push: + branches: + - main + + pull_request: + paths: + - ".github/workflows/check-package-diff.yml" + - "Package*.swift" + - "Makefile" + - "Utils/expected_package_diff.patch" + +jobs: + check: + name: Check Package.swift Diff + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Check Package.swift Diff + run: make check-package-diff diff --git a/.gitignore b/.gitignore index cb4b4598ee6..2fd2fc5c3ce 100644 --- a/.gitignore +++ b/.gitignore @@ -104,3 +104,5 @@ Sentry-Dynamic-WithARM64e.xcframework* SentrySwiftUI.xcframework* Sentry-WithoutUIKitOrAppKit.xcframework* Sentry-WithoutUIKitOrAppKit-WithARM64e.xcframework* + +current_package_diff.patch diff --git a/Makefile b/Makefile index 8c33656a39a..f5a51a5a658 100644 --- a/Makefile +++ b/Makefile @@ -183,3 +183,18 @@ xcode-ci: xcodegen --spec Samples/watchOS-Swift/watchOS-Swift.yml xcodegen --spec TestSamples/SwiftUITestSample/SwiftUITestSample.yml xcodegen --spec TestSamples/SwiftUICrashTest/SwiftUICrashTest.yml + +.PHONY: check-package-diff update-package-diff +# Diff will return an error if the files are different, so we need to ignore it with `|| true`. +check-package-diff: + diff Package.swift Package@swift-5.9.swift > current_package_diff.patch || true + @if diff ./Utils/expected_package_diff.patch current_package_diff.patch > /dev/null 2>&1; then \ + echo "--> Package diff check passed - no changes detected"; \ + else \ + echo "--> Package diff check failed - changes detected! Make sure to run \"make update-package-diff\" to update the expected diff."; \ + exit 1; \ + fi + +# Diff will return an error if the files are different, so we need to ignore it with `|| true`. +update-package-diff: + diff Package.swift Package@swift-5.9.swift > ./Utils/expected_package_diff.patch || true diff --git a/Utils/expected_package_diff.patch b/Utils/expected_package_diff.patch new file mode 100644 index 00000000000..d41c2c2886b --- /dev/null +++ b/Utils/expected_package_diff.patch @@ -0,0 +1,25 @@ +1,2c1,5 +< // swift-tools-version:5.3 +< #if canImport(Darwin) +--- +> // swift-tools-version:5.9 +> // This Package.swift for Swift 5.9 (and newer) fixes an issue on Xcode 26 when linking `SentrySwiftUI`. +> // Don't remove this comment. +> +> #if canImport(Darwin) +15d17 +< .library(name: "Sentry-Dynamic-WithARM64e", targets: ["Sentry-Dynamic-WithARM64e"]), +39a42,44 +> swiftSettings: [ +> .interoperabilityMode(.Cxx, .when(platforms: [.visionOS])) +> ], +53c58 +< if let env = env, String(cString: env, encoding: .utf8) == "1" { +--- +> if let env = env, String(cString: env) == "1" { +84a90 +> publicHeadersPath: "", +100c106 +< platforms: [.iOS(.v11), .macOS(.v10_13), .tvOS(.v11), .watchOS(.v4)], +--- +> platforms: [.iOS(.v11), .macOS(.v10_13), .tvOS(.v11), .watchOS(.v4), .visionOS(.v1)],