Skip to content

Commit ec14767

Browse files
committed
Hopefully fix some weird issues
1 parent f9c1f46 commit ec14767

49 files changed

Lines changed: 2421 additions & 2250 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ xcuserdata/
1515
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
1616
build/
1717
DerivedData/
18+
.derivedData*/
1819
*.moved-aside
1920
*.pbxuser
2021
!default.pbxuser

StikDebug.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@
579579
);
580580
MACOSX_DEPLOYMENT_TARGET = 15.1;
581581
MARKETING_VERSION = 1.0;
582-
PRODUCT_BUNDLE_IDENTIFIER = com.stik.StikDebugTests;
582+
PRODUCT_BUNDLE_IDENTIFIER = com.stik.stikdebug.tests;
583583
PRODUCT_NAME = "$(TARGET_NAME)";
584584
SDKROOT = auto;
585585
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
@@ -611,7 +611,7 @@
611611
);
612612
MACOSX_DEPLOYMENT_TARGET = 15.1;
613613
MARKETING_VERSION = 1.0;
614-
PRODUCT_BUNDLE_IDENTIFIER = com.stik.StikDebugTests;
614+
PRODUCT_BUNDLE_IDENTIFIER = com.stik.stikdebug.tests;
615615
PRODUCT_NAME = "$(TARGET_NAME)";
616616
SDKROOT = auto;
617617
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
@@ -634,7 +634,7 @@
634634
IPHONEOS_DEPLOYMENT_TARGET = 18.2;
635635
MACOSX_DEPLOYMENT_TARGET = 15.1;
636636
MARKETING_VERSION = 1.0;
637-
PRODUCT_BUNDLE_IDENTIFIER = com.stik.StikDebugUITests;
637+
PRODUCT_BUNDLE_IDENTIFIER = com.stik.stikdebug.uitests;
638638
PRODUCT_NAME = "$(TARGET_NAME)";
639639
SDKROOT = auto;
640640
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
@@ -656,7 +656,7 @@
656656
IPHONEOS_DEPLOYMENT_TARGET = 18.2;
657657
MACOSX_DEPLOYMENT_TARGET = 15.1;
658658
MARKETING_VERSION = 1.0;
659-
PRODUCT_BUNDLE_IDENTIFIER = com.stik.StikDebugUITests;
659+
PRODUCT_BUNDLE_IDENTIFIER = com.stik.stikdebug.uitests;
660660
PRODUCT_NAME = "$(TARGET_NAME)";
661661
SDKROOT = auto;
662662
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//
2+
// AppBootstrapper.swift
3+
// StikDebug
4+
//
5+
6+
import Foundation
7+
import ObjectiveC.runtime
8+
import UIKit
9+
10+
enum AppBootstrapper {
11+
static func configure() {
12+
registerDefaultSettings()
13+
startConfiguredKeepAliveServices()
14+
applyDocumentPickerCopyWorkaround()
15+
}
16+
17+
private static func registerDefaultSettings() {
18+
let os = ProcessInfo.processInfo.operatingSystemVersion
19+
let enableAdvancedOptions = os.majorVersion >= 19
20+
21+
UserDefaults.standard.register(defaults: [
22+
"enableAdvancedOptions": enableAdvancedOptions,
23+
UserDefaults.Keys.txmOverride: false,
24+
"keepAliveAudio": true,
25+
"keepAliveLocation": true
26+
])
27+
}
28+
29+
private static func startConfiguredKeepAliveServices() {
30+
guard UserDefaults.standard.bool(forKey: "keepAliveAudio") else {
31+
return
32+
}
33+
BackgroundAudioManager.shared.start()
34+
}
35+
36+
private static func applyDocumentPickerCopyWorkaround() {
37+
let fixedSelector = NSSelectorFromString("fix_initForOpeningContentTypes:asCopy:")
38+
let originalSelector = #selector(UIDocumentPickerViewController.init(forOpeningContentTypes:asCopy:))
39+
40+
guard let fixedMethod = class_getInstanceMethod(UIDocumentPickerViewController.self, fixedSelector),
41+
let originalMethod = class_getInstanceMethod(UIDocumentPickerViewController.self, originalSelector) else {
42+
return
43+
}
44+
45+
method_exchangeImplementations(originalMethod, fixedMethod)
46+
}
47+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ struct StikDebugShortcuts: AppShortcutsProvider {
298298

299299
func ensureTunnel() async {
300300
await MainActor.run {
301-
pubTunnelConnected = false
301+
markTunnelDisconnected()
302302
startTunnelInBackground(showErrorUI: false)
303303
}
304304
try? await Task.sleep(nanoseconds: 1_000_000_000)

StikDebug/App/StikDebugApp.swift

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
//
2+
// StikDebugApp.swift
3+
// StikDebug
4+
//
5+
// Created by Stephen on 3/26/25.
6+
//
7+
8+
import SwiftUI
9+
10+
@main
11+
struct StikDebugApp: App {
12+
@Environment(\.scenePhase) private var scenePhase
13+
@State private var shouldAttemptTunnelReconnect = false
14+
15+
init() {
16+
AppBootstrapper.configure()
17+
}
18+
19+
var body: some Scene {
20+
WindowGroup {
21+
MainTabView()
22+
.task {
23+
await downloadMissingDeveloperDiskImageFiles()
24+
}
25+
.onChange(of: scenePhase) { _, newPhase in
26+
handleScenePhaseChange(newPhase)
27+
}
28+
}
29+
}
30+
31+
private func handleScenePhaseChange(_ newPhase: ScenePhase) {
32+
switch newPhase {
33+
case .background:
34+
shouldAttemptTunnelReconnect = true
35+
case .active:
36+
if shouldAttemptTunnelReconnect {
37+
shouldAttemptTunnelReconnect = false
38+
startTunnelInBackground(showErrorUI: false)
39+
}
40+
default:
41+
break
42+
}
43+
}
44+
45+
private func downloadMissingDeveloperDiskImageFiles() async {
46+
do {
47+
try await DeveloperDiskImageService.shared.downloadMissingFiles()
48+
} catch {
49+
await MainActor.run {
50+
showAlert(
51+
title: "An Error has Occurred",
52+
message: "[Download DDI Error]: \(error.localizedDescription)",
53+
showOk: true
54+
)
55+
}
56+
}
57+
}
58+
}
Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,4 @@ final class LogManager: ObservableObject {
9090
self.errorCount = 0
9191
}
9292
}
93-
94-
func removeOldestLogs(count: Int) {
95-
DispatchQueue.main.async {
96-
let removed = self.logs.prefix(count)
97-
self.logs.removeFirst(count)
98-
let removedErrors = removed.filter { $0.type == .error }.count
99-
self.errorCount = max(0, self.errorCount - removedErrors)
100-
}
101-
}
10293
}
File renamed without changes.

StikDebug/Utilities/DeviceInfoManager.swift renamed to StikDebug/Device/DeviceInfoManager.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,9 @@ struct CSVDocument: FileDocument {
379379
static var writableContentTypes: [UTType] { [UTType.commaSeparatedText] }
380380
let url: URL?
381381
init(url: URL?) { self.url = url }
382-
init(configuration: ReadConfiguration) throws { fatalError("Not supported") }
382+
init(configuration: ReadConfiguration) throws {
383+
throw CocoaError(.fileReadUnsupportedScheme)
384+
}
383385
func fileWrapper(configuration: WriteConfiguration) throws -> FileWrapper {
384386
guard let url = url else { throw NSError(domain: "CSVDocument", code: -1) }
385387
return try FileWrapper(url: url, options: .immediate)

0 commit comments

Comments
 (0)