Skip to content
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
2 changes: 2 additions & 0 deletions Samples/SentrySampleShared/SentrySampleShared.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ CODE_SIGN_IDENTITY =
CODE_SIGN_IDENTITY[sdk=macosx*] =
PROVISIONING_PROFILE_SPECIFIER =
DEVELOPMENT_TEAM =

TARGETED_DEVICE_FAMILY = 1,2,3,4,7
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#if !os(macOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)
import UIKit

public class SampleAppDebugMenu: NSObject {
static var displayingForm = false
let window = {
if #available(iOS 13.0, *) {
if let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene {
return Window(windowScene: scene)
}
}
return Window()
}()

lazy var rootVC = {
let uivc = UIViewController(nibName: nil, bundle: nil)
uivc.view.addSubview(button)

button.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
button.leadingAnchor.constraint(equalTo: uivc.view.safeAreaLayoutGuide.leadingAnchor, constant: 25),
button.bottomAnchor.constraint(equalTo: uivc.view.safeAreaLayoutGuide.bottomAnchor, constant: -75)
])

return uivc
}()

lazy var button = {
let button = UIButton(type: .custom)
button.addTarget(self, action: #selector(displayDebugMenu), for: .touchUpInside)
button.setTitle("SDK Debug", for: .normal)
button.setTitleColor(.blue, for: .normal)
return button
}()

@objc public func display() {
window.rootViewController = rootVC
window.isHidden = false
}

@objc func displayDebugMenu() {
SampleAppDebugMenu.displayingForm = true
rootVC.present(FeaturesViewController(style: .plain), animated: true)
}

class Window: UIWindow {

@available(iOS 13.0, *)
override init(windowScene: UIWindowScene) {
super.init(windowScene: windowScene)
commonInit()
}

init() {
super.init(frame: UIScreen.main.bounds)
commonInit()
}

func commonInit() {
windowLevel = UIWindow.Level.alert + 1
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
guard !SampleAppDebugMenu.displayingForm else {
return super.hitTest(point, with: event)
}

guard let result = super.hitTest(point, with: event) else {
return nil
}
guard result.isKind(of: UIButton.self) else {
return nil
}
return result
}
}
}

extension SampleAppDebugMenu: UIAdaptivePresentationControllerDelegate {
public func presentationControllerDidDismiss(_ presentationController: UIPresentationController) {
rootVC.dismiss(animated: true)
SampleAppDebugMenu.displayingForm = false
}
}
#endif // !os(macOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import UIKit
public struct SentrySDKWrapper {
public static let shared = SentrySDKWrapper()

#if !os(macOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)
let debugMenu = SampleAppDebugMenu()
#endif // !os(macOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)

#if !os(macOS) && !os(tvOS) && !os(watchOS)
public let feedbackButton = {
let button = UIButton(type: .custom)
Expand All @@ -28,6 +32,10 @@ public struct SentrySDKWrapper {

if !SentrySDKOverrides.Special.skipSDKInit.boolValue {
SentrySDK.start(configureOptions: configureSentryOptions(options:))

#if !os(macOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)
debugMenu.display()
#endif // !os(macOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)
}
}

Expand Down
4 changes: 4 additions & 0 deletions Samples/iOS-ObjectiveC/iOS-ObjectiveC/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
@import SentrySampleShared;

@interface AppDelegate ()
@property (strong, nonatomic) SampleAppDebugMenu *debugMenu;
@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.debugMenu = [[SampleAppDebugMenu alloc] init];
[self.debugMenu display];

NSArray<NSString *> *args = NSProcessInfo.processInfo.arguments;
NSDictionary<NSString *, NSString *> *env = NSProcessInfo.processInfo.environment;

Expand Down
48 changes: 19 additions & 29 deletions Samples/iOS-Swift/iOS-Swift/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions Samples/iOS-Swift/iOS-Swift/ExtraViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,6 @@ class ExtraViewController: UIViewController {
}
}

@IBAction func featureFlags(_ sender: Any) {
navigationController?.pushViewController(FeaturesViewController(style: .plain), animated: true)
}

private func calcPi() -> Double {
var denominator = 1.0
var pi = 0.0
Expand Down
8 changes: 0 additions & 8 deletions Samples/iOS-Swift6/iOS-Swift6/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
import Sentry
import SentrySampleShared
import UIKit

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
SentrySDKWrapper.shared.startSentry()
return true
}

// MARK: UISceneSession Lifecycle

func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
Expand Down
17 changes: 2 additions & 15 deletions Samples/iOS-Swift6/iOS-Swift6/SceneDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
import SentrySampleShared
import UIKit

class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let _ = (scene as? UIWindowScene) else { return }
}

