Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reimplement a small bit of ObjC in Swift.
This prevents us from needing an entirely separate module for just one ObjC file.
- Loading branch information
Showing
14 changed files
with
68 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
10 changes: 0 additions & 10 deletions
10
Sources/Remote Logging/Crash Logging/ObjC/SentryClient+Shim.h
This file was deleted.
Oops, something went wrong.
40 changes: 0 additions & 40 deletions
40
Sources/Remote Logging/Crash Logging/ObjC/SentryClient+Shim.m
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
Sources/Remote Logging/Crash Logging/RemoteLoggingExports.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Foundation | ||
|
||
#if SWIFT_PACKAGE | ||
@_exported import AutomatticTracksModel | ||
@_exported import AutomatticTracksModelObjC | ||
#endif |
53 changes: 53 additions & 0 deletions
53
Sources/Remote Logging/Crash Logging/SentryClient+Shim.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// | ||
// SentryClient+Shim.swift | ||
// AutomatticTracksiOS | ||
// | ||
// Created by BJ Homer on 7/27/21. | ||
// | ||
|
||
import Foundation | ||
import Sentry | ||
|
||
|
||
@objc | ||
private protocol SentryClient_InternalMethods { | ||
@objc(prepareEvent:withScope:alwaysAttachStacktrace:isCrashEvent:) | ||
func prepareEvent(_ e: Sentry.Event, | ||
withScope: Sentry.Scope, | ||
alwaysAttachStacktrace: Bool, | ||
isCrashEvent:Bool | ||
) -> Sentry.Event? | ||
} | ||
|
||
extension Sentry.Client { | ||
/* | ||
* A wrapper around a private method in `SentryClient`. If it's unavailable (say the library | ||
changes), | ||
* the worst that should happen is that the stack trace is no longer available on events sent | ||
manually using this method. | ||
* | ||
* We can remove this once the Sentry SDK allows for capturing events and being notified once | ||
they're delivered. | ||
* ref: https://github.com/getsentry/sentry-cocoa/issues/660 | ||
*/ | ||
@objc(addStackTraceToEvent:forClient:) | ||
func addStackTrace(to event: Sentry.Event, for client: Sentry.Client) -> Sentry.Event { | ||
|
||
let sel = #selector(SentryClient_InternalMethods.prepareEvent(_:withScope:alwaysAttachStacktrace:isCrashEvent:)) | ||
|
||
if !client.responds(to: sel) { | ||
return event | ||
} | ||
|
||
let scope = SentrySDK.currentHub().getScope() | ||
guard let eventWithStackTrace = (self as AnyObject).prepareEvent(event, withScope: scope, alwaysAttachStacktrace: true, isCrashEvent: false) | ||
else { | ||
return event | ||
} | ||
|
||
if let stackTrace = eventWithStackTrace.threads?.first?.stacktrace { | ||
eventWithStackTrace.stacktrace = stackTrace | ||
} | ||
return event | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 0 additions & 7 deletions
7
Sources/Remote Logging/Crash Logging/Swift/RemoteLoggingExports.swift
This file was deleted.
Oops, something went wrong.
File renamed without changes.