|
| 1 | +// swift-tools-version:5.9 |
| 2 | +// This Package.swift for Swift 5.9 (and newer) fixes an issue on Xcode 26 when linking `SentrySwiftUI`. |
| 3 | +// Don't remove this comment. |
| 4 | + |
| 5 | +#if canImport(Darwin) |
| 6 | +import Darwin.C |
| 7 | +#elseif canImport(Glibc) |
| 8 | +import Glibc |
| 9 | +#elseif canImport(MSVCRT) |
| 10 | +import MSVCRT |
| 11 | +#endif |
| 12 | + |
| 13 | +import PackageDescription |
| 14 | + |
| 15 | +var products: [Product] = [ |
| 16 | + .library(name: "Sentry", targets: ["Sentry"]), |
| 17 | + .library(name: "Sentry-Dynamic", targets: ["Sentry-Dynamic"]), |
| 18 | + .library(name: "SentrySwiftUI", targets: ["Sentry", "SentrySwiftUI"]) |
| 19 | +] |
| 20 | + |
| 21 | +var targets: [Target] = [ |
| 22 | + .binaryTarget( |
| 23 | + name: "Sentry", |
| 24 | + url: "https://github.com/getsentry/sentry-cocoa/releases/download/8.54.0/Sentry.xcframework.zip", |
| 25 | + checksum: "f0f4b5582f7fef029ddedd22b6b9894a6d2d31ea9c7b52a2133b1ec7c4cff206" //Sentry-Static |
| 26 | + ), |
| 27 | + .binaryTarget( |
| 28 | + name: "Sentry-Dynamic", |
| 29 | + url: "https://github.com/getsentry/sentry-cocoa/releases/download/8.54.0/Sentry-Dynamic.xcframework.zip", |
| 30 | + checksum: "2cd3ee298133ed3a6d3b98f3b040e5c67b752887e67647ae671f450ecfd3facf" //Sentry-Dynamic |
| 31 | + ), |
| 32 | + .target ( |
| 33 | + name: "SentrySwiftUI", |
| 34 | + dependencies: ["Sentry", "SentryInternal"], |
| 35 | + path: "Sources/SentrySwiftUI", |
| 36 | + exclude: ["SentryInternal/", "module.modulemap"], |
| 37 | + swiftSettings: [ |
| 38 | + .interoperabilityMode(.Cxx, .when(platforms: [.visionOS])) |
| 39 | + ], |
| 40 | + linkerSettings: [ |
| 41 | + .linkedFramework("Sentry") |
| 42 | + ]), |
| 43 | + .target( |
| 44 | + name: "SentryInternal", |
| 45 | + path: "Sources/SentrySwiftUI", |
| 46 | + sources: [ |
| 47 | + "SentryInternal/" |
| 48 | + ], |
| 49 | + publicHeadersPath: "SentryInternal/") |
| 50 | +] |
| 51 | + |
| 52 | +let env = getenv("EXPERIMENTAL_SPM_BUILDS") |
| 53 | +if let env = env, String(cString: env) == "1" { |
| 54 | + products.append(.library(name: "SentrySPM", type: .dynamic, targets: ["SentryObjc"])) |
| 55 | + targets.append(contentsOf: [ |
| 56 | + // At least one source file is required, therefore we use a dummy class to satisfy the SPM build system |
| 57 | + .target( |
| 58 | + name: "SentryHeaders", |
| 59 | + path: "Sources/Sentry", |
| 60 | + sources: ["SentryDummyPublicEmptyClass.m"], |
| 61 | + publicHeadersPath: "Public" |
| 62 | + ), |
| 63 | + .target( |
| 64 | + name: "_SentryPrivate", |
| 65 | + dependencies: ["SentryHeaders"], |
| 66 | + path: "Sources/Sentry", |
| 67 | + sources: ["SentryDummyPrivateEmptyClass.m"], |
| 68 | + publicHeadersPath: "include", |
| 69 | + cSettings: [.headerSearchPath("include/HybridPublic")]), |
| 70 | + .target( |
| 71 | + name: "SentrySwift", |
| 72 | + dependencies: ["_SentryPrivate", "SentryHeaders"], |
| 73 | + path: "Sources/Swift", |
| 74 | + swiftSettings: [ |
| 75 | + .unsafeFlags(["-enable-library-evolution"]), |
| 76 | + // Some API breaking changes are necessary for the framework to compile with SPM, we’ll ship |
| 77 | + // those in V9. |
| 78 | + .define("SDK_V9") |
| 79 | + ]), |
| 80 | + .target( |
| 81 | + name: "SentryObjc", |
| 82 | + dependencies: ["SentrySwift"], |
| 83 | + path: "Sources", |
| 84 | + exclude: ["Sentry/SentryDummyPublicEmptyClass.m", "Sentry/SentryDummyPrivateEmptyClass.m", "Swift", "SentrySwiftUI", "Resources", "Configuration"], |
| 85 | + publicHeadersPath: "", |
| 86 | + cSettings: [ |
| 87 | + .headerSearchPath("Sentry/include/HybridPublic"), |
| 88 | + .headerSearchPath("Sentry"), |
| 89 | + .headerSearchPath("SentryCrash/Recording"), |
| 90 | + .headerSearchPath("SentryCrash/Recording/Monitors"), |
| 91 | + .headerSearchPath("SentryCrash/Recording/Tools"), |
| 92 | + .headerSearchPath("SentryCrash/Installations"), |
| 93 | + .headerSearchPath("SentryCrash/Reporting/Filters"), |
| 94 | + .headerSearchPath("SentryCrash/Reporting/Filters/Tools"), |
| 95 | + .define("SDK_V9")]) |
| 96 | + ]) |
| 97 | +} |
| 98 | + |
| 99 | +let package = Package( |
| 100 | + name: "Sentry", |
| 101 | + platforms: [.iOS(.v11), .macOS(.v10_13), .tvOS(.v11), .watchOS(.v4), .visionOS(.v1)], |
| 102 | + products: products, |
| 103 | + targets: targets, |
| 104 | + cxxLanguageStandard: .cxx14 |
| 105 | +) |
0 commit comments