Skip to content

Commit 03fb954

Browse files
committed
Fix macOS versions without open --arch
1 parent cc1c7e7 commit 03fb954

File tree

1 file changed

+32
-8
lines changed

1 file changed

+32
-8
lines changed

SS14.Launcher/Models/Connector.cs

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Net.Http;
88
using System.Net.Http.Json;
99
using System.Runtime.InteropServices;
10+
using System.Text;
1011
using System.Text.Json;
1112
using System.Text.Json.Serialization;
1213
using System.Threading;
@@ -574,12 +575,17 @@ private async Task<ContentLaunchInfo> InstallContentBundleAsync(
574575
startInfo.UseShellExecute = false;
575576
startInfo.ArgumentList.AddRange(extraArgs);
576577

577-
/*
578-
foreach (var arg in startInfo.ArgumentList)
578+
var commandBuilder = new StringBuilder();
579+
commandBuilder.Append(startInfo.FileName);
580+
581+
for (var i = 0; i < startInfo.ArgumentList.Count; i++)
579582
{
580-
Log.Debug("arg: {Arg}", arg);
583+
var arg = startInfo.ArgumentList[i];
584+
585+
commandBuilder.Append($" [{i}] {arg}");
581586
}
582-
*/
587+
588+
Log.Debug("Launch command: {LaunchCommand}", commandBuilder.ToString());
583589

584590
var process = Process.Start(startInfo);
585591

@@ -743,13 +749,31 @@ private static async Task<ProcessStartInfo> GetLoaderStartInfo()
743749

744750
await xattr.WaitForExitAsync();
745751

746-
var arch = RuntimeInformation.ProcessArchitecture == Architecture.Arm64 ? "arm64" : "x86_64";
747-
748-
return new ProcessStartInfo
752+
var startInfo = new ProcessStartInfo
749753
{
750754
FileName = "open",
751-
ArgumentList = {appPath, "--arch", arch, "--args"},
755+
ArgumentList = { appPath }
752756
};
757+
758+
if (RuntimeInformation.OSArchitecture != Architecture.X64)
759+
{
760+
// Intel macs may be running unsupported macOS versions without open --arch.
761+
// So don't add it. It's not necessary anyways.
762+
763+
// Versions before Sonoma also don't have it.
764+
// If you're on one of those... uhh.. Why are you running an outdated OS?
765+
// But don't add --arch so that people on an outdated OS can still use native Apple Silicon.
766+
if (OperatingSystem.IsMacOSVersionAtLeast(14))
767+
{
768+
startInfo.ArgumentList.Add("--arch");
769+
startInfo.ArgumentList.Add(
770+
RuntimeInformation.ProcessArchitecture == Architecture.Arm64 ? "arm64" : "x86_64");
771+
}
772+
}
773+
774+
startInfo.ArgumentList.Add("--args");
775+
776+
return startInfo;
753777
}
754778
else
755779
{

0 commit comments

Comments
 (0)