func sceneDidDisconnect(_ scene: UIScene) {
}

func sceneDidBecomeActive(_ scene: UIScene) {
}

func sceneWillResignActive(_ scene: UIScene) {
}

func sceneWillEnterForeground(_ scene: UIScene) {
}

func sceneDidEnterBackground(_ scene: UIScene) {
SentrySDKWrapper.shared.startSentry()
}
}
27 changes: 23 additions & 4 deletions Samples/iOS-SwiftUI/iOS-SwiftUI/SwiftUIApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,32 @@ import SwiftUI

@main
struct SwiftUIApp: App {
init() {
SentrySDKWrapper.shared.startSentry()
}

@UIApplicationDelegateAdaptor private var appDelegate: MyAppDelegate

var body: some Scene {
WindowGroup {
ContentView()
}
}
}

class MyAppDelegate: NSObject, UIApplicationDelegate, ObservableObject {
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
let configuration = UISceneConfiguration(
name: nil,
sessionRole: connectingSceneSession.role)
if connectingSceneSession.role == .windowApplication {
configuration.delegateClass = MySceneDelegate.self
}
return configuration
}
}

class MySceneDelegate: NSObject, UIWindowSceneDelegate, ObservableObject {
var initializedSentry = false
func sceneDidBecomeActive(_ scene: UIScene) {
guard !initializedSentry else { return }
SentrySDKWrapper.shared.startSentry()
initializedSentry = true
}
}
25 changes: 22 additions & 3 deletions Samples/iOS15-SwiftUI/iOS15-SwiftUI/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,32 @@ import SwiftUI

@main
struct SwiftUIApp: App {
init() {
SentrySDKWrapper.shared.startSentry()
}
@UIApplicationDelegateAdaptor private var appDelegate: MyAppDelegate

var body: some Scene {
WindowGroup {
ContentView()
}
}
}

class MyAppDelegate: NSObject, UIApplicationDelegate, ObservableObject {
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
let configuration = UISceneConfiguration(
name: nil,
sessionRole: connectingSceneSession.role)
if connectingSceneSession.role == .windowApplication {
configuration.delegateClass = MySceneDelegate.self
}
return configuration
}
}

class MySceneDelegate: NSObject, UIWindowSceneDelegate, ObservableObject {
var initializedSentry = false
func sceneDidBecomeActive(_ scene: UIScene) {
guard !initializedSentry else { return }
SentrySDKWrapper.shared.startSentry()
initializedSentry = true
}
}
1 change: 1 addition & 0 deletions Samples/visionOS-Swift/visionOS-Swift.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ INFOPLIST_FILE = visionOS-Swift/Info.plist
SUPPORTED_PLATFORMS = xros xrsimulator
XROS_DEPLOYMENT_TARGET = 1.0
DEVELOPMENT_ASSET_PATHS = "visionOS-Swift/Preview Content"
TARGETED_DEVICE_FAMILY = 7
62 changes: 31 additions & 31 deletions Samples/visionOS-Swift/visionOS-Swift/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,36 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>GIT_BRANCH</key>
<string>&lt;branch&gt;</string>
<key>GIT_COMMIT_HASH</key>
<string>&lt;sha&gt;</string>
<key>GIT_STATUS_CLEAN</key>
<string>&lt;status&gt;</string>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationPreferredDefaultSceneSessionRole</key>
<string>UIWindowSceneSessionRoleApplication</string>
<key>UIApplicationSupportsMultipleScenes</key>
<true/>
<key>UISceneConfigurations</key>
<dict/>
</dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>GIT_BRANCH</key>
<string>&lt;branch&gt;</string>
<key>GIT_COMMIT_HASH</key>
<string>&lt;sha&gt;</string>
<key>GIT_STATUS_CLEAN</key>
<string>&lt;status&gt;</string>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationPreferredDefaultSceneSessionRole</key>
<string>UIWindowSceneSessionRoleApplication</string>
<key>UIApplicationSupportsMultipleScenes</key>
<true/>
<key>UISceneConfigurations</key>
<dict/>
</dict>
</dict>
</plist>
Loading