Skip to content

test: sample app build tooling #5200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 16 commits into
base: armcknight/test/share-sdk-overrides
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
95a973d
wip with scripts to build all sample apps in one command
armcknight May 7, 2025
4ec7b89
Merge branch 'armcknight/test/shared-sdk-lib' into armkcnight/test/sa…
armcknight May 7, 2025
7069046
trying to use correct destinations for all schemes; stuck on watchOS
armcknight May 7, 2025
e41a467
Merge branch 'armcknight/test/share-sdk-overrides' into armkcnight/te…
armcknight May 7, 2025
6577b74
Merge branch 'armcknight/test/share-sdk-overrides' into armkcnight/te…
armcknight May 7, 2025
1a23a29
move more session replay config options behind feature flags
armcknight May 7, 2025
1aee450
move logic to restart SDK from camera sample app to shared sdk overrides
armcknight May 7, 2025
258f50a
Merge branch 'armcknight/test/share-sdk-overrides' into armcknight/te…
armcknight May 7, 2025
091c49d
Merge branch 'armcknight/test/restart-sdk-on-reconfig' into armcknigh…
armcknight May 7, 2025
e0c3477
Merge branch 'armcknight/test/more-override-config' into armkcnight/t…
armcknight May 7, 2025
0d5ff59
remove noisy repetitive logging
armcknight May 7, 2025
760f8ac
Merge branch 'armcknight/test/restart-sdk-on-reconfig' into armcknigh…
armcknight May 7, 2025
bce6528
Merge branch 'armcknight/test/more-override-config' into armkcnight/t…
armcknight May 7, 2025
55f71a4
Merge branch 'armcknight/test/share-sdk-overrides' into armcknight/te…
armcknight May 7, 2025
02587a2
Merge branch 'armcknight/test/restart-sdk-on-reconfig' into armcknigh…
armcknight May 7, 2025
8e30b1c
Merge branch 'armcknight/test/more-override-config' into armkcnight/t…
armcknight May 7, 2025
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
25 changes: 25 additions & 0 deletions .build-sample-apps.tmuxinator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: build-sample-apps

