Skip to content

Commit dc44654

Browse files
committed
Fixed crashes and added a way to log while running.
1 parent 38a4b4e commit dc44654

File tree

4 files changed

+80
-36
lines changed

4 files changed

+80
-36
lines changed

sm_osx.xcodeproj/project.pbxproj

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
9669DC6D27D55CD200DE5FAB /* Patches.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9669DC6C27D55CD200DE5FAB /* Patches.swift */; };
1919
9669DC6F27D55D5300DE5FAB /* PatchesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9669DC6E27D55D5300DE5FAB /* PatchesView.swift */; };
2020
9669DC7127D55F4700DE5FAB /* RomView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9669DC7027D55F4700DE5FAB /* RomView.swift */; };
21-
9670CE8F281986B5005AA0CD /* AlertToBool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9670CE8E281986B5005AA0CD /* AlertToBool.swift */; };
2221
96BB22E327E274F700057915 /* RepoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BB22E227E274F700057915 /* RepoView.swift */; };
2322
96CF3D4227DBD8C7008A26F5 /* CompilationSpeed.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CF3D4127DBD8C7008A26F5 /* CompilationSpeed.swift */; };
2423
96DE71D327EB9C170090E7A0 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96DE71D227EB9C170090E7A0 /* SettingsView.swift */; };
@@ -38,7 +37,6 @@
3837
9669DC6C27D55CD200DE5FAB /* Patches.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Patches.swift; sourceTree = "<group>"; };
3938
9669DC6E27D55D5300DE5FAB /* PatchesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PatchesView.swift; sourceTree = "<group>"; };
4039
9669DC7027D55F4700DE5FAB /* RomView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RomView.swift; sourceTree = "<group>"; };
41-
9670CE8E281986B5005AA0CD /* AlertToBool.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertToBool.swift; sourceTree = "<group>"; };
4240
96BB22E227E274F700057915 /* RepoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RepoView.swift; sourceTree = "<group>"; };
4341
96CF3D4127DBD8C7008A26F5 /* CompilationSpeed.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompilationSpeed.swift; sourceTree = "<group>"; };
4442
96DE71D227EB9C170090E7A0 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
@@ -83,15 +81,14 @@
8381
9669DC6A27D5581F00DE5FAB /* Repos.swift */,
8482
9669DC6C27D55CD200DE5FAB /* Patches.swift */,
8583
9669DC6E27D55D5300DE5FAB /* PatchesView.swift */,
86-
9669DC7027D55F4700DE5FAB /* RomView.swift */,
8784
960D46F527D6850D0056E393 /* BuildingSteps.swift */,
85+
9669DC7027D55F4700DE5FAB /* RomView.swift */,
8886
96CF3D4127DBD8C7008A26F5 /* CompilationSpeed.swift */,
8987
96BB22E227E274F700057915 /* RepoView.swift */,
9088
96DE71D227EB9C170090E7A0 /* SettingsView.swift */,
9189
963F238227F8B211004E010E /* LauncherView.swift */,
9290
963F238427F8B942004E010E /* DataStore.xcdatamodeld */,
9391
963F238727F8BA01004E010E /* DataController.swift */,
94-
9670CE8E281986B5005AA0CD /* AlertToBool.swift */,
9592
);
9693
path = sm_osx;
9794
sourceTree = "<group>";
@@ -190,7 +187,6 @@
190187
9669DC6B27D5581F00DE5FAB /* Repos.swift in Sources */,
191188
96BB22E327E274F700057915 /* RepoView.swift in Sources */,
192189
9669DC5C27D5565000DE5FAB /* sm_osxApp.swift in Sources */,
193-
9670CE8F281986B5005AA0CD /* AlertToBool.swift in Sources */,
194190
);
195191
runOnlyForDeploymentPostprocessing = 0;
196192
};
@@ -325,7 +321,7 @@
325321
CODE_SIGN_IDENTITY = "Apple Development";
326322
CODE_SIGN_STYLE = Automatic;
327323
COMBINE_HIDPI_IMAGES = YES;
328-
CURRENT_PROJECT_VERSION = 16;
324+
CURRENT_PROJECT_VERSION = 18;
329325
DEVELOPMENT_ASSET_PATHS = "\"sm_osx/Preview Content\"";
330326
DEVELOPMENT_TEAM = 25RK3JMVLT;
331327
ENABLE_HARDENED_RUNTIME = NO;
@@ -339,7 +335,7 @@
339335
"$(inherited)",
340336
"@executable_path/../Frameworks",
341337
);
342-
MARKETING_VERSION = 1.1.6;
338+
MARKETING_VERSION = 1.1.7;
343339
ONLY_ACTIVE_ARCH = NO;
344340
PRODUCT_BUNDLE_IDENTIFIER = "com.CubingStudios.sm-osx";
345341
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -357,7 +353,7 @@
357353
CODE_SIGN_IDENTITY = "Apple Development";
358354
CODE_SIGN_STYLE = Automatic;
359355
COMBINE_HIDPI_IMAGES = YES;
360-
CURRENT_PROJECT_VERSION = 16;
356+
CURRENT_PROJECT_VERSION = 18;
361357
DEVELOPMENT_ASSET_PATHS = "\"sm_osx/Preview Content\"";
362358
DEVELOPMENT_TEAM = 25RK3JMVLT;
363359
ENABLE_HARDENED_RUNTIME = NO;
@@ -371,7 +367,7 @@
371367
"$(inherited)",
372368
"@executable_path/../Frameworks",
373369
);
374-
MARKETING_VERSION = 1.1.6;
370+
MARKETING_VERSION = 1.1.7;
375371
ONLY_ACTIVE_ARCH = NO;
376372
PRODUCT_BUNDLE_IDENTIFIER = "com.CubingStudios.sm-osx";
377373
PRODUCT_NAME = "$(TARGET_NAME)";

