Skip to content

Commit

Permalink
Merge 74dd57a into c2acec5
Browse files Browse the repository at this point in the history
  • Loading branch information
armcknight authored Oct 5, 2023
2 parents c2acec5 + 74dd57a commit 1ef367e
Show file tree
Hide file tree
Showing 71 changed files with 1,092 additions and 365 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,23 @@ jobs:
- uses: actions/checkout@v4
- run: swift build
shell: sh

check-uikit-linkage-debug:
name: Check UIKit linkage (Debug)
runs-on: macos-13
steps:
- uses: actions/checkout@v4
- name: Build for Debug
run: ./scripts/xcode-test.sh "iOS" "latest" $GITHUB_REF_NAME ci build "iPhone 14" Debug_without_UIKit uikit-check-build
- name: Ensure no UIKit
run: ./scripts/check-uikit-linkage.sh Debug_without_UIKit uikit-check-build

check-uikit-linkage-release:
name: Check UIKit linkage (Release)
runs-on: macos-13
steps:
- uses: actions/checkout@v4
- name: Build for Release
run: ./scripts/xcode-test.sh "iOS" "latest" $GITHUB_REF_NAME ci build "iPhone 14" Release_without_UIKit uikit-check-build
- name: Ensure no UIKit
run: ./scripts/check-uikit-linkage.sh Release_without_UIKit uikit-check-build
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,14 @@ jobs:
# We split building and running tests in two steps so we know how long running the tests takes.
- name: Build tests
id: build_tests
run: ./scripts/xcode-test.sh ${{matrix.platform}} ${{matrix.test-destination-os}} $GITHUB_REF_NAME ci build-for-testing "${{matrix.device}}"
run: ./scripts/xcode-test.sh ${{matrix.platform}} ${{matrix.test-destination-os}} $GITHUB_REF_NAME ci build-for-testing "${{matrix.device}}" TestCI

- name: Run tests
# We call a script with the platform so the destination
# passed to xcodebuild doesn't end up in the job name,
# because GitHub Actions don't provide an easy way of
# manipulating string in expressions.
run: ./scripts/xcode-test.sh ${{matrix.platform}} ${{matrix.test-destination-os}} $GITHUB_REF_NAME ci test-without-building "${{matrix.device}}"
run: ./scripts/xcode-test.sh ${{matrix.platform}} ${{matrix.test-destination-os}} $GITHUB_REF_NAME ci test-without-building "${{matrix.device}}" TestCI

- name: Slowest Tests
if: ${{ always() }}
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ GIT-REF := $(shell git rev-parse --abbrev-ref HEAD)

test:
@echo "--> Running all tests"
./scripts/xcode-test.sh iOS latest $(GIT-REF) YES
./scripts/xcode-test.sh iOS latest $(GIT-REF) YES test Test
./scripts/xcode-slowest-tests.sh
.PHONY: test

Expand Down
1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ let package = Package(
"SentryCrash/"
],
publicHeadersPath: "Sentry/Public/",
cSettings: [.unsafeFlags(["-DSENTRY_UIKIT_LINKED=1"])],
cxxSettings: [
.define("GCC_ENABLE_CPP_EXCEPTIONS", to: "YES"),
.headerSearchPath("Sentry/include"),
Expand Down
4 changes: 3 additions & 1 deletion Samples/iOS-Swift/iOS-Swift/ExtraViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ class ExtraViewController: UIViewController {
}

SentrySDK.reportFullyDisplayed()


#if SENTRY_HAS_UIKIT
Timer.scheduledTimer(withTimeInterval: 0.5, repeats: true) { _ in
self.framesLabel?.text = "Frames Total:\(PrivateSentrySDKOnly.currentScreenFrames.total) Slow:\(PrivateSentrySDKOnly.currentScreenFrames.slow) Frozen:\(PrivateSentrySDKOnly.currentScreenFrames.frozen)"
}
#endif // SENTRY_HAS_UIKIT

SentrySDK.reportFullyDisplayed()
}
Expand Down
3 changes: 2 additions & 1 deletion Sentry.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ Pod::Spec.new do |s|
s.pod_target_xcconfig = {
'GCC_ENABLE_CPP_EXCEPTIONS' => 'YES',
'CLANG_CXX_LANGUAGE_STANDARD' => 'c++14',
'CLANG_CXX_LIBRARY' => 'libc++'
'CLANG_CXX_LIBRARY' => 'libc++',
'GCC_PREPROCESSOR_DEFINITIONS' => 'SENTRY_UIKIT_LINKED=1'
}
s.watchos.pod_target_xcconfig = {
'OTHER_LDFLAGS' => '$(inherited) -framework WatchKit'
Expand Down
691 changes: 669 additions & 22 deletions Sentry.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
<Test
Identifier = "SentrySubClassFinderTests/testActOnSubclassesOfViewController()">
</Test>
<Test
Identifier = "SentryThreadInspectorTests/testStacktraceHasFrames_forEveryThread()">
</Test>
</SkippedTests>
</TestableReference>
<TestableReference
Expand All @@ -91,7 +94,7 @@
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
buildConfiguration = "Test"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
Expand Down
6 changes: 6 additions & 0 deletions SentryTestUtils/SentryTestUtils-ObjC-BridgingHeader.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#import "SentryDefines.h"

#if TARGET_OS_IOS || TARGET_OS_TV
# define SENTRY_UIKIT_AVAILABLE 1
#else
# define SENTRY_UIKIT_AVAILABLE 0
#endif

#if SENTRY_HAS_UIKIT
# import "SentryAppStartTracker.h"
# import "SentryDisplayLinkWrapper.h"
Expand Down
6 changes: 5 additions & 1 deletion Sources/Sentry/PrivateSentrySDKOnly.mm
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,21 @@ + (SentryScreenFrames *)currentScreenFrames
return SentryDependencyContainer.sharedInstance.framesTracker.currentFrames;
}