windows:
- build:
layout: tiled
panes:
- bash -c 'cd ./Samples/iOS13-Swift && xcodebuild build -scheme iOS13-Swift | xcbeautify; echo $? > /tmp/iOS13-Swift.exit'
- bash -c 'cd ./Samples/iOS-SwiftUI && xcodebuild build -scheme iOS-SwiftUI | xcbeautify; echo $? > /tmp/iOS-SwiftUI.exit'
- bash -c 'cd ./Samples/iOS-Swift6 && xcodebuild build -scheme iOS-Swift6 | xcbeautify; echo $? > /tmp/iOS-Swift6.exit'
- bash -c 'cd ./Samples/iOS-Swift && xcodebuild build -scheme iOS-Swift | xcbeautify; echo $? > /tmp/iOS-Swift.exit'
- bash -c 'cd ./Samples/watchOS-Swift && xcodebuild build -scheme "watchOS-Swift WatchKit App" | xcbeautify; echo $? > /tmp/watchOS-Swift.exit'
- bash -c 'cd ./Samples/visionOS-Swift && xcodebuild build -scheme visionOS-Swift | xcbeautify; echo $? > /tmp/visionOS-Swift.exit'
- bash -c 'cd ./Samples/tvOS-Swift && xcodebuild build -scheme tvOS-Swift | xcbeautify; echo $? > /tmp/tvOS-Swift.exit'
- bash -c 'cd ./Samples/macOS-SwiftUI && xcodebuild build -scheme macOS-SwiftUI | xcbeautify; echo $? > /tmp/macOS-SwiftUI.exit'
- bash -c 'cd ./Samples/macOS-Swift && xcodebuild build -scheme macOS-Swift | xcbeautify; echo $? > /tmp/macOS-Swift.exit'
- bash -c 'cd ./Samples/iOS15-SwiftUI && xcodebuild build -scheme iOS15-SwiftUI | xcbeautify; echo $? > /tmp/iOS15-SwiftUI.exit'
- bash -c 'cd ./Samples/iOS-ObjectiveC && xcodebuild build -scheme iOS-ObjectiveC | xcbeautify; echo $? > /tmp/iOS-ObjectiveC.exit'
- |
while [ ! -f /tmp/iOS13-Swift.exit ] || [ ! -f /tmp/iOS-SwiftUI.exit ] || [ ! -f /tmp/iOS-Swift6.exit ] || [ ! -f /tmp/iOS-Swift.exit ] || [ ! -f /tmp/watchOS-Swift.exit ] || [ ! -f /tmp/visionOS-Swift.exit ] || [ ! -f /tmp/tvOS-Swift.exit ] || [ ! -f /tmp/macOS-SwiftUI.exit ] || [ ! -f /tmp/macOS-Swift.exit ] || [ ! -f /tmp/iOS15-SwiftUI.exit ] || [ ! -f /tmp/iOS-ObjectiveC.exit ]; do
sleep 1
done
for file in /tmp/*.exit; do
echo "$file: $(cat $file)"
done
rm /tmp/*.exit
2 changes: 2 additions & 0 deletions Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ brew 'pre-commit'
brew 'python3'
brew 'xcbeautify'
brew 'rbenv'
brew 'tmux'
brew 'tmuxinator'
brew 'xcodegen'
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,8 @@ xcode:
xcodegen --spec Samples/visionOS-Swift/visionOS-Swift.yml
xcodegen --spec Samples/watchOS-Swift/watchOS-Swift.yml
open Sentry.xcworkspace

.PHONY: build-sample-apps

build-sample-apps:
tmuxinator start -p .build-sample-apps.tmuxinator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class EnvironmentVariableTableViewCell: UITableViewCell, UITextFieldDelegate {
} else {
override?.stringValue = textField.text
}
SentrySDKWrapper.shared.startSentry()
}
}
#endif // !os(macOS) && !os(tvOS) && !os(watchOS)
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#if !os(macOS) && !os(tvOS) && !os(watchOS)
import Sentry
import UIKit

class LaunchArgumentTableViewCell: UITableViewCell {
Expand All @@ -12,6 +13,7 @@ class LaunchArgumentTableViewCell: UITableViewCell {

@objc func toggleFlag() {
override?.boolValue = flagSwitch.isOn
SentrySDKWrapper.shared.startSentry()
}

override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public enum SentrySDKOverrides {
public enum Special: String, SentrySDKOverride {
case wipeDataOnLaunch = "--io.sentry.wipe-data"
case disableEverything = "--io.sentry.disable-everything"
case skipSDKInit = "--skip-sentry-init"

public var boolValue: Bool {
get {
Expand Down Expand Up @@ -94,10 +95,63 @@ public enum SentrySDKOverrides {
}
}

public enum SessionReplay: String, SentrySDKOverride {
case disableSessionReplay = "--disable-session-replay"
case disableViewRendererV2 = "--io.sentry.session-replay.disableViewRendereV2"
case enableFastViewRendering = "--io.sentry.session-replay.enableFastViewRendering"
case sessionReplaySampleRate = "--io.sentry.sessionReplaySampleRate"
case sessionReplayOnErrorSampleRate = "--io.sentry.sessionReplayOnErrorSampleRate"
case sessionReplayQuality = "--io.sentry.sessionReplayQuality"

public var booleanValue: Bool {
get {
switch self {
case .sessionReplaySampleRate, .sessionReplayOnErrorSampleRate, .sessionReplayQuality: fatalError("This override doesn't correspond to a boolean value.")
default: return getBoolOverride(for: rawValue)
}
}
set(newValue) {
switch self {
case .sessionReplaySampleRate, .sessionReplayOnErrorSampleRate, .sessionReplayQuality: fatalError("This override doesn't correspond to a boolean value.")
default: setBoolOverride(for: rawValue, value: newValue)
}
}
}

public var floatValue: Float? {
get {
switch self {
case .sessionReplaySampleRate, .sessionReplayOnErrorSampleRate: return getFloatValueOverride(for: rawValue)
default: fatalError("This override doesn't correspond to a float value.")
}
}
set(newValue) {
switch self {
case .sessionReplaySampleRate, .sessionReplayOnErrorSampleRate: setFloatOverride(for: rawValue, value: newValue)
default: fatalError("This override doesn't correspond to a float value.")
}
}
}

public var stringValue: String? {
get {
switch self {
case .sessionReplayQuality: return getStringValueOverride(for: rawValue)
default: fatalError("This override doesn't correspond to a string value.")
}
}
set(newValue) {
switch self {
case .sessionReplayQuality: setStringOverride(for: rawValue, value: newValue)
default: fatalError("This override doesn't correspond to a string value.")
}
}
}
}

public enum Other: String, SentrySDKOverride {
case disableAttachScreenshot = "--disable-attach-screenshot"
case disableAttachViewHierarchy = "--disable-attach-view-hierarchy"
case disableSessionReplay = "--disable-session-replay"
case disableMetricKit = "--disable-metrickit-integration"
case disableBreadcrumbs = "--disable-automatic-breadcrumbs"
case disableNetworkBreadcrumbs = "--disable-network-breadcrumbs"
Expand Down Expand Up @@ -135,7 +189,7 @@ public enum SentrySDKOverrides {
}
}

public static var boolValues: [Other] { [.disableAttachScreenshot, .disableAttachViewHierarchy, .disableSessionReplay, .disableMetricKit, .disableBreadcrumbs, .disableNetworkBreadcrumbs, .disableSwizzling, .disableCrashHandling, .disableSpotlight, .disableFileManagerSwizzling] }
public static var boolValues: [Other] { [.disableAttachScreenshot, .disableAttachViewHierarchy, .disableMetricKit, .disableBreadcrumbs, .disableNetworkBreadcrumbs, .disableSwizzling, .disableCrashHandling, .disableSpotlight, .disableFileManagerSwizzling] }
public static var stringVars: [Other] { [.userName, .userEmail] }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ public struct SentrySDKWrapper {
#endif // !os(macOS) && !os(tvOS) && !os(watchOS)

public func startSentry() {
SentrySDK.start(configureOptions: configureSentryOptions(options:))
if SentrySDK.isEnabled {
print("SentrySDK already enabled, closing it")
SentrySDK.close()
}

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

func configureSentryOptions(options: Options) {
Expand All @@ -33,17 +40,21 @@ public struct SentrySDKWrapper {
options.debug = true

#if !os(macOS) && !os(watchOS) && !os(visionOS)
if #available(iOS 16.0, *), !SentrySDKOverrides.Other.disableSessionReplay.boolValue {
if #available(iOS 16.0, *), !SentrySDKOverrides.SessionReplay.disableSessionReplay.boolValue {
options.sessionReplay = SentryReplayOptions(
sessionSampleRate: 0,
onErrorSampleRate: 1,
sessionSampleRate: SentrySDKOverrides.SessionReplay.sessionReplaySampleRate.floatValue ?? 0,
onErrorSampleRate: SentrySDKOverrides.SessionReplay.sessionReplayOnErrorSampleRate.floatValue ?? 1,
maskAllText: true,
maskAllImages: true
)
options.sessionReplay.quality = .high
options.sessionReplay.enableViewRendererV2 = true
// Disable the fast view renderering, because we noticed parts (like the tab bar) are not rendered correctly
options.sessionReplay.enableFastViewRendering = false

let defaultReplayQuality = SentryReplayOptions.SentryReplayQuality.high
options.sessionReplay.quality = SentryReplayOptions.SentryReplayQuality(rawValue: (SentrySDKOverrides.SessionReplay.sessionReplayQuality.stringValue as? NSString)?.integerValue ?? defaultReplayQuality.rawValue) ?? defaultReplayQuality

options.sessionReplay.enableViewRendererV2 = !SentrySDKOverrides.SessionReplay.disableViewRendererV2.boolValue

// Disable the fast view rendering, because we noticed parts (like the tab bar) are not rendered correctly
options.sessionReplay.enableFastViewRendering = SentrySDKOverrides.SessionReplay.enableFastViewRendering.boolValue
}

#if !os(tvOS)
Expand Down Expand Up @@ -378,13 +389,11 @@ extension SentrySDKWrapper {

var args: [String] {
let args = ProcessInfo.processInfo.arguments
print("[iOS-Swift] [debug] launch arguments: \(args)")
return args
}

var env: [String: String] {
let env = ProcessInfo.processInfo.environment
print("[iOS-Swift] [debug] environment: \(env)")
return env
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
name: SessionReplay-CameraTest
include:
- ../Shared/feature-flags.yml
createIntermediateGroups: true
generateEmptyDirectories: true
projectReferences:
Expand Down Expand Up @@ -32,3 +34,10 @@ targets:
- script: ../Shared/reset-git-info.sh
name: Reset Git Fields in Info.plist
basedOnDependencyAnalysis: false
schemes:
SessionReplay-CameraTest:
templates:
- SampleAppScheme
build:
targets:
SessionReplay-CameraTest: all
22 changes: 1 addition & 21 deletions Samples/SessionReplay-CameraTest/Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,9 @@ import UIKit

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

static var isSentryEnabled = true
static var isSessionReplayEnabled = true
static var isViewRendererV2Enabled = true

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
AppDelegate.reloadSentrySDK()

return true
}

static func reloadSentrySDK() {
if SentrySDK.isEnabled {
print("SentrySDK already started, closing it")
SentrySDK.close()
}

if !isSentryEnabled {
print("SentrySDK disabled")
return
}

SentrySDKWrapper.shared.startSentry()
return true
}

// MARK: UISceneSession Lifecycle
Expand Down
Loading
Loading