Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add experimental visionOS support (#3328)
Added support for visionOS
- Loading branch information
Showing
23 changed files
with
813 additions
and
4 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
389 changes: 389 additions & 0 deletions
389
Samples/visionOS-Swift/visionOS-Swift.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
77 changes: 77 additions & 0 deletions
77
...es/visionOS-Swift/visionOS-Swift.xcodeproj/xcshareddata/xcschemes/visionOS-Swift.xcscheme
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,77 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "1510" | ||
version = "1.7"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES"> | ||
<BuildActionEntries> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "YES" | ||
buildForArchiving = "YES" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "D84C37DA2ACDC4A000EF74BE" | ||
BuildableName = "visionOS-Swift.app" | ||
BlueprintName = "visionOS-Swift" | ||
ReferencedContainer = "container:visionOS-Swift.xcodeproj"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
</BuildActionEntries> | ||
</BuildAction> | ||
<TestAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
shouldAutocreateTestPlan = "YES"> | ||
</TestAction> | ||
<LaunchAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
launchStyle = "0" | ||
useCustomWorkingDirectory = "NO" | ||
ignoresPersistentStateOnLaunch = "NO" | ||
debugDocumentVersioning = "YES" | ||
debugServiceExtension = "internal" | ||
allowLocationSimulation = "YES"> | ||
<BuildableProductRunnable | ||
runnableDebuggingMode = "0"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "D84C37DA2ACDC4A000EF74BE" | ||
BuildableName = "visionOS-Swift.app" | ||
BlueprintName = "visionOS-Swift" | ||
ReferencedContainer = "container:visionOS-Swift.xcodeproj"> | ||
</BuildableReference> | ||
</BuildableProductRunnable> | ||
</LaunchAction> | ||
<ProfileAction | ||
buildConfiguration = "Release" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
debugDocumentVersioning = "YES"> | ||
<BuildableProductRunnable | ||
runnableDebuggingMode = "0"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "D84C37DA2ACDC4A000EF74BE" | ||
BuildableName = "visionOS-Swift.app" | ||
BlueprintName = "visionOS-Swift" | ||
ReferencedContainer = "container:visionOS-Swift.xcodeproj"> | ||
</BuildableReference> | ||
</BuildableProductRunnable> | ||
</ProfileAction> | ||
<AnalyzeAction | ||
buildConfiguration = "Debug"> | ||
</AnalyzeAction> | ||
<ArchiveAction | ||
buildConfiguration = "Release" | ||
revealArchiveInOrganizer = "YES"> | ||
</ArchiveAction> | ||
</Scheme> |
12 changes: 12 additions & 0 deletions
12
...xcassets/AppIcon.solidimagestack/Back.solidimagestacklayer/Content.imageset/Contents.json
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,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "vision", | ||
"scale" : "2x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...nOS-Swift/Assets.xcassets/AppIcon.solidimagestack/Back.solidimagestacklayer/Contents.json
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 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
Samples/visionOS-Swift/visionOS-Swift/Assets.xcassets/AppIcon.solidimagestack/Contents.json
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,17 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"layers" : [ | ||
{ | ||
"filename" : "Front.solidimagestacklayer" | ||
}, | ||
{ | ||
"filename" : "Middle.solidimagestacklayer" | ||
}, | ||
{ | ||
"filename" : "Back.solidimagestacklayer" | ||
} | ||
] | ||
} |
12 changes: 12 additions & 0 deletions
12
...cassets/AppIcon.solidimagestack/Front.solidimagestacklayer/Content.imageset/Contents.json
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,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "vision", | ||
"scale" : "2x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...OS-Swift/Assets.xcassets/AppIcon.solidimagestack/Front.solidimagestacklayer/Contents.json
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 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...assets/AppIcon.solidimagestack/Middle.solidimagestacklayer/Content.imageset/Contents.json
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,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "vision", | ||
"scale" : "2x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...S-Swift/Assets.xcassets/AppIcon.solidimagestack/Middle.solidimagestacklayer/Contents.json
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 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
Samples/visionOS-Swift/visionOS-Swift/Assets.xcassets/Contents.json
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 @@ | ||
{ | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
167 changes: 167 additions & 0 deletions
167
Samples/visionOS-Swift/visionOS-Swift/ContentView.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,167 @@ | ||
import RealityKit | ||
import Sentry | ||
import SentrySwiftUI | ||
import SwiftUI | ||
|
||
struct ContentView: View { | ||
|
||
var addBreadcrumbAction: () -> Void = { | ||
let crumb = Breadcrumb(level: SentryLevel.info, category: "Debug") | ||
crumb.message = "tapped addBreadcrumb" | ||
crumb.type = "user" | ||
SentrySDK.addBreadcrumb(crumb) | ||
} | ||
|
||
var captureMessageAction: () -> Void = { | ||
SentrySDK.capture(message: "Yeah captured a message") | ||
} | ||
|
||
var captureUserFeedbackAction: () -> Void = { | ||
let error = NSError(domain: "UserFeedbackErrorDomain", code: 0, userInfo: [NSLocalizedDescriptionKey: "This never happens."]) | ||
|
||
let eventId = SentrySDK.capture(error: error) { scope in | ||
scope.setLevel(.fatal) | ||
} | ||
|
||
let userFeedback = UserFeedback(eventId: eventId) | ||
userFeedback.comments = "It broke on visionOS-Swift. I don't know why, but this happens." | ||
userFeedback.email = "john@me.com" | ||
userFeedback.name = "John Me" | ||
SentrySDK.capture(userFeedback: userFeedback) | ||
} | ||
|
||
var captureErrorAction: () -> Void = { | ||
let error = NSError(domain: "SampleErrorDomain", code: 1, userInfo: [NSLocalizedDescriptionKey: "Object does not exist"]) | ||
SentrySDK.capture(error: error) { (scope) in | ||
scope.setTag(value: "value", key: "myTag") | ||
} | ||
} | ||
|
||
var captureNSExceptionAction: () -> Void = { | ||
let exception = NSException(name: NSExceptionName("My Custom exeption"), reason: "User clicked the button", userInfo: nil) | ||
let scope = Scope() | ||
scope.setLevel(.fatal) | ||
SentrySDK.capture(exception: exception, scope: scope) | ||
} | ||
|
||
var captureTransactionAction: () -> Void = { | ||
let dispatchQueue = DispatchQueue(label: "ContentView") | ||
|
||
let transaction = SentrySDK.startTransaction(name: "Some Transaction", operation: "some operation", bindToScope: true) | ||
|
||
guard let imgUrl = URL(string: "https://sentry-brand.storage.googleapis.com/sentry-logo-black.png") else { | ||
return | ||
} | ||
let session = URLSession(configuration: URLSessionConfiguration.default) | ||
let dataTask = session.dataTask(with: imgUrl) { (_, _, _) in } | ||
dataTask.resume() | ||
|
||
dispatchQueue.async { | ||
if let path = Bundle.main.path(forResource: "Tongariro", ofType: "jpg") { | ||
_ = FileManager.default.contents(atPath: path) | ||
} | ||
} | ||
|
||
dispatchQueue.asyncAfter(deadline: .now() + Double.random(in: 0.4...0.6), execute: { | ||
transaction.finish() | ||
}) | ||
} | ||
|
||
func asyncCrash1() { | ||
DispatchQueue.main.async { | ||
self.asyncCrash2() | ||
} | ||
} | ||
|
||
func asyncCrash2() { | ||
DispatchQueue.main.async { | ||
SentrySDK.crash() | ||
} | ||
} | ||
|
||
var oomCrashAction: () -> Void = { | ||
DispatchQueue.main.async { | ||
let megaByte = 1_024 * 1_024 | ||
let memoryPageSize = NSPageSize() | ||
let memoryPages = megaByte / memoryPageSize | ||
|
||
while true { | ||
// Allocate one MB and set one element of each memory page to something. | ||
let ptr = UnsafeMutablePointer<Int8>.allocate(capacity: megaByte) | ||
for i in 0..<memoryPages { | ||
ptr[i * memoryPageSize] = 40 | ||
} | ||
} | ||
} | ||
} | ||
|
||
var body: some View { | ||
SentryTracedView("Content View Body") { | ||
NavigationStack { | ||
HStack { | ||
VStack { | ||
Button(action: addBreadcrumbAction) { | ||
Text("Add Breadcrumb") | ||
} | ||
|
||
Button(action: captureMessageAction) { | ||
Text("Capture Message") | ||
} | ||
.accessibility(identifier: "captureMessageButton") | ||
|
||
Button(action: captureUserFeedbackAction) { | ||
Text("Capture User Feedback") | ||
} | ||
|
||
Button(action: captureErrorAction) { | ||
Text("Capture Error") | ||
} | ||
|
||
Button(action: captureNSExceptionAction) { | ||
Text("Capture NSException") | ||
} | ||
|
||
Button(action: captureTransactionAction) { | ||
Text("Capture Transaction") | ||
} | ||
} | ||
VStack { | ||
|
||
Button(action: { | ||
SentrySDK.crash() | ||
}) { | ||
Text("Crash") | ||
} | ||
|
||
Button(action: { | ||
DispatchQueue.main.async { | ||
self.asyncCrash1() | ||
} | ||
}) { | ||
Text("Async Crash") | ||
} | ||
|
||
Button(action: oomCrashAction) { | ||
Text("OOM Crash") | ||
} | ||
|
||
Button(action: { | ||
Thread.sleep(forTimeInterval: 3.0) | ||
}) { | ||
Text("Cause ANR") | ||
} | ||
|
||
NavigationLink(destination: LoremIpsumView()) { | ||
Text("Show Detail View 1") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
.padding() | ||
} | ||
} | ||
|
||
#Preview(windowStyle: .automatic) { | ||
ContentView() | ||
} |
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,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>UIApplicationSceneManifest</key> | ||
<dict> | ||
<key>UIApplicationPreferredDefaultSceneSessionRole</key> | ||
<string>UIWindowSceneSessionRoleApplication</string> | ||
<key>UIApplicationSupportsMultipleScenes</key> | ||
<true/> | ||
<key>UISceneConfigurations</key> | ||
<dict/> | ||
</dict> | ||
</dict> | ||
</plist> |
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,5 @@ | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean nec massa varius, rutrum massa eget, bibendum sapien. Integer et porttitor augue. Donec sagittis neque eu elit venenatis, non posuere odio laoreet. Curabitur non velit tempor, volutpat velit vitae, interdum tortor. Cras congue dignissim risus, vitae laoreet felis facilisis et. Vestibulum et nunc commodo, venenatis libero ac, euismod urna. Duis ultrices libero id placerat dapibus. Suspendisse vitae felis varius, tincidunt odio pretium, volutpat orci. In rhoncus augue commodo pretium sodales. Etiam fringilla dui id urna tempus, ut commodo libero aliquam. Pellentesque eu mauris id est posuere ultrices. In ante lacus, blandit non nibh id, cursus cursus eros. | ||
|
||
Phasellus in imperdiet tellus, ut tincidunt nulla. Nunc dapibus erat at leo cursus, non iaculis felis dignissim. Vestibulum viverra nisl in justo cursus scelerisque. Nulla facilisi. Praesent aliquet magna eu ipsum mollis egestas. Vestibulum hendrerit aliquam metus ut placerat. Donec nec feugiat urna. Donec rutrum, lectus in vestibulum eleifend, dolor lacus suscipit eros, et ornare ex risus at nisl. Duis tempus interdum dui at iaculis. Duis condimentum consectetur sapien, sed euismod leo tempor et. Nullam molestie metus quam, vel finibus velit dapibus ac. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Phasellus elit dui, sagittis sed lacus et, interdum aliquam quam. Nulla volutpat commodo ligula, sit amet lacinia nisl iaculis ut. Vestibulum a libero nulla. Duis id neque vitae orci cursus sollicitudin ac eget leo. | ||
|
||
Praesent vestibulum nunc nec ornare suscipit. Maecenas placerat metus nisi, ut rhoncus dui ullamcorper vitae. Praesent sit amet eros elit. Donec vel maximus massa. Phasellus pretium pulvinar dolor, id faucibus eros rutrum tincidunt. Phasellus quis placerat orci. Vivamus vel arcu non lacus gravida vehicula. Curabitur convallis facilisis fringilla. Duis at lorem non felis facilisis lacinia non vitae lectus. Vivamus eu leo sit amet justo eleifend consectetur. Donec ut ipsum dictum, sollicitudin felis a, aliquam lacus. Morbi vitae sollicitudin quam. Phasellus congue posuere justo eu mollis. Maecenas auctor nulla vel neque euismod ultricies. Suspendisse facilisis urna nec nisl dictum commodo. |
37 changes: 37 additions & 0 deletions
37
Samples/visionOS-Swift/visionOS-Swift/LoremIpsumView.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,37 @@ | ||
import Foundation | ||
import SentrySwiftUI | ||
import SwiftUI | ||
|
||
struct LoremIpsumView: View { | ||
|
||
@StateObject var viewModel = LoremIpsumViewModel() | ||
|
||
var body: some View { | ||
SentryTracedView("Lorem Ipsum") { | ||
Text(viewModel.text) | ||
.padding(16) | ||
} | ||
} | ||
} | ||
|
||
class LoremIpsumViewModel: ObservableObject { | ||
|
||
@Published var text = "Lorem Ipsum ..." | ||
|
||
init() { | ||
fetchLoremIpsum() | ||
} | ||
|
||
private func fetchLoremIpsum() { | ||
let dispatchQueue = DispatchQueue(label: "LoremIpsumViewModel") | ||
dispatchQueue.async { | ||
if let path = Bundle.main.path(forResource: "LoremIpsum", ofType: "txt") { | ||
if let contents = FileManager.default.contents(atPath: path) { | ||
DispatchQueue.main.async { | ||
self.text = String(data: contents, encoding: .utf8) ?? "" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.