Skip to content

Commit 25c6606

Browse files
committed
add widget and widget control for testing
1 parent 0b7362d commit 25c6606

File tree

22 files changed

+3040
-2
lines changed

22 files changed

+3040
-2
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Cartfile.resolved
8484

8585
Samples/SessionReplay-CameraTest/SessionReplay-CameraTest.xcodeproj
8686
Samples/iOS-ObjectiveC/iOS-ObjectiveC.xcodeproj
87-
Samples/iOS-Swift/iOS-Swift.xcodeproj
87+
# Samples/iOS-Swift/iOS-Swift.xcodeproj
8888
Samples/iOS-Swift6/iOS-Swift6.xcodeproj
8989
Samples/iOS-SwiftUI/iOS-SwiftUI.xcodeproj
9090
Samples/iOS15-SwiftUI/iOS15-SwiftUI.xcodeproj
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#import "SentryExposure.h"
2+
#import <Sentry/PrivateSentrySDKOnly.h>
3+
#import <Sentry/SentryDsn+Private.h>
4+
#import <Sentry/SentryOptions+Private.h>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"colors": [
3+
{
4+
"idiom": "universal"
5+
}
6+
],
7+
"info": {
8+
"author": "xcode",
9+
"version": 1
10+
}
11+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"images": [
3+
{
4+
"idiom": "universal",
5+
"platform": "ios",
6+
"size": "1024x1024"
7+
},
8+
{
9+
"appearances": [
10+
{
11+
"appearance": "luminosity",
12+
"value": "dark"
13+
}
14+
],
15+
"idiom": "universal",
16+
"platform": "ios",
17+
"size": "1024x1024"
18+
},
19+
{
20+
"appearances": [
21+
{
22+
"appearance": "luminosity",
23+
"value": "tinted"
24+
}
25+
],
26+
"idiom": "universal",
27+
"platform": "ios",
28+
"size": "1024x1024"
29+
}
30+
],
31+
"info": {
32+
"author": "xcode",
33+
"version": 1
34+
}
35+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info": {
3+
"author": "xcode",
4+
"version": 1
5+
}
6+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"colors": [
3+
{
4+
"idiom": "universal"
5+
}
6+
],
7+
"info": {
8+
"author": "xcode",
9+
"version": 1
10+
}
11+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>$(DEVELOPMENT_LANGUAGE)</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIdentifier</key>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11+
<key>CFBundleInfoDictionaryVersion</key>
12+
<string>6.0</string>
13+
<key>CFBundleName</key>
14+
<string>$(PRODUCT_NAME)</string>
15+
<key>CFBundlePackageType</key>
16+
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
17+
<key>CFBundleShortVersionString</key>
18+
<string>$(MARKETING_VERSION)</string>
19+
<key>CFBundleVersion</key>
20+
<string>$(CURRENT_PROJECT_VERSION)</string>
21+
<key>NSExtension</key>
22+
<dict>
23+
<key>NSExtensionPointIdentifier</key>
24+
<string>com.apple.widgetkit-extension</string>
25+
</dict>
26+
</dict>
27+
</plist>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import AppIntents
2+
import WidgetKit
3+
4+
struct SampleConfigurationAppIntent: WidgetConfigurationIntent {
5+
static var title: LocalizedStringResource { "Configuration" }
6+
static var description: IntentDescription { "This is a Sentry widget." }
7+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import Sentry
2+
import SwiftUI
3+
import WidgetKit
4+
5+
struct SampleWidget: Widget {
6+
let kind: String = "SampleWidget"
7+
8+
var body: some WidgetConfiguration {
9+
AppIntentConfiguration(kind: kind, intent: SampleConfigurationAppIntent.self, provider: Provider()) { entry in
10+
SampleWidgetEntryView(entry: entry)
11+
.containerBackground(.fill.tertiary, for: .widget)
12+
}
13+
}
14+
}
15+
16+
fileprivate struct SampleWidgetEntryView: View {
17+
var entry: Provider.Entry
18+
19+
var body: some View {
20+
let anrInstalled = SentrySDK.isEnabled &&
21+
SentrySDKInternal.trimmedInstalledIntegrationNames()
22+
.contains("ANRTracking")
23+
24+
VStack(spacing: 8) {
25+
Text("Sentry")
26+
.font(.headline)
27+
28+
Text("ANR Tracking:")
29+
.font(.caption2)
30+
Text(anrInstalled ? "❌ Enabled" : "✅ Disabled")
31+
.font(.caption)
32+
.foregroundColor(anrInstalled ? .red : .green)
33+
.bold()
34+
35+
Text(entry.date, style: .time)
36+
.font(.caption2)
37+
}
38+
}
39+
}
40+
41+
private struct Provider: AppIntentTimelineProvider {
42+
func placeholder(in context: Context) -> SimpleEntry {
43+
SimpleEntry(date: Date(), configuration: SampleConfigurationAppIntent())
44+
}
45+
46+
func snapshot(for configuration: SampleConfigurationAppIntent, in context: Context) async -> SimpleEntry {
47+
setupSentrySDK()
48+
49+
return SimpleEntry(date: Date(), configuration: configuration)
50+
}
51+
52+
func timeline(for configuration: SampleConfigurationAppIntent, in context: Context) async -> Timeline<SimpleEntry> {
53+
setupSentrySDK()
54+
55+
let entry = SimpleEntry(date: Date(), configuration: configuration)
56+
return Timeline(entries: [entry], policy: .atEnd)
57+
}
58+
59+
private func setupSentrySDK() {
60+
guard !SentrySDK.isEnabled else {
61+
return
62+
}
63+
SentrySDK.start { options in
64+
options.dsn = "https://a92d50327ac74b8b9aa4ea80eccfb267@o447951.ingest.sentry.io/5428557"
65+
options.debug = true
66+
options.enableAppHangTracking = true
67+
}
68+
}
69+
}
70+
71+
private struct SimpleEntry: TimelineEntry {
72+
let date: Date
73+
let configuration: SampleConfigurationAppIntent
74+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// iOS_Swift_WidgetBundle.swift
3+
// iOS-Swift-Widget
4+
//
5+
// Created by Philip Niedertscheider on 04.11.25.
6+
//
7+
8+
import SwiftUI
9+
import WidgetKit
10+
11+
@main
12+
struct iOS_Swift_WidgetBundle: WidgetBundle {
13+
var body: some Widget {
14+
SampleWidget()
15+
SampleWidgetControl()
16+
SampleWidgetLiveActivity()
17+
}
18+
}

0 commit comments

Comments
 (0)