Skip to content

Commit 53d4963

Browse files
[ios/catalyst] fix for "sandboxed" platforms (dotnet#2930)
Context: dotnet#2929 Without this fix, I was getting the exception on `net10.0-ios` and `net10.0-maccatalyst` projects: Access to the path '~/src/dotnet/BenchmarkDotNet/samples/BenchmarkDotNet.Samples.Maui/bin/Debug/net10.0-maccatalyst/maccatalyst-arm64/BenchmarkDotNet.Samples.Maui.app/BenchmarkDotNet.Artifacts' is denied. This change was already here for Android, but it feels like it should have been here for iOS as well. `net10.0-maccatalyst` will also respond to this fix, as it is basically iOS "emulated" on macOS.
1 parent 0818e53 commit 53d4963

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/BenchmarkDotNet/Configs/DefaultConfig.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,17 @@ public string ArtifactsPath
9494
{
9595
get
9696
{
97-
var root = OsDetector.IsAndroid() ?
98-
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) :
99-
Directory.GetCurrentDirectory();
97+
string root;
98+
if (OsDetector.IsAndroid() || OsDetector.IsIOS())
99+
{
100+
// On mobile platforms (Android, iOS, and Mac Catalyst), use a writable location
101+
// because the app bundle and current directory are read-only due to sandboxing
102+
root = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
103+
}
104+
else
105+
{
106+
root = Directory.GetCurrentDirectory();
107+
}
100108
return Path.Combine(root, "BenchmarkDotNet.Artifacts");
101109
}
102110
}

0 commit comments

Comments
 (0)