Skip to content
Open
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a72802e
POC: Add `swift-log` package
denrase Sep 25, 2025
7032e87
Merge branch 'main' into denrase/swift-log-sentry-poc
denrase Sep 25, 2025
4b491c8
use trace instead of error in sample app
denrase Sep 25, 2025
21dc2de
add tests, move sample to app with ios > 11
denrase Sep 25, 2025
59117a4
revert changes in sample app
denrase Sep 25, 2025
2fcf8bb
remove unused helper
denrase Sep 25, 2025
467f314
no need for docs for swift-log methods
denrase Sep 25, 2025
00559c2
fix typo
denrase Sep 25, 2025
249759b
no need to map level
denrase Sep 25, 2025
1c0a0d4
fix typo
denrase Sep 25, 2025
39dc722
format package
denrase Sep 25, 2025
3f82bb0
Merge branch 'main' into denrase/swift-log-sentry-poc
denrase Sep 30, 2025
ce69ea1
Rename to SentrySwiftLog
denrase Sep 30, 2025
825e5df
remae target
denrase Sep 30, 2025
7139756
Add changelog
denrase Sep 30, 2025
2408a07
disable lint warning, remove todo
denrase Sep 30, 2025
f9062d6
Exclude from SentryObjc
denrase Sep 30, 2025
f6bc914
test SentrySwiftLog
denrase Sep 30, 2025
fd73f1e
Update prepare-package.swift
denrase Sep 30, 2025
fb07770
Add shared scheme
denrase Oct 1, 2025
befdf40
Merge branch 'main' into denrase/swift-log-sentry-poc
denrase Oct 1, 2025
45c8ed8
fix old target names
denrase Oct 1, 2025
0779263
format
denrase Oct 1, 2025
601a5ae
Merge branch 'main' into denrase/swift-log-sentry-poc
denrase Oct 6, 2025
4e20b63
Move example to iOS-Swift app
denrase Oct 6, 2025
a607ccb
bump depolyment targets for senryswiftlog target
denrase Oct 6, 2025
3d57dc6
add cl entry
denrase Oct 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/actions/prepare-package.swift/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,14 @@ runs:
env:
PACKAGE_FILE: ${{ inputs.package-file }}
run: |
sed -i '' 's/url.*//g' $PACKAGE_FILE
# Remove Sentry binary framework URLs and convert checksums to paths
sed -i '' 's/url: "https:\/\/github\.com\/getsentry\/sentry-cocoa\/releases\/download\/.*"//g' $PACKAGE_FILE
sed -i '' 's/checksum: ".*" \/\/Sentry-Static/path: "Sentry.xcframework.zip"/g' $PACKAGE_FILE
sed -i '' 's/checksum: ".*" \/\/Sentry-Dynamic-WithARM64e/path: "Sentry-Dynamic-WithARM64e.xcframework.zip"/g' $PACKAGE_FILE
sed -i '' 's/checksum: ".*" \/\/Sentry-Dynamic/path: "Sentry-Dynamic.xcframework.zip"/g' $PACKAGE_FILE
sed -i '' 's/checksum: ".*" \/\/Sentry-WithoutUIKitOrAppKit-WithARM64e/path: "Sentry-WithoutUIKitOrAppKit-WithARM64e.xcframework.zip"/g' $PACKAGE_FILE
sed -i '' 's/checksum: ".*" \/\/Sentry-WithoutUIKitOrAppKit/path: "Sentry-WithoutUIKitOrAppKit.xcframework.zip"/g' $PACKAGE_FILE
# Clean up orphaned commas and fix syntax
sed -i '' '/^[[:space:]]*,$/d' $PACKAGE_FILE
sed -i '' 's/name: "Sentry\(-.*\)\?"$/name: "Sentry\1",/g' $PACKAGE_FILE
sed -i '' 's/platforms: \[\.iOS(\.v11), \.macOS(\.v10_13), \.tvOS(\.v11), \.watchOS(\.v4)\]$/platforms: [.iOS(.v11), .macOS(.v10_13), .tvOS(.v11), .watchOS(.v4)],/g' $PACKAGE_FILE
Comment on lines +53 to +56
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this trying to do?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the CI jobs is replacing dependencies with local build artefacts. This broke, as swift-log was added to our Package.swift. This code fixes those issues.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this only happen because of swift-log or should we do the fix in a separate PR?

9 changes: 9 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,15 @@ jobs:
device: "iPhone 15 Pro"
scheme: "SentrySwiftUI"

# iOS 17
- name: iOS 17 SentrySwiftLog
runs-on: macos-14
platform: "iOS"
xcode: "15.4"
test-destination-os: "17.5"
device: "iPhone 15 Pro"
scheme: "SentrySwiftLog"

# tvOS 18
- name: tvOS 18 Sentry
runs-on: macos-15
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Removes `enablePerformanceV2` option and makes this the default. The app start d
### Features

