From d5ce74ca67049000ea471737f4f34480242b4e40 Mon Sep 17 00:00:00 2001 From: Dhiogo Brustolin Date: Thu, 15 Dec 2022 13:27:00 -0300 Subject: [PATCH 1/4] fix: Screenshot crashes when application delegate has no window. (#2538) Add a check to ensure application delegate has window --- CHANGELOG.md | 6 ++ Sentry.xcodeproj/project.pbxproj | 10 +++ .../xcshareddata/xcschemes/Sentry.xcscheme | 6 ++ Sources/Sentry/SentryUIApplication.m | 38 +++++++--- Sources/Sentry/include/SentryUIApplication.h | 10 +++ Tests/SentryTests/MockUIScene.h | 16 +++++ Tests/SentryTests/MockUIScene.m | 16 +++++ .../SentryTests/SentryTests-Bridging-Header.h | 1 + .../SentryUIApplicationTests.swift | 72 +++++++++++++++++++ 9 files changed, 164 insertions(+), 11 deletions(-) create mode 100644 Tests/SentryTests/MockUIScene.h create mode 100644 Tests/SentryTests/MockUIScene.m create mode 100644 Tests/SentryTests/SentryUIApplicationTests.swift diff --git a/CHANGELOG.md b/CHANGELOG.md index d1d370d8f3a..fba2a3c6eb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Fixes + +- Screenshot crashes when application delegate has no window (#2538) + ## 7.31.3 ### Fixes diff --git a/Sentry.xcodeproj/project.pbxproj b/Sentry.xcodeproj/project.pbxproj index 0292e4e6147..ad9c8313883 100644 --- a/Sentry.xcodeproj/project.pbxproj +++ b/Sentry.xcodeproj/project.pbxproj @@ -725,6 +725,8 @@ D8B76B0828081461000A58C4 /* TestSentryScreenShot.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8B76B0728081461000A58C4 /* TestSentryScreenShot.swift */; }; D8C67E9B28000E24007E326E /* SentryUIApplication.h in Headers */ = {isa = PBXBuildFile; fileRef = D8C67E9928000E23007E326E /* SentryUIApplication.h */; }; D8C67E9C28000E24007E326E /* SentryScreenshot.h in Headers */ = {isa = PBXBuildFile; fileRef = D8C67E9A28000E23007E326E /* SentryScreenshot.h */; }; + D8CB742B294B1DD000A5F964 /* SentryUIApplicationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8CB742A294B1DD000A5F964 /* SentryUIApplicationTests.swift */; }; + D8CB742E294B294B00A5F964 /* MockUIScene.m in Sources */ = {isa = PBXBuildFile; fileRef = D8CB742D294B294B00A5F964 /* MockUIScene.m */; }; D8CE69BC277E39C700C6EC5C /* SentryFileIOTrackingIntegrationObjCTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D8CE69BB277E39C700C6EC5C /* SentryFileIOTrackingIntegrationObjCTests.m */; }; D8F6A2472885512100320515 /* SentryPredicateDescriptor.m in Sources */ = {isa = PBXBuildFile; fileRef = D8F6A2452885512100320515 /* SentryPredicateDescriptor.m */; }; D8F6A24B2885515C00320515 /* SentryPredicateDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = D8F6A24A2885515B00320515 /* SentryPredicateDescriptor.h */; }; @@ -1527,6 +1529,9 @@ D8B76B0728081461000A58C4 /* TestSentryScreenShot.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestSentryScreenShot.swift; sourceTree = ""; }; D8C67E9928000E23007E326E /* SentryUIApplication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentryUIApplication.h; path = include/SentryUIApplication.h; sourceTree = ""; }; D8C67E9A28000E23007E326E /* SentryScreenshot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentryScreenshot.h; path = include/SentryScreenshot.h; sourceTree = ""; }; + D8CB742A294B1DD000A5F964 /* SentryUIApplicationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryUIApplicationTests.swift; sourceTree = ""; }; + D8CB742C294B294B00A5F964 /* MockUIScene.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MockUIScene.h; sourceTree = ""; }; + D8CB742D294B294B00A5F964 /* MockUIScene.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MockUIScene.m; sourceTree = ""; }; D8CE69BB277E39C700C6EC5C /* SentryFileIOTrackingIntegrationObjCTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryFileIOTrackingIntegrationObjCTests.m; sourceTree = ""; }; D8F6A2452885512100320515 /* SentryPredicateDescriptor.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryPredicateDescriptor.m; sourceTree = ""; }; D8F6A24A2885515B00320515 /* SentryPredicateDescriptor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentryPredicateDescriptor.h; path = include/SentryPredicateDescriptor.h; sourceTree = ""; }; @@ -2881,6 +2886,9 @@ D81FDF10280EA0080045E0E4 /* SentryScreenShotTests.swift */, D8F6A24C2885534E00320515 /* SentryPredicateDescriptorTests.swift */, 0A5370A028A3EC2400B2DCDE /* SentryViewHierarchyTests.swift */, + D8CB742A294B1DD000A5F964 /* SentryUIApplicationTests.swift */, + D8CB742C294B294B00A5F964 /* MockUIScene.h */, + D8CB742D294B294B00A5F964 /* MockUIScene.m */, ); name = Tools; sourceTree = ""; @@ -3775,6 +3783,7 @@ 7B5CAF7E27F5AD3500ED0DB6 /* TestNSURLRequestBuilder.m in Sources */, 8EAC7FF8265C8910005B44E5 /* SentryTracerTests.swift in Sources */, 0A1B497328E597DD00D7BFA3 /* TestLogOutput.swift in Sources */, + D8CB742E294B294B00A5F964 /* MockUIScene.m in Sources */, 7BA61CBD247BC6B900C130A8 /* TestSentryCrashBinaryImageProvider.swift in Sources */, 7BFA69F627E0840400233199 /* SentryANRTrackingIntegrationTests.swift in Sources */, 7BBD18B62451807600427C76 /* SentryDefaultRateLimitsTests.swift in Sources */, @@ -3787,6 +3796,7 @@ 7BF9EF7A2722B58900B5BBEF /* SentrySubClassFinderTests.swift in Sources */, 7B59398224AB47650003AAD2 /* SentrySessionTrackerTests.swift in Sources */, 7B05A61824A4D14A00EF211D /* SentrySessionGeneratorTests.swift in Sources */, + D8CB742B294B1DD000A5F964 /* SentryUIApplicationTests.swift in Sources */, 63FE720920DA66EC00CDBAE8 /* XCTestCase+SentryCrash.m in Sources */, D8918B222849FA6D00701F9A /* SentrySDKIntegrationTestsBase.swift in Sources */, 7B85BD8E24C5C3A6000A4225 /* SentryFileManagerTestExtension.swift in Sources */, diff --git a/Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme b/Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme index 5bb51dfcfce..e5d4fe47a07 100644 --- a/Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme +++ b/Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme @@ -85,6 +85,12 @@ + + + + diff --git a/Sources/Sentry/SentryUIApplication.m b/Sources/Sentry/SentryUIApplication.m index 08ed0ac3a10..b39d741a7ea 100644 --- a/Sources/Sentry/SentryUIApplication.m +++ b/Sources/Sentry/SentryUIApplication.m @@ -12,27 +12,43 @@ - (UIApplication *)sharedApplication return [UIApplication performSelector:@selector(sharedApplication)]; } +- (nullable id)getApplicationDelegate:(UIApplication *)application +{ + return application.delegate; +} + +- (NSArray *)getApplicationConnectedScenes:(UIApplication *)application + API_AVAILABLE(ios(13.0), tvos(13.0)) +{ + if (application && [application respondsToSelector:@selector(connectedScenes)]) { + return [application.connectedScenes allObjects]; + } + + return @[]; +} + - (NSArray *)windows { UIApplication *app = [self sharedApplication]; - if (app == nil) - return nil; - - NSMutableArray *result = [NSMutableArray new]; + NSMutableArray *result = [NSMutableArray array]; if (@available(iOS 13.0, tvOS 13.0, *)) { - if ([app respondsToSelector:@selector(connectedScenes)]) { - for (UIScene *scene in app.connectedScenes) { - if (scene.activationState == UISceneActivationStateForegroundActive - && scene.delegate && [scene.delegate respondsToSelector:@selector(window)]) { - [result addObject:[scene.delegate performSelector:@selector(window)]]; + NSArray *scenes = [self getApplicationConnectedScenes:app]; + for (UIScene *scene in scenes) { + if (scene.activationState == UISceneActivationStateForegroundActive && scene.delegate && + [scene.delegate respondsToSelector:@selector(window)]) { + id window = [scene.delegate performSelector:@selector(window)]; + if (window) { + [result addObject:window]; } } } } - if ([app.delegate respondsToSelector:@selector(window)]) { - [result addObject:app.delegate.window]; + id appDelegate = [self getApplicationDelegate:app]; + + if ([appDelegate respondsToSelector:@selector(window)] && appDelegate.window != nil) { + [result addObject:appDelegate.window]; } return result; diff --git a/Sources/Sentry/include/SentryUIApplication.h b/Sources/Sentry/include/SentryUIApplication.h index 2195d220243..f32d18ed4ba 100644 --- a/Sources/Sentry/include/SentryUIApplication.h +++ b/Sources/Sentry/include/SentryUIApplication.h @@ -20,6 +20,16 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nonatomic, readonly, nullable) NSArray *windows; +/** + * Retrieves the application delegate for given UIApplication + */ +- (nullable id)getApplicationDelegate:(UIApplication *)application; + +/** + * Retrieves connected scenes for given UIApplication + */ +- (NSArray *)getApplicationConnectedScenes:(UIApplication *)application + API_AVAILABLE(ios(13.0), tvos(13.0)); @end NS_ASSUME_NONNULL_END diff --git a/Tests/SentryTests/MockUIScene.h b/Tests/SentryTests/MockUIScene.h new file mode 100644 index 00000000000..455317fe675 --- /dev/null +++ b/Tests/SentryTests/MockUIScene.h @@ -0,0 +1,16 @@ +#import "SentryDefines.h" + +#if SENTRY_HAS_UIKIT +# import + +NS_ASSUME_NONNULL_BEGIN + +API_AVAILABLE(ios(13.0)) +@interface MockUIScene : UIScene + +- (instancetype)init; + +@end + +NS_ASSUME_NONNULL_END +#endif diff --git a/Tests/SentryTests/MockUIScene.m b/Tests/SentryTests/MockUIScene.m new file mode 100644 index 00000000000..a3c5a6a62c2 --- /dev/null +++ b/Tests/SentryTests/MockUIScene.m @@ -0,0 +1,16 @@ +#import "MockUIScene.h" +#if SENTRY_HAS_UIKIT +@implementation MockUIScene + +- (instancetype)init +{ + return self; +} + +- (UISceneActivationState)activationState +{ + return UISceneActivationStateForegroundActive; +} + +@end +#endif diff --git a/Tests/SentryTests/SentryTests-Bridging-Header.h b/Tests/SentryTests/SentryTests-Bridging-Header.h index b9c0e8b2309..41ae3e5699c 100644 --- a/Tests/SentryTests/SentryTests-Bridging-Header.h +++ b/Tests/SentryTests/SentryTests-Bridging-Header.h @@ -177,6 +177,7 @@ #import "URLSessionTaskMock.h" #if SENTRY_HAS_UIKIT +# import "MockUIScene.h" # import "SentryUIEventTracker.h" # import "SentryUIEventTrackingIntegration.h" #endif diff --git a/Tests/SentryTests/SentryUIApplicationTests.swift b/Tests/SentryTests/SentryUIApplicationTests.swift new file mode 100644 index 00000000000..3cd73abd278 --- /dev/null +++ b/Tests/SentryTests/SentryUIApplicationTests.swift @@ -0,0 +1,72 @@ +import XCTest + +#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) +class SentryUIApplicationTests: XCTestCase { + + func test_noScene_delegateWithNoWindow() { + let sut = MockSentryUIApplicationTests() + XCTAssertEqual(sut.windows?.count, 0) + } + + func test_delegateWithWindow() { + let sut = MockSentryUIApplicationTests() + let delegate = TestApplicationDelegate() + sut.appDelegate = delegate + sut.appDelegate?.window = UIWindow() + + XCTAssertEqual(sut.windows?.count, 1) + } + + //Somehow this is running under iOS 12 and is breaking the test. Disabling it. + @available(iOS 13.0, tvOS 13.0, *) + func test_applicationWithScenes() { + let sceneDelegate = TestUISceneDelegate() + sceneDelegate.window = UIWindow() + + let scene1 = MockUIScene() + scene1.delegate = sceneDelegate + + let sut = MockSentryUIApplicationTests() + sut.scenes = [scene1] + + XCTAssertEqual(sut.windows?.count, 1) + } + + //Somehow this is running under iOS 12 and is breaking the test. Disabling it. + @available(iOS 13.0, tvOS 13.0, *) + func test_applicationWithScenes_noWindow() { + let sceneDelegate = TestUISceneDelegate() + + let scene1 = MockUIScene() + scene1.delegate = sceneDelegate + + let sut = MockSentryUIApplicationTests() + sut.scenes = [scene1] + + XCTAssertEqual(sut.windows?.count, 0) + } + + private class TestApplicationDelegate: NSObject, UIApplicationDelegate { + var window: UIWindow? + } + + private class TestUISceneDelegate: NSObject, UIWindowSceneDelegate { + var window: UIWindow? + } + + private class MockSentryUIApplicationTests: SentryUIApplication { + weak var appDelegate: TestApplicationDelegate? + + var scenes: [Any]? + + override func getDelegate(_ application: UIApplication) -> UIApplicationDelegate? { + return appDelegate + } + + @available(iOS 13.0, tvOS 13.0, *) + override func getConnectedScenes(_ application: UIApplication) -> [UIScene] { + return scenes as? [UIScene] ?? super.getConnectedScenes(application) + } + } +} +#endif From 5238cc5f12c2b75027730a54ecf632cf103daf21 Mon Sep 17 00:00:00 2001 From: getsentry-bot Date: Thu, 15 Dec 2022 16:29:07 +0000 Subject: [PATCH 2/4] release: 7.31.4 --- CHANGELOG.md | 2 +- Samples/iOS-Swift/iOS-Swift.xcodeproj/project.pbxproj | 8 ++++---- Sentry.podspec | 2 +- Sources/Configuration/Sentry.xcconfig | 2 +- Sources/Sentry/SentryMeta.m | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fba2a3c6eb7..01be011d55d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## Unreleased +## 7.31.4 ### Fixes diff --git a/Samples/iOS-Swift/iOS-Swift.xcodeproj/project.pbxproj b/Samples/iOS-Swift/iOS-Swift.xcodeproj/project.pbxproj index d25849e195f..56cc9ebfa7f 100644 --- a/Samples/iOS-Swift/iOS-Swift.xcodeproj/project.pbxproj +++ b/Samples/iOS-Swift/iOS-Swift.xcodeproj/project.pbxproj @@ -1096,7 +1096,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 7.31.3; + MARKETING_VERSION = 7.31.4; PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.sample.iOS-Swift"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "match Development io.sentry.sample.iOS-Swift"; @@ -1125,7 +1125,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 7.31.3; + MARKETING_VERSION = 7.31.4; PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.sample.iOS-Swift"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "match AppStore io.sentry.sample.iOS-Swift"; @@ -1770,7 +1770,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 7.31.3; + MARKETING_VERSION = 7.31.4; PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.sample.iOS-Swift.Clip"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "match Development io.sentry.sample.iOS-Swift.Clip"; @@ -1805,7 +1805,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 7.31.3; + MARKETING_VERSION = 7.31.4; PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.sample.iOS-Swift.Clip"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "match AppStore io.sentry.sample.iOS-Swift.Clip"; diff --git a/Sentry.podspec b/Sentry.podspec index f55d1ad1a96..b569cb76c02 100644 --- a/Sentry.podspec +++ b/Sentry.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "Sentry" - s.version = "7.31.3" + s.version = "7.31.4" s.summary = "Sentry client for cocoa" s.homepage = "https://github.com/getsentry/sentry-cocoa" s.license = "mit" diff --git a/Sources/Configuration/Sentry.xcconfig b/Sources/Configuration/Sentry.xcconfig index 3fb0968e8ea..0f33a9a93f1 100644 --- a/Sources/Configuration/Sentry.xcconfig +++ b/Sources/Configuration/Sentry.xcconfig @@ -28,7 +28,7 @@ MACH_O_TYPE = mh_dylib FRAMEWORK_VERSION = A PRODUCT_NAME = Sentry -CURRENT_PROJECT_VERSION = 7.31.3 +CURRENT_PROJECT_VERSION = 7.31.4 INFOPLIST_FILE = Sources/Sentry/Info.plist PRODUCT_BUNDLE_IDENTIFIER = io.sentry.Sentry ALWAYS_SEARCH_USER_PATHS = NO diff --git a/Sources/Sentry/SentryMeta.m b/Sources/Sentry/SentryMeta.m index 578422b3276..839c510a1b9 100644 --- a/Sources/Sentry/SentryMeta.m +++ b/Sources/Sentry/SentryMeta.m @@ -5,7 +5,7 @@ @implementation SentryMeta // Don't remove the static keyword. If you do the compiler adds the constant name to the global // symbol table and it might clash with other constants. When keeping the static keyword the // compiler replaces all occurrences with the value. -static NSString *versionString = @"7.31.3"; +static NSString *versionString = @"7.31.4"; static NSString *sdkName = @"sentry.cocoa"; + (NSString *)versionString From 628acb367786b253bb0acbc83aabb73ada9b68a2 Mon Sep 17 00:00:00 2001 From: Philipp Hofmann Date: Thu, 22 Dec 2022 20:28:10 +0100 Subject: [PATCH 3/4] fix: Crash in SentryOutOfMemoryScopeObserver (#2557) * fix: Crash in SentryOutOfMemoryScopeObserver Writing data to disk when the file handle is broken causes crashes. This is fixed now by capturing an exception. Fixes GH-2548 --- CHANGELOG.md | 6 +++ .../Sentry/SentryOutOfMemoryScopeObserver.m | 25 +++++++----- .../include/SentryOutOfMemoryScopeObserver.h | 8 +++- .../SentryOutOfMemoryScopeObserverTests.swift | 39 ++++++++++++++++++- .../SentryCrashScopeObserverTests.swift | 2 +- Tests/SentryTests/SentryScopeSwiftTests.swift | 2 +- 6 files changed, 67 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01be011d55d..8914989b720 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Fixes + +- Crash in SentryOutOfMemoryScopeObserver (#2557) + ## 7.31.4 ### Fixes diff --git a/Sources/Sentry/SentryOutOfMemoryScopeObserver.m b/Sources/Sentry/SentryOutOfMemoryScopeObserver.m index 713202fc9f5..b260c4bc0f7 100644 --- a/Sources/Sentry/SentryOutOfMemoryScopeObserver.m +++ b/Sources/Sentry/SentryOutOfMemoryScopeObserver.m @@ -75,15 +75,22 @@ - (void)switchFileHandle - (void)store:(NSData *)data { - [self.fileHandle seekToEndOfFile]; - [self.fileHandle writeData:data]; - [self.fileHandle writeData:[@"\n" dataUsingEncoding:NSASCIIStringEncoding]]; - - self.breadcrumbCounter += 1; - - if (self.breadcrumbCounter >= self.maxBreadcrumbs) { - [self switchFileHandle]; - self.breadcrumbCounter = 0; + unsigned long long fileSize; + @try { + fileSize = [self.fileHandle seekToEndOfFile]; + + [self.fileHandle writeData:data]; + [self.fileHandle writeData:[@"\n" dataUsingEncoding:NSASCIIStringEncoding]]; + + self.breadcrumbCounter += 1; + } @catch (NSException *exception) { + SENTRY_LOG_ERROR(@"Error while writing data to end file with size (%llu): %@ ", fileSize, + exception.description); + } @finally { + if (self.breadcrumbCounter >= self.maxBreadcrumbs) { + [self switchFileHandle]; + self.breadcrumbCounter = 0; + } } } diff --git a/Sources/Sentry/include/SentryOutOfMemoryScopeObserver.h b/Sources/Sentry/include/SentryOutOfMemoryScopeObserver.h index da27299c823..eb708ffda0f 100644 --- a/Sources/Sentry/include/SentryOutOfMemoryScopeObserver.h +++ b/Sources/Sentry/include/SentryOutOfMemoryScopeObserver.h @@ -5,8 +5,12 @@ NS_ASSUME_NONNULL_BEGIN -/// This scope observer is used by the Out of Memory integration to write breadcrumbs to disk. -/// The overhead is ~0.015 seconds for 1000 breadcrumbs. +/** + * This scope observer is used by the Out of Memory integration to write breadcrumbs to disk. + * The overhead is ~0.015 seconds for 1000 breadcrumbs. + * This class doesn't need to be thread safe as the scope already calls the scope observers in a + * thread safe manner. + */ @interface SentryOutOfMemoryScopeObserver : NSObject SENTRY_NO_INIT diff --git a/Tests/SentryTests/Integrations/OutOfMemory/SentryOutOfMemoryScopeObserverTests.swift b/Tests/SentryTests/Integrations/OutOfMemory/SentryOutOfMemoryScopeObserverTests.swift index c26e10ad1a4..eb36a5d2fca 100644 --- a/Tests/SentryTests/Integrations/OutOfMemory/SentryOutOfMemoryScopeObserverTests.swift +++ b/Tests/SentryTests/Integrations/OutOfMemory/SentryOutOfMemoryScopeObserverTests.swift @@ -1,17 +1,22 @@ import XCTest class SentryOutOfMemoryScopeObserverTests: XCTestCase { + + private static let dsn = TestConstants.dsnAsString(username: "SentryOutOfMemoryScopeObserverTests") + private class Fixture { let breadcrumb: Breadcrumb let options: Options let fileManager: SentryFileManager let currentDate = TestCurrentDateProvider() + let maxBreadcrumbs = 10 init() { breadcrumb = TestData.crumb breadcrumb.data = nil options = Options() + options.dsn = SentryOutOfMemoryScopeObserverTests.dsn fileManager = try! SentryFileManager(options: options, andCurrentDateProvider: currentDate) } @@ -20,7 +25,7 @@ class SentryOutOfMemoryScopeObserverTests: XCTestCase { } func getSut(fileManager: SentryFileManager) -> SentryOutOfMemoryScopeObserver { - return SentryOutOfMemoryScopeObserver(maxBreadcrumbs: 10, fileManager: fileManager) + return SentryOutOfMemoryScopeObserver(maxBreadcrumbs: maxBreadcrumbs, fileManager: fileManager) } } @@ -85,7 +90,7 @@ class SentryOutOfMemoryScopeObserverTests: XCTestCase { XCTAssertEqual(fileTwoLines.count, 1) // Store 10 more - for _ in 0..<10 { + for _ in 0.. UnsafeMutablePointer?) -> String? { + private func getScopeJson(getField: (SentryCrashScope) -> UnsafeMutablePointer?) -> String? { guard let scopePointer = sentrycrash_scopesync_getScope() else { return nil } diff --git a/Tests/SentryTests/SentryScopeSwiftTests.swift b/Tests/SentryTests/SentryScopeSwiftTests.swift index 263e1615693..a054bef45db 100644 --- a/Tests/SentryTests/SentryScopeSwiftTests.swift +++ b/Tests/SentryTests/SentryScopeSwiftTests.swift @@ -221,7 +221,7 @@ class SentryScopeSwiftTests: XCTestCase { func testUseSpanForClear() { fixture.scope.span = fixture.transaction - fixture.scope.useSpan { (span) in + fixture.scope.useSpan { (_) in self.fixture.scope.span = nil } XCTAssertNil(fixture.scope.span) From cf43eac1aa12017868c257ad3854ad87a5de0758 Mon Sep 17 00:00:00 2001 From: getsentry-bot Date: Thu, 22 Dec 2022 19:29:29 +0000 Subject: [PATCH 4/4] release: 7.31.5 --- CHANGELOG.md | 2 +- Samples/iOS-Swift/iOS-Swift.xcodeproj/project.pbxproj | 8 ++++---- Sentry.podspec | 2 +- Sources/Configuration/Sentry.xcconfig | 2 +- Sources/Sentry/SentryMeta.m | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8914989b720..cb6e0413650 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## Unreleased +## 7.31.5 ### Fixes diff --git a/Samples/iOS-Swift/iOS-Swift.xcodeproj/project.pbxproj b/Samples/iOS-Swift/iOS-Swift.xcodeproj/project.pbxproj index 56cc9ebfa7f..35beffbfdab 100644 --- a/Samples/iOS-Swift/iOS-Swift.xcodeproj/project.pbxproj +++ b/Samples/iOS-Swift/iOS-Swift.xcodeproj/project.pbxproj @@ -1096,7 +1096,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 7.31.4; + MARKETING_VERSION = 7.31.5; PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.sample.iOS-Swift"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "match Development io.sentry.sample.iOS-Swift"; @@ -1125,7 +1125,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 7.31.4; + MARKETING_VERSION = 7.31.5; PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.sample.iOS-Swift"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "match AppStore io.sentry.sample.iOS-Swift"; @@ -1770,7 +1770,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 7.31.4; + MARKETING_VERSION = 7.31.5; PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.sample.iOS-Swift.Clip"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "match Development io.sentry.sample.iOS-Swift.Clip"; @@ -1805,7 +1805,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 7.31.4; + MARKETING_VERSION = 7.31.5; PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.sample.iOS-Swift.Clip"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "match AppStore io.sentry.sample.iOS-Swift.Clip"; diff --git a/Sentry.podspec b/Sentry.podspec index b569cb76c02..9e371cecfee 100644 --- a/Sentry.podspec +++ b/Sentry.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "Sentry" - s.version = "7.31.4" + s.version = "7.31.5" s.summary = "Sentry client for cocoa" s.homepage = "https://github.com/getsentry/sentry-cocoa" s.license = "mit" diff --git a/Sources/Configuration/Sentry.xcconfig b/Sources/Configuration/Sentry.xcconfig index 0f33a9a93f1..089f0d91ce0 100644 --- a/Sources/Configuration/Sentry.xcconfig +++ b/Sources/Configuration/Sentry.xcconfig @@ -28,7 +28,7 @@ MACH_O_TYPE = mh_dylib FRAMEWORK_VERSION = A PRODUCT_NAME = Sentry -CURRENT_PROJECT_VERSION = 7.31.4 +CURRENT_PROJECT_VERSION = 7.31.5 INFOPLIST_FILE = Sources/Sentry/Info.plist PRODUCT_BUNDLE_IDENTIFIER = io.sentry.Sentry ALWAYS_SEARCH_USER_PATHS = NO diff --git a/Sources/Sentry/SentryMeta.m b/Sources/Sentry/SentryMeta.m index 839c510a1b9..072528603fe 100644 --- a/Sources/Sentry/SentryMeta.m +++ b/Sources/Sentry/SentryMeta.m @@ -5,7 +5,7 @@ @implementation SentryMeta // Don't remove the static keyword. If you do the compiler adds the constant name to the global // symbol table and it might clash with other constants. When keeping the static keyword the // compiler replaces all occurrences with the value. -static NSString *versionString = @"7.31.4"; +static NSString *versionString = @"7.31.5"; static NSString *sdkName = @"sentry.cocoa"; + (NSString *)versionString