|
| 1 | +// swift-tools-version:6.2 |
| 2 | + |
| 3 | +#if canImport(Darwin) |
| 4 | +import Darwin.C |
| 5 | +#elseif canImport(Glibc) |
| 6 | +import Glibc |
| 7 | +#elseif canImport(MSVCRT) |
| 8 | +import MSVCRT |
| 9 | +#endif |
| 10 | + |
| 11 | +import PackageDescription |
| 12 | + |
| 13 | +var products: [Product] = [ |
| 14 | + .library(name: "Sentry", targets: ["Sentry", "SentryCppHelper"]), |
| 15 | + .library(name: "Sentry-Dynamic", targets: ["Sentry-Dynamic"]), |
| 16 | + .library(name: "Sentry-Dynamic-WithARM64e", targets: ["Sentry-Dynamic-WithARM64e"]), |
| 17 | + .library(name: "Sentry-WithoutUIKitOrAppKit", targets: ["Sentry-WithoutUIKitOrAppKit", "SentryCppHelper"]), |
| 18 | + .library(name: "Sentry-WithoutUIKitOrAppKit-WithARM64e", targets: ["Sentry-WithoutUIKitOrAppKit-WithARM64e", "SentryCppHelper"]), |
| 19 | + .library(name: "SentrySwiftUI", targets: ["Sentry", "SentrySwiftUI", "SentryCppHelper"]), |
| 20 | + .library(name: "SentryDistribution", targets: ["SentryDistribution"]) |
| 21 | +] |
| 22 | + |
| 23 | +var targets: [Target] = [ |
| 24 | + .binaryTarget( |
| 25 | + name: "Sentry", |
| 26 | + url: "https://github.com/getsentry/sentry-cocoa/releases/download/9.10.0/Sentry.xcframework.zip", |
| 27 | + checksum: "166692d02bb59fe9a158fe59b16e122fda40dddf6deaabed65a9e4b240f84c9b" //Sentry-Static |
| 28 | + ), |
| 29 | + .binaryTarget( |
| 30 | + name: "Sentry-Dynamic", |
| 31 | + url: "https://github.com/getsentry/sentry-cocoa/releases/download/9.10.0/Sentry-Dynamic.xcframework.zip", |
| 32 | + checksum: "1dd70512f3b5af6c74f1b8f11279531900173fb638d7d541320a7cbc00ed06bc" //Sentry-Dynamic |
| 33 | + ), |
| 34 | + .binaryTarget( |
| 35 | + name: "Sentry-Dynamic-WithARM64e", |
| 36 | + url: "https://github.com/getsentry/sentry-cocoa/releases/download/9.10.0/Sentry-Dynamic-WithARM64e.xcframework.zip", |
| 37 | + checksum: "7d981d7ad0686c5fd68c791b721820a360285dc711e2b23e79114a6a62d799a6" //Sentry-Dynamic-WithARM64e |
| 38 | + ), |
| 39 | + .binaryTarget( |
| 40 | + name: "Sentry-WithoutUIKitOrAppKit", |
| 41 | + url: "https://github.com/getsentry/sentry-cocoa/releases/download/9.10.0/Sentry-WithoutUIKitOrAppKit.xcframework.zip", |
| 42 | + checksum: "8c70de11731587e2c615089464820b67d8f0103b5e019d81a16b0cac31e33e65" //Sentry-WithoutUIKitOrAppKit |
| 43 | + ), |
| 44 | + .binaryTarget( |
| 45 | + name: "Sentry-WithoutUIKitOrAppKit-WithARM64e", |
| 46 | + url: "https://github.com/getsentry/sentry-cocoa/releases/download/9.10.0/Sentry-WithoutUIKitOrAppKit-WithARM64e.xcframework.zip", |
| 47 | + checksum: "abd3b0836ce6637cbc274e7d979b345ec3c2f46857d5412e78c1d2f0fe3397b0" //Sentry-WithoutUIKitOrAppKit-WithARM64e |
| 48 | + ), |
| 49 | + .target( |
| 50 | + name: "SentrySwiftUI", |
| 51 | + dependencies: ["Sentry"], |
| 52 | + path: "Sources/SentrySwiftUI", |
| 53 | + exclude: ["module.modulemap"], |
| 54 | + linkerSettings: [ |
| 55 | + .linkedFramework("Sentry") |
| 56 | + ] |
| 57 | + ), |
| 58 | + .target( |
| 59 | + name: "SentryCppHelper", |
| 60 | + path: "Sources/SentryCppHelper", |
| 61 | + linkerSettings: [ |
| 62 | + .linkedLibrary("c++") |
| 63 | + ] |
| 64 | + ), |
| 65 | + .target(name: "SentryDistribution", path: "Sources/SentryDistribution"), |
| 66 | + .testTarget(name: "SentryDistributionTests", dependencies: ["SentryDistribution"], path: "Sources/SentryDistributionTests") |
| 67 | +] |
| 68 | + |
| 69 | +// Targets required to support compile-from-source builds via SPM. |
| 70 | +products.append(.library(name: "SentrySPM", targets: ["SentryObjCInternal"])) |
| 71 | +targets += [ |
| 72 | + // At least one source file is required, therefore we use a dummy class to satisfy the SPM build system |
| 73 | + .target( |
| 74 | + name: "SentryHeaders", |
| 75 | + path: "Sources/Sentry", |
| 76 | + sources: ["SentryDummyPublicEmptyClass.m"], |
| 77 | + publicHeadersPath: "Public" |
| 78 | + ), |
| 79 | + .target( |
| 80 | + name: "_SentryPrivate", |
| 81 | + dependencies: ["SentryHeaders"], |
| 82 | + path: "Sources/Sentry", |
| 83 | + sources: ["SentryDummyPrivateEmptyClass.m"], |
| 84 | + publicHeadersPath: "include"), |
| 85 | + .target( |
| 86 | + name: "SentrySwift", |
| 87 | + dependencies: ["_SentryPrivate", "SentryHeaders"], |
| 88 | + path: "Sources/Swift", |
| 89 | + swiftSettings: [ |
| 90 | + .unsafeFlags(["-enable-library-evolution"]), |
| 91 | + .define("SENTRY_NO_UI_FRAMEWORK", .when(traits: ["NoUIFramework"])) |
| 92 | + ]), |
| 93 | + |
| 94 | + // SentryObjCInternal compiles all ObjC/C sources from the repo. Named "Internal" |
| 95 | + // to reserve "SentryObjC" for a future public Objective-C wrapper around the SDK. |
| 96 | + .target( |
| 97 | + name: "SentryObjCInternal", |
| 98 | + dependencies: ["SentrySwift"], |
| 99 | + path: "Sources", |
| 100 | + exclude: ["Sentry/SentryDummyPublicEmptyClass.m", "Sentry/SentryDummyPrivateEmptyClass.m", "Swift", "SentrySwiftUI", "Resources", "Configuration", "SentryCppHelper", "SentryDistribution", "SentryDistributionTests"], |
| 101 | + cSettings: [ |
| 102 | + .headerSearchPath("Sentry"), |
| 103 | + .headerSearchPath("SentryCrash/Recording"), |
| 104 | + .headerSearchPath("SentryCrash/Recording/Monitors"), |
| 105 | + .headerSearchPath("SentryCrash/Recording/Tools"), |
| 106 | + .headerSearchPath("SentryCrash/Installations"), |
| 107 | + .headerSearchPath("SentryCrash/Reporting/Filters"), |
| 108 | + .headerSearchPath("SentryCrash/Reporting/Filters/Tools"), |
| 109 | + .define("SENTRY_NO_UI_FRAMEWORK", to: "1", .when(traits: ["NoUIFramework"])) |
| 110 | + ]) |
| 111 | +] |
| 112 | + |
| 113 | +let package = Package( |
| 114 | + name: "Sentry", |
| 115 | + platforms: [.iOS(.v15), .macOS(.v10_14), .tvOS(.v15), .watchOS(.v8), .visionOS(.v1)], |
| 116 | + products: products, |
| 117 | + traits: [ |
| 118 | + .init(name: "NoUIFramework", description: "Build without UIKit/AppKit framework linkage. Use for command-line tools or contexts where UI frameworks are unavailable.") |
| 119 | + ], |
| 120 | + targets: targets, |
| 121 | + swiftLanguageModes: [.v5], |
| 122 | + cxxLanguageStandard: .cxx14 |
| 123 | +) |
0 commit comments