- Add SentryDistribution as Swift Package Manager target (#6149)
- Add `SentrySwiftLog` Integration ([#6286](https://github.com/getsentry/sentry-cocoa/pull/6286))

### Fixes

Expand Down
28 changes: 22 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ var products: [Product] = [
.library(name: "Sentry-WithoutUIKitOrAppKit", targets: ["Sentry-WithoutUIKitOrAppKit", "SentryCppHelper"]),
.library(name: "Sentry-WithoutUIKitOrAppKit-WithARM64e", targets: ["Sentry-WithoutUIKitOrAppKit-WithARM64e", "SentryCppHelper"]),
.library(name: "SentrySwiftUI", targets: ["Sentry", "SentrySwiftUI", "SentryCppHelper"]),
.library(name: "SentryDistribution", targets: ["SentryDistribution"])
.library(name: "SentryDistribution", targets: ["SentryDistribution"]),
.library(name: "SentrySwiftLog", targets: ["Sentry", "SentrySwiftLog"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

m: I don't fully understand why this is another target. Is this only here because swift-log is a new dependency? Shouldn't we add it as a dependency to Sentry instead?

]

var targets: [Target] = [
Expand Down Expand Up @@ -45,21 +46,31 @@ var targets: [Target] = [
url: "https://github.com/getsentry/sentry-cocoa/releases/download/8.56.2/Sentry-WithoutUIKitOrAppKit-WithARM64e.xcframework.zip",
checksum: "0c716f6a6475d8fd6e78b9204c74adffef5c0989f057c5d795989a667ae58047" //Sentry-WithoutUIKitOrAppKit-WithARM64e
),
.target (
.target(
name: "SentrySwiftUI",
dependencies: ["Sentry", "SentryInternal"],
path: "Sources/SentrySwiftUI",
exclude: ["SentryInternal/", "module.modulemap"],
linkerSettings: [
.linkedFramework("Sentry")
]),
]
),
.target(
name: "SentrySwiftLog",
dependencies: ["Sentry", .product(name: "Logging", package: "swift-log")],
path: "Sources/SentrySwiftLog",
linkerSettings: [
.linkedFramework("Sentry")
]
),
.target(
name: "SentryInternal",
path: "Sources/SentrySwiftUI",
sources: [
"SentryInternal/"
],
publicHeadersPath: "SentryInternal/"),
publicHeadersPath: "SentryInternal/"
),
.target(
name: "SentryCppHelper",
dependencies: ["Sentry"],
Expand Down Expand Up @@ -104,7 +115,7 @@ if let env = env, String(cString: env, encoding: .utf8) == "1" {
name: "SentryObjc",
dependencies: ["SentrySwift"],
path: "Sources",
exclude: ["Sentry/SentryDummyPublicEmptyClass.m", "Sentry/SentryDummyPrivateEmptyClass.m", "Swift", "SentrySwiftUI", "Resources", "Configuration", "SentryCppHelper", "SentryDistribution", "SentryDistributionTests"],
exclude: ["Sentry/SentryDummyPublicEmptyClass.m", "Sentry/SentryDummyPrivateEmptyClass.m", "Swift", "SentrySwiftUI", "SentrySwiftLog", "Resources", "Configuration", "SentryCppHelper", "SentryDistribution", "SentryDistributionTests"],
cSettings: [
.headerSearchPath("Sentry/include/HybridPublic"),
.headerSearchPath("Sentry"),
Expand All @@ -114,14 +125,19 @@ if let env = env, String(cString: env, encoding: .utf8) == "1" {
.headerSearchPath("SentryCrash/Installations"),
.headerSearchPath("SentryCrash/Reporting/Filters"),
.headerSearchPath("SentryCrash/Reporting/Filters/Tools"),
.define("SDK_V9")])
.define("SDK_V9")
]
)
])
}

let package = Package(
name: "Sentry",
platforms: [.iOS(.v15), .macOS(.v12), .tvOS(.v15), .watchOS(.v8)],
products: products,
dependencies: [
.package(url: "https://github.com/apple/swift-log", from: "1.6.0")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

h: So I think this is going to be a problem as soon as new swift-log version becomes available. AFAIK the SPM doesn't support peer-dependencies, so if someone uses swift-log with a version not being 1.6.0, while we depend on it, Xcode will not build because it doesn't support the same dependency with different versions like NPM.

So basically this will lock our SDK users into exactly the swift-log version we declare, requiring us to release a new SDK version with every update of swift-log, furthermore requiring users to update the Sentry SDK even though they just want a new version of swift-log. At this point I do not have a proposal how to fix this other than asking the user to "inject" their swift-log version by making it conform to a Sentry-included protocol

],
targets: targets,
cxxLanguageStandard: .cxx14
)
1 change: 1 addition & 0 deletions Samples/iOS-Swift/iOS-Swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ targets:
- target: iOS-SwiftClip
- target: SentrySampleShared/SentrySampleShared
- target: iOS-Swift-ShareExtension
- target: Sentry/SentrySwiftLog
configFiles:
Debug: iOS-Swift.xcconfig
DebugV9: iOS-Swift.xcconfig
Expand Down
16 changes: 15 additions & 1 deletion Samples/iOS-Swift/iOS-Swift/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import SentrySampleShared
import UIKit

import Logging
import SentrySwiftLog

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
private var randomDistributionTimer: Timer?
Expand All @@ -24,11 +27,22 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

SentrySDKWrapper.shared.startSentry()
SampleAppDebugMenu.shared.display()

if #available(iOS 15.0, *) {
metricKit.receiveReports()
}

// Use structured logs with swift-log
LoggingSystem.bootstrap { _ in
return SentryLogHandler(logLevel: .trace)
}
let logger = Logger(label: "io.sentry.iOS-Swift")
logger.trace(
"[iOS-Swift] didFinishLaunchingWithOptions",
metadata: ["foo": "bar"],
source: "iOS"
)

return true
}

Expand Down
1 change: 0 additions & 1 deletion Samples/iOS15-SwiftUI/iOS15-SwiftUI/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ struct ContentView: View {
await captureErrorAsync()
}
}

func captureErrorAsync() async {
let error = NSError(domain: "SampleErrorDomain", code: 1, userInfo: [NSLocalizedDescriptionKey: "Object does not exist"])
SentrySDK.capture(error: error)
Expand Down
Loading
Loading