sm_osx/AlertToBool.swift

Lines changed: 0 additions & 7 deletions
This file was deleted.

sm_osx/CompilationSpeed.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ enum Speed: String {
1212
case normal = "-j2"
1313
case fast = "-j3"
1414
case veryFast = "-j6"
15-
case fastest = "-j64"
15+
case fastest = "-j"
1616
}

sm_osx/LauncherView.swift

Lines changed: 74 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,19 @@ struct LauncherView: View {
1717
@FetchRequest(sortDescriptors:[SortDescriptor(\.title)]) var launcherRepos: FetchedResults<LauncherRepos>
1818
@State var existingRepo = URL(string: "")
1919
@State var repoTitle = ""
20-
@State var currentVersion = "v1.1.6\n"
20+
@State var currentVersion = "v1.1.7\n"
2121
@State var updateAlert = false
2222
@State var latestVersion = ""
2323
@State var repoArgs = ""
2424
@State var crashStatus = false
2525
@State var crashLog = ""
2626
@State var readableCrashLog = ""
2727
@State var allowAddingRepos = true
28+
@State var beginLogging = false
2829
@AppStorage("firstLaunch") var firstLaunch = true
2930
@State var romURL = URL(string: "")
30-
let sm64: UTType = .init(filenameExtension: "f3dex2e")!
31-
let rom: UTType = .init(filenameExtension: "z64")!
31+
let sm64: UTType = .init(filenameExtension: "f3dex2e") ?? UTType.unixExecutable
32+
let rom: UTType = .init(filenameExtension: "z64") ?? UTType.unixExecutable
3233

3334
func launcherShell(_ command: String) throws -> String {
3435
self.crashLog = ""
@@ -44,7 +45,7 @@ struct LauncherView: View {
4445
let outHandle = pipe.fileHandleForReading
4546
outHandle.waitForDataInBackgroundAndNotify()
4647

47-
var obs1 : NSObjectProtocol!
48+
var obs1 : NSObjectProtocol?
4849
obs1 = NotificationCenter.default.addObserver(forName: Notification.Name.NSFileHandleDataAvailable, object: outHandle, queue: nil) { notification -> Void in
4950
let data = outHandle.availableData
5051

@@ -63,7 +64,7 @@ struct LauncherView: View {
6364
}
6465
}
6566

66-
var obs2 : NSObjectProtocol!
67+
var obs2 : NSObjectProtocol?
6768
obs2 = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: task, queue: nil) { notification -> Void in
6869
print("terminated")
6970

@@ -215,6 +216,23 @@ struct LauncherView: View {
215216
Image(systemName: "trash")
216217
}
217218

219+
Button(action: {
220+
221+
for i in 0...launcherRepos.count - 1 {
222+
launcherRepos[i].isEditing = false
223+
}
224+
225+
print(try? launcherShell("\(LauncherRepo.path ?? "its broken") \(LauncherRepo.args ?? "")"))
226+
227+
beginLogging = true
228+
229+
print(LauncherRepo.path ?? "")
230+
}) {
231+
Text("Log")
232+
233+
Image(systemName: "arrow.right.circle.fill")
234+
}
235+
218236
Button(action: {
219237

220238
for i in 0...launcherRepos.count - 1 {
@@ -246,8 +264,10 @@ struct LauncherView: View {
246264
if allowAddingRepos {
247265
Button(action:{
248266

249-
for i in 0...launcherRepos.count - 1 {
250-
launcherRepos[i].isEditing = false
267+
if !launcherRepos.isEmpty {
268+
for i in 0...launcherRepos.count - 1 {
269+
launcherRepos[i].isEditing = false
270+
}
251271
}
252272

253273
romURL = showOpenPanelForRom()
@@ -274,8 +294,10 @@ struct LauncherView: View {
274294

275295
Button(action:{
276296

277-
for i in 0...launcherRepos.count - 1 {
278-
launcherRepos[i].isEditing = false
297+
if !launcherRepos.isEmpty {
298+
for i in 0...launcherRepos.count - 1 {
299+
launcherRepos[i].isEditing = false
300+
}
279301
}
280302

281303
repoView = true
@@ -288,8 +310,10 @@ struct LauncherView: View {
288310

289311
Button("Add Existing Repo") {
290312

291-
for i in 0...launcherRepos.count - 1 {
292-
launcherRepos[i].isEditing = false
313+
if !launcherRepos.isEmpty {
314+
for i in 0...launcherRepos.count - 1 {
315+
launcherRepos[i].isEditing = false
316+
}
293317
}
294318

295319
existingRepo = showOpenPanel()
@@ -324,11 +348,11 @@ struct LauncherView: View {
324348
launcherRepos[i].isEditing = false
325349
}
326350

327-
print(try! shell.shell("brew install make mingw-w64 gcc sdl2 pkg-config glew glfw3 libusb audiofile coreutils"))
351+
print(try? shell.shell("brew install make mingw-w64 gcc sdl2 pkg-config glew glfw3 libusb audiofile coreutils"))
328352

329353
print("its intel's turn nerd what an idiot man")
330354

331-
print(try! shell.intelShell("/usr/local/bin/brew install gcc gcc@9 sdl2 pkg-config glew glfw3 libusb audiofile coreutils"))
355+
print(try? shell.intelShell("/usr/local/bin/brew install gcc gcc@9 sdl2 pkg-config glew glfw3 libusb audiofile coreutils"))
332356

333357
let content = UNMutableNotificationContent()
334358
content.title = "Finished installing dependencies"
@@ -349,14 +373,24 @@ struct LauncherView: View {
349373
}
350374

351375
}.onAppear {
352-
if try! checkRom("ls ~/SM64Repos/baserom.us.z64") {
353-
allowAddingRepos = true
376+
do {
377+
if try checkRom("ls ~/SM64Repos/baserom.us.z64") {
378+
allowAddingRepos = true
379+
}
380+
else {
381+
allowAddingRepos = false
382+
}
354383
}
355-
else {
356-
allowAddingRepos = false
384+
catch {
385+
print("Failed: \(error)")
357386
}
358387

359-
latestVersion = try! shell.shell("curl https://github.com/EmeraldLoc/sm_osx/releases/latest -s | grep -o 'v[0-9].[0-9].[0-9]*' | sort -u")
388+
do {
389+
latestVersion = try shell.shell("curl https://github.com/EmeraldLoc/sm_osx/releases/latest -s | grep -o 'v[0-9].[0-9].[0-9]*' | sort -u")
390+
}
391+
catch {
392+
print("Failed: \(error)")
393+
}
360394

361395
print("Latest Version: \(latestVersion), Current Version: \(currentVersion)")
362396

@@ -382,7 +416,7 @@ struct LauncherView: View {
382416

383417
}.alert("An Update is Avalible", isPresented: $updateAlert) {
384418
Button("Update", role: .none) {
385-
print(try! shell.shell("cd ~/Downloads && wget https://github.com/EmeraldLoc/sm_osx/releases/latest/download/sm_osx.zip && unzip sm_osx.zip && rm -rf sm_osx.zip /Applications/sm_osx.app && mv sm_osx.app /Applications && open /Applications/sm_osx.app"))
419+
print(try? shell.shell("cd ~/Downloads && wget https://github.com/EmeraldLoc/sm_osx/releases/latest/download/sm_osx.zip && unzip sm_osx.zip && rm -rf sm_osx.zip /Applications/sm_osx.app && mv sm_osx.app /Applications && open /Applications/sm_osx.app"))
386420

387421
exit(0)
388422
}
@@ -400,6 +434,8 @@ struct LauncherView: View {
400434
readableCrashLog = crashLog
401435
}
402436
.onAppear {
437+
beginLogging = false
438+
403439
readableCrashLog = crashLog
404440
}
405441
}
@@ -410,6 +446,25 @@ struct LauncherView: View {
410446
crashStatus = false
411447
}
412448
}.frame(minWidth: 350, maxHeight: 350)
449+
}.sheet(isPresented: $beginLogging) {
450+
VStack {
451+
TextEditor(text: $readableCrashLog)
452+
.frame(minWidth: 350, minHeight: 350)
453+
.onChange(of: readableCrashLog) { _ in
454+
readableCrashLog = crashLog
455+
}.onChange(of: crashLog) { _ in
456+
readableCrashLog = crashLog
457+
}
458+
.onAppear {
459+
readableCrashLog = crashLog
460+
}
461+
462+
Spacer()
463+
464+
Button("Finish") {
465+
beginLogging = false
466+
}
467+
}
413468
}
414469
}
415470
}

0 commit comments

Comments
 (0)