# if SENTRY_HAS_UIKIT

+ (NSArray<NSData *> *)captureScreenshots
{
return [SentryDependencyContainer.sharedInstance.screenshot takeScreenshots];
}

# endif // SENTRY_HAS_UIKIT

+ (NSData *)captureViewHierarchy
{
return [SentryDependencyContainer.sharedInstance.viewHierarchy fetchViewHierarchy];
}

#endif
#endif // SENTRY_HAS_UIKIT

+ (SentryUser *)userWithDictionary:(NSDictionary *)dictionary
{
Expand Down
10 changes: 8 additions & 2 deletions Sources/Sentry/Public/SentryDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@
# define SENTRY_EXTERN extern __attribute__((visibility("default")))
#endif

#if TARGET_OS_IOS || TARGET_OS_TV
#if (TARGET_OS_IOS || TARGET_OS_TV) && SENTRY_UIKIT_LINKED
# define SENTRY_HAS_UIKIT 1
#else
# define SENTRY_HAS_UIKIT 0
#endif

#if TARGET_OS_IOS || TARGET_OS_OSX || TARGET_OS_MACCATALYST
#if TARGET_OS_OSX || TARGET_OS_MACCATALYST
# define SENTRY_TARGET_MACOS 1
#else
# define SENTRY_TARGET_MACOS 0
#endif

#if TARGET_OS_IOS || SENTRY_TARGET_MACOS
# define SENTRY_HAS_METRIC_KIT 1
#else
# define SENTRY_HAS_METRIC_KIT 0
Expand Down
9 changes: 6 additions & 3 deletions Sources/Sentry/Public/SentryOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,16 @@ NS_SWIFT_NAME(Options)
*/
@property (nonatomic) SentryScope * (^initialScope)(SentryScope *);

#if SENTRY_HAS_UIKIT
/**
* When enabled, the SDK tracks performance for UIViewController subclasses.
* @note This feature is only available on builds that link @c UIKit .
* @note The default is @c YES .
*/
@property (nonatomic, assign) BOOL enableUIViewControllerTracing;

/**
* Automatically attaches a screenshot when capturing an error or exception.
* @note This feature is only available on builds that link @c UIKit .
* @note Default value is @c NO .
*/
@property (nonatomic, assign) BOOL attachScreenshot;
Expand All @@ -216,20 +217,23 @@ NS_SWIFT_NAME(Options)
* @warning This is an experimental feature and may still have bugs.
* @brief Automatically attaches a textual representation of the view hierarchy when capturing an
* error event.
* @note This feature is only available on builds that link @c UIKit .
* @note Default value is @c NO .
*/
@property (nonatomic, assign) BOOL attachViewHierarchy;

/**
* When enabled, the SDK creates transactions for UI events like buttons clicks, switch toggles,
* and other ui elements that uses UIControl @c sendAction:to:forEvent:
* @note This feature is only available on builds that link @c UIKit .
* @note Default value is @c YES .
*/
@property (nonatomic, assign) BOOL enableUserInteractionTracing;

/**
* How long an idle transaction waits for new children after all its child spans finished. Only UI
* event transactions are idle transactions.
* @note This feature is only available on builds that link @c UIKit .
* @note The default is 3 seconds.
*/
@property (nonatomic, assign) NSTimeInterval idleTimeout;
Expand All @@ -242,12 +246,11 @@ NS_SWIFT_NAME(Options)
* @note You can filter for different app start types in Discover with
* @c app_start_type:cold.prewarmed ,
* @c app_start_type:warm.prewarmed , @c app_start_type:cold , and @c app_start_type:warm .
* @note This feature is only available on builds that link @c UIKit .
* @note Default value is @c NO .
*/
@property (nonatomic, assign) BOOL enablePreWarmedAppStartTracing;

#endif // SENTRY_HAS_UIKIT

/**
* When enabled, the SDK tracks performance for HTTP requests if auto performance tracking and
* @c enableSwizzling are enabled.
Expand Down
1 change: 1 addition & 0 deletions Sources/Sentry/SentryAppStartTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

# import "SentryAppStartMeasurement.h"
# import "SentryAppStateManager.h"
# import "SentryDefines.h"
# import "SentryLog.h"
# import "SentrySysctl.h"
# import <Foundation/Foundation.h>
Expand Down
5 changes: 3 additions & 2 deletions Sources/Sentry/SentryAppStateManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,11 @@ - (SentryAppState *)buildCurrentAppState
// Is the current process being traced or not? If it is a debugger is attached.
bool isDebugging = self.crashWrapper.isBeingTraced;

NSString *vendorId = [UIDevice.currentDevice.identifierForVendor UUIDString];
UIDevice *device = [UIDevice currentDevice];
NSString *vendorId = [device.identifierForVendor UUIDString];

return [[SentryAppState alloc] initWithReleaseName:self.options.releaseName
osVersion:UIDevice.currentDevice.systemVersion
osVersion:device.systemVersion
vendorId:vendorId
isDebugging:isDebugging
systemBootTimestamp:SentryDependencyContainer.sharedInstance
Expand Down
16 changes: 15 additions & 1 deletion Sources/Sentry/SentryAutoBreadcrumbTrackingIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
SentryAutoBreadcrumbTrackingIntegration ()

@property (nonatomic, strong) SentryBreadcrumbTracker *breadcrumbTracker;

#if TARGET_OS_IOS && SENTRY_HAS_UIKIT
@property (nonatomic, strong) SentrySystemEventBreadcrumbs *systemEventBreadcrumbs;
#endif // TARGET_OS_IOS && SENTRY_HAS_UIKIT

@end

Expand All @@ -27,11 +30,14 @@ - (BOOL)installWithOptions:(SentryOptions *)options

[self installWithOptions:options
breadcrumbTracker:[[SentryBreadcrumbTracker alloc] init]
#if TARGET_OS_IOS && SENTRY_HAS_UIKIT
systemEventBreadcrumbs:
[[SentrySystemEventBreadcrumbs alloc]
initWithFileManager:[SentryDependencyContainer sharedInstance].fileManager
andNotificationCenterWrapper:[SentryDependencyContainer sharedInstance]
.notificationCenterWrapper]];
.notificationCenterWrapper]
#endif // TARGET_OS_IOS && SENTRY_HAS_UIKIT
];

return YES;
}
Expand All @@ -46,27 +52,35 @@ - (SentryIntegrationOption)integrationOptions
*/
- (void)installWithOptions:(nonnull SentryOptions *)options
breadcrumbTracker:(SentryBreadcrumbTracker *)breadcrumbTracker
#if TARGET_OS_IOS && SENTRY_HAS_UIKIT
systemEventBreadcrumbs:(SentrySystemEventBreadcrumbs *)systemEventBreadcrumbs
#endif // TARGET_OS_IOS && SENTRY_HAS_UIKIT
{
self.breadcrumbTracker = breadcrumbTracker;
[self.breadcrumbTracker startWithDelegate:self];

#if SENTRY_HAS_UIKIT
if (options.enableSwizzling) {
[self.breadcrumbTracker startSwizzle];
}
#endif // SENTRY_HAS_UIKIT

#if TARGET_OS_IOS && SENTRY_HAS_UIKIT
self.systemEventBreadcrumbs = systemEventBreadcrumbs;
[self.systemEventBreadcrumbs startWithDelegate:self];
#endif // TARGET_OS_IOS && SENTRY_HAS_UIKIT
}

- (void)uninstall
{
if (nil != self.breadcrumbTracker) {
[self.breadcrumbTracker stop];
}
#if TARGET_OS_IOS && SENTRY_HAS_UIKIT
if (nil != self.systemEventBreadcrumbs) {
[self.systemEventBreadcrumbs stop];
}
#endif // TARGET_OS_IOS && SENTRY_HAS_UIKIT
}

- (void)addBreadcrumb:(SentryBreadcrumb *)crumb
Expand Down
2 changes: 2 additions & 0 deletions Sources/Sentry/SentryBaseIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@ - (BOOL)shouldBeEnabledWithOptions:(SentryOptions *)options
return NO;
}

# if SENTRY_HAS_UIKIT
if ((integrationOptions & kIntegrationOptionAttachScreenshot) && !options.attachScreenshot) {
[self logWithOptionName:@"attachScreenshot"];
return NO;
}
# endif // SENTRY_HAS_UIKIT

if ((integrationOptions & kIntegrationOptionEnableUserInteractionTracing)
&& !options.enableUserInteractionTracing) {
Expand Down
Loading

0 comments on commit 1ef367e

Please sign in to comment.