Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change shared instead of shared() in Swift #532

Merged
merged 2 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ import KSCrash
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

let installation = CrashInstallationStandard.shared()
let installation = CrashInstallationStandard.shared
installation.url = URL(string: "http://put.your.url.here")!

// Optional: Add an alert confirmation (recommended for email installation)
Expand All @@ -154,7 +154,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
##### Email Installation

```swift
let installation = CrashInstallationEmail.shared()
let installation = CrashInstallationEmail.shared
installation.recipients = ["some@email.address"] // Specify recipients for email reports
// Optional: Send Apple-style reports instead of JSON
installation.setReportStyle(.apple, useDefaultFilenameFormat: true)
Expand All @@ -163,7 +163,7 @@ installation.setReportStyle(.apple, useDefaultFilenameFormat: true)
##### Console Installation

```swift
let installation = CrashInstallationConsole.shared()
let installation = CrashInstallationConsole.shared
installation.printAppleFormat = true // Print crash reports in Apple format for testing
```

Expand Down
2 changes: 1 addition & 1 deletion Samples/Common/Sources/LibraryBridge/RecordingSample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ import KSCrashRecording
public class RecordingSample {
public static func simpleInstall() {
let config = KSCrashConfiguration()
KSCrash.shared().install(with: config)
KSCrash.shared.install(with: config)
}
}
8 changes: 4 additions & 4 deletions Samples/Common/Sources/LibraryBridge/ReportingSample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import KSCrashSinks

public class ReportingSample {
public static func logToConsole() {
KSCrash.shared().sink = CrashReportSinkConsole.filter().defaultCrashReportFilterSet()
KSCrash.shared().sendAllReports { reports, isSuccess, error in
KSCrash.shared.sink = CrashReportSinkConsole.filter().defaultCrashReportFilterSet()
KSCrash.shared.sendAllReports { reports, isSuccess, error in
if isSuccess, let reports {
print("Logged \(reports.count) reports")
for (idx, report) in reports.enumerated() {
Expand All @@ -54,11 +54,11 @@ public class ReportingSample {
}

public static func sampleLogToConsole() {
KSCrash.shared().sink = CrashReportFilterPipeline(filtersArray: [
KSCrash.shared.sink = CrashReportFilterPipeline(filtersArray: [
SampleFilter(),
SampleSink(),
])
KSCrash.shared().sendAllReports()
KSCrash.shared.sendAllReports()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ NS_SWIFT_NAME(CrashInstallationConsole)

@property(nonatomic, readwrite) BOOL printAppleFormat;

+ (instancetype)sharedInstance NS_SWIFT_NAME(shared());
@property(class, readonly) KSCrashInstallationConsole *sharedInstance NS_SWIFT_NAME(shared);

@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ typedef NS_ENUM(NSUInteger, KSCrashEmailReportStyle) {
NS_SWIFT_NAME(CrashInstallationEmail)
@interface KSCrashInstallationEmail : KSCrashInstallation

@property(class, readonly) KSCrashInstallationEmail *sharedInstance NS_SWIFT_NAME(shared);

/** List of email addresses to send to (mandatory) */
@property(nonatomic, readwrite, copy) NSArray<NSString *> *recipients;

Expand Down Expand Up @@ -78,8 +80,6 @@ NS_SWIFT_NAME(CrashInstallationEmail)
*/
- (void)setReportStyle:(KSCrashEmailReportStyle)reportStyle useDefaultFilenameFormat:(BOOL)useDefaultFilenameFormat;

+ (instancetype)sharedInstance NS_SWIFT_NAME(shared());

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ NS_ASSUME_NONNULL_BEGIN
NS_SWIFT_NAME(CrashInstallationStandard)
@interface KSCrashInstallationStandard : KSCrashInstallation

@property(class, readonly) KSCrashInstallationStandard *sharedInstance NS_SWIFT_NAME(shared);

/** The URL to connect to. */
@property(nonatomic, readwrite, strong) NSURL *url;

+ (instancetype)sharedInstance NS_SWIFT_NAME(shared());

@end

NS_ASSUME_NONNULL_END
12 changes: 6 additions & 6 deletions Sources/KSCrashRecording/include/KSCrash.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;

/** Get the singleton instance of the crash reporter.
*
* @note To specify a custom base direcory for KSCrash use `setBasePath:` method.
*/
@property(class, readonly) KSCrash *sharedInstance NS_SWIFT_NAME(shared);

/**
* Specifies a custom base path for KSCrash installation.
* By default a "KSCrash" directory inside the default cache directory is used.
Expand All @@ -121,12 +127,6 @@ NS_ASSUME_NONNULL_BEGIN
*/
+ (void)setBasePath:(nullable NSString *)basePath;

/** Get the singleton instance of the crash reporter.
*
* @note To specify a custom base direcory for KSCrash use `setBasePath:` method.
*/
+ (instancetype)sharedInstance NS_SWIFT_NAME(shared());

/** Install the crash reporter.
* The reporter will record crashes, but will not send any crash reports unless
* sink is set.
Expand Down
2 changes: 1 addition & 1 deletion Sources/KSCrashRecording/include/KSCrashAppStateTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ NS_SWIFT_NAME(AppStateTracker)
* The shared tracker. Use this unless you absolutely need your own tracker,
* at which point you can simply allocate your own.
*/
+ (instancetype)sharedInstance NS_SWIFT_NAME(shared());
@property(class, readonly) KSCrashAppStateTracker *sharedInstance NS_SWIFT_NAME(shared);

- (instancetype)initWithNotificationCenter:(NSNotificationCenter *)notificationCenter NS_DESIGNATED_INITIALIZER;

Expand Down